From c91b004b0b1db27db76ebf912e3d8ef371fc7c1d Mon Sep 17 00:00:00 2001 From: Peter Szanto Date: Sun, 31 Jul 2016 04:16:22 +0200 Subject: [PATCH 1/3] fixing bug of rendering an extra spaces into @FeignClient annotation properties --- .../JavaSpring/libraries/spring-cloud/apiClient.mustache | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache index 57d227f6bbb..52fedbea776 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-cloud/apiClient.mustache @@ -3,6 +3,8 @@ package {{package}}; import org.springframework.cloud.netflix.feign.FeignClient; import {{configPackage}}.ClientConfiguration; -@FeignClient(name="${ {{{title}}}.name:{{{title}}}}", url="${ {{{title}}}.url:{{{basePath}}}}", configuration = ClientConfiguration.class) +{{=<% %>=}} +@FeignClient(name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class) +<%={{ }}=%> public interface {{classname}}Client extends {{classname}} { } \ No newline at end of file From abd5b3f4ded12b7276f42d0821339edd2be6753c Mon Sep 17 00:00:00 2001 From: Peter Szanto Date: Mon, 1 Aug 2016 14:50:09 +0200 Subject: [PATCH 2/3] regenerated the spring-cloud sample --- .../spring-cloud/src/main/java/io/swagger/api/PetApiClient.java | 2 +- .../src/main/java/io/swagger/api/StoreApiClient.java | 2 +- .../src/main/java/io/swagger/api/UserApiClient.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApiClient.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApiClient.java index 4b65141b5c1..64bd0b2f70c 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApiClient.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApiClient.java @@ -3,6 +3,6 @@ import org.springframework.cloud.netflix.feign.FeignClient; import io.swagger.configuration.ClientConfiguration; -@FeignClient(name="${ swaggerPetstore.name:swaggerPetstore}", url="${ swaggerPetstore.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +@FeignClient(name="${swaggerPetstore.name:swaggerPetstore}", url="${swaggerPetstore.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) public interface PetApiClient extends PetApi { } \ No newline at end of file diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApiClient.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApiClient.java index 2f43ae1839f..99321fe75ee 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApiClient.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApiClient.java @@ -3,6 +3,6 @@ import org.springframework.cloud.netflix.feign.FeignClient; import io.swagger.configuration.ClientConfiguration; -@FeignClient(name="${ swaggerPetstore.name:swaggerPetstore}", url="${ swaggerPetstore.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +@FeignClient(name="${swaggerPetstore.name:swaggerPetstore}", url="${swaggerPetstore.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) public interface StoreApiClient extends StoreApi { } \ No newline at end of file diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApiClient.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApiClient.java index 45c00ef8adc..1d8783803f3 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApiClient.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApiClient.java @@ -3,6 +3,6 @@ import org.springframework.cloud.netflix.feign.FeignClient; import io.swagger.configuration.ClientConfiguration; -@FeignClient(name="${ swaggerPetstore.name:swaggerPetstore}", url="${ swaggerPetstore.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) +@FeignClient(name="${swaggerPetstore.name:swaggerPetstore}", url="${swaggerPetstore.url:http://petstore.swagger.io/v2}", configuration = ClientConfiguration.class) public interface UserApiClient extends UserApi { } \ No newline at end of file From 9cc4e1fee07ddfd40699e2bb6425156d911b6668 Mon Sep 17 00:00:00 2001 From: Peter Szanto Date: Mon, 1 Aug 2016 15:16:00 +0200 Subject: [PATCH 3/3] updated readme.md --- samples/client/petstore/spring-cloud/README.md | 9 +++++++++ samples/client/petstore/spring-stubs/README.md | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/spring-cloud/README.md b/samples/client/petstore/spring-cloud/README.md index 0d2d58540db..e00582169b8 100644 --- a/samples/client/petstore/spring-cloud/README.md +++ b/samples/client/petstore/spring-cloud/README.md @@ -1,5 +1,14 @@ # swagger-petstore-spring-cloud +Spring cloud (Feign) client can be generated using the below command : +```shell +swagger-codegen-cli generate \ + -l spring \ + -i http://petstore.swagger.io/v2/swagger.json \ + -DhideGenerationTimestamp=true +``` +example is [here](https://github.com/swagger-api/swagger-codegen/blob/master/bin/spring-cloud-feign-petstore.sh) + ## Requirements Building the API client library requires [Maven](https://maven.apache.org/) to be installed. diff --git a/samples/client/petstore/spring-stubs/README.md b/samples/client/petstore/spring-stubs/README.md index 99663f64082..fe1a6233e39 100644 --- a/samples/client/petstore/spring-stubs/README.md +++ b/samples/client/petstore/spring-stubs/README.md @@ -1,6 +1,15 @@ - # Swagger generated API stub +Spring stub can be generated using the below command : +```shell +swagger-codegen-cli generate \ + -l spring \ + -i http://petstore.swagger.io/v2/swagger.json \ + -DinterfaceOnly=true,singleContentTypes=true,hideGenerationTimestamp=true +``` +example is [here](https://github.com/swagger-api/swagger-codegen/blob/master/bin/spring-stubs.sh) + + Spring Framework stub