Added Swagger UI to all services
This commit is contained in:
@@ -123,3 +123,5 @@ Simply run the command `docker-compose up` to launch the services.
|
|||||||
This will create containers for MongoDB and each of the services.
|
This will create containers for MongoDB and each of the services.
|
||||||
|
|
||||||
You can now, for example, use the curl commands in `handy-curl-commands.sh` to interact with the server.
|
You can now, for example, use the curl commands in `handy-curl-commands.sh` to interact with the server.
|
||||||
|
|
||||||
|
You can also use the Swagger UI exposed by each service `http://host:port/swagger-ui.html`.
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ apply plugin: 'spring-boot'
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(":accounts-command-side-web")
|
compile project(":accounts-command-side-web")
|
||||||
|
compile project(":common-swagger")
|
||||||
|
|
||||||
compile "org.springframework.boot:spring-boot-starter-web"
|
compile "org.springframework.boot:spring-boot-starter-web"
|
||||||
compile "org.springframework.boot:spring-boot-starter-actuator"
|
compile "org.springframework.boot:spring-boot-starter-actuator"
|
||||||
|
|
||||||
|
|
||||||
compile "net.chrisrichardson.eventstore.client:eventstore-http-stomp-client_2.10:$eventStoreClientVersion"
|
compile "net.chrisrichardson.eventstore.client:eventstore-http-stomp-client_2.10:$eventStoreClientVersion"
|
||||||
|
|
||||||
testCompile "org.springframework.boot:spring-boot-starter-test"
|
testCompile "org.springframework.boot:spring-boot-starter-test"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.chrisrichardson.eventstore.javaexamples.banking.web;
|
package net.chrisrichardson.eventstore.javaexamples.banking.web;
|
||||||
|
|
||||||
import net.chrisrichardson.eventstore.client.config.EventStoreHttpClientConfiguration;
|
import net.chrisrichardson.eventstore.client.config.EventStoreHttpClientConfiguration;
|
||||||
|
import net.chrisrichardson.eventstore.javaexamples.banking.commonswagger.CommonSwaggerConfiguration;
|
||||||
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts.CommandSideWebAccountsConfiguration;
|
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts.CommandSideWebAccountsConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
||||||
@@ -12,7 +13,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
|||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({CommandSideWebAccountsConfiguration.class, EventStoreHttpClientConfiguration.class })
|
@Import({CommandSideWebAccountsConfiguration.class, EventStoreHttpClientConfiguration.class, CommonSwaggerConfiguration.class})
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
public class AccountsCommandSideServiceConfiguration {
|
public class AccountsCommandSideServiceConfiguration {
|
||||||
@@ -24,4 +25,5 @@ public class AccountsCommandSideServiceConfiguration {
|
|||||||
return new HttpMessageConverters(additional);
|
return new HttpMessageConverters(additional);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ apply plugin: 'spring-boot'
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(":accounts-query-side-web")
|
compile project(":accounts-query-side-web")
|
||||||
|
compile project(":common-swagger")
|
||||||
|
|
||||||
compile "org.springframework.boot:spring-boot-starter-web"
|
compile "org.springframework.boot:spring-boot-starter-web"
|
||||||
compile "org.springframework.boot:spring-boot-starter-actuator"
|
compile "org.springframework.boot:spring-boot-starter-actuator"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.chrisrichardson.eventstore.javaexamples.banking.web;
|
package net.chrisrichardson.eventstore.javaexamples.banking.web;
|
||||||
|
|
||||||
import net.chrisrichardson.eventstore.client.config.EventStoreHttpClientConfiguration;
|
import net.chrisrichardson.eventstore.client.config.EventStoreHttpClientConfiguration;
|
||||||
|
import net.chrisrichardson.eventstore.javaexamples.banking.commonswagger.CommonSwaggerConfiguration;
|
||||||
import net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.QuerySideWebConfiguration;
|
import net.chrisrichardson.eventstore.javaexamples.banking.web.queryside.QuerySideWebConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
||||||
@@ -12,7 +13,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
|||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({QuerySideWebConfiguration.class, EventStoreHttpClientConfiguration.class})
|
@Import({QuerySideWebConfiguration.class, EventStoreHttpClientConfiguration.class, CommonSwaggerConfiguration.class})
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
public class AccountsQuerySideServiceConfiguration {
|
public class AccountsQuerySideServiceConfiguration {
|
||||||
|
|||||||
7
java-spring/common-swagger/build.gradle
Normal file
7
java-spring/common-swagger/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
dependencies {
|
||||||
|
compile "net.chrisrichardson.eventstore.client:eventstore-java-client_2.10:$eventStoreClientVersion"
|
||||||
|
|
||||||
|
compile "io.springfox:springfox-swagger2:2.2.2"
|
||||||
|
compile 'io.springfox:springfox-swagger-ui:2.2.2'
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package net.chrisrichardson.eventstore.javaexamples.banking.commonswagger;
|
||||||
|
|
||||||
|
import com.fasterxml.classmate.TypeResolver;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
import rx.Observable;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.schema.WildcardType;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
import static springfox.documentation.schema.AlternateTypeRules.newRule;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
public class CommonSwaggerConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket api() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("net.chrisrichardson.eventstore.javaexamples.banking"))
|
||||||
|
.build()
|
||||||
|
.pathMapping("/")
|
||||||
|
.genericModelSubstitutes(ResponseEntity.class, Observable.class)
|
||||||
|
.alternateTypeRules(
|
||||||
|
newRule(typeResolver.resolve(DeferredResult.class,
|
||||||
|
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
|
||||||
|
typeResolver.resolve(WildcardType.class))
|
||||||
|
)
|
||||||
|
.useDefaultResponseMessages(false)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TypeResolver typeResolver;
|
||||||
|
|
||||||
|
}
|
||||||
4
java-spring/mongodb-cli.sh
Executable file
4
java-spring/mongodb-cli.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
docker run --link javaspring_mongodb_1:mongodb -i -t mongo:3.0.4 /usr/bin/mongo --host mongodb
|
||||||
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
include 'testutil'
|
include 'testutil'
|
||||||
include 'common-web'
|
include 'common-web'
|
||||||
|
include 'common-swagger'
|
||||||
|
|
||||||
include 'common-backend'
|
include 'common-backend'
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ apply plugin: VerifyEventStoreEnvironmentPlugin
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(":transactions-command-side-web")
|
compile project(":transactions-command-side-web")
|
||||||
|
compile project(":common-swagger")
|
||||||
|
|
||||||
compile "org.springframework.boot:spring-boot-starter-web"
|
compile "org.springframework.boot:spring-boot-starter-web"
|
||||||
compile "org.springframework.boot:spring-boot-starter-actuator"
|
compile "org.springframework.boot:spring-boot-starter-actuator"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.chrisrichardson.eventstore.javaexamples.banking.web;
|
package net.chrisrichardson.eventstore.javaexamples.banking.web;
|
||||||
|
|
||||||
import net.chrisrichardson.eventstore.client.config.EventStoreHttpClientConfiguration;
|
import net.chrisrichardson.eventstore.client.config.EventStoreHttpClientConfiguration;
|
||||||
|
import net.chrisrichardson.eventstore.javaexamples.banking.commonswagger.CommonSwaggerConfiguration;
|
||||||
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions.CommandSideWebTransactionsConfiguration;
|
import net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions.CommandSideWebTransactionsConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
||||||
@@ -12,7 +13,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
|||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({CommandSideWebTransactionsConfiguration.class, EventStoreHttpClientConfiguration.class})
|
@Import({CommandSideWebTransactionsConfiguration.class, EventStoreHttpClientConfiguration.class, CommonSwaggerConfiguration.class})
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
public class TransactionsCommandSideServiceConfiguration {
|
public class TransactionsCommandSideServiceConfiguration {
|
||||||
|
|||||||
Reference in New Issue
Block a user