diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java index a90533a3614..62642183906 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java @@ -2,6 +2,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenOperation; +import io.swagger.codegen.CodegenResponse; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; import io.swagger.models.Operation; @@ -146,6 +147,14 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen if (operations != null) { List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { + List responses = operation.responses; + if (responses != null) { + for (CodegenResponse resp : responses) { + if ("0".equals(resp.code)) { + resp.code = "200"; + } + } + } if (operation.returnType == null) { operation.returnType = "Void"; } else if (operation.returnType.startsWith("List")) { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/README.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/README.mustache index f357cb9a081..9cf2b4bc6e8 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/README.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/README.mustache @@ -8,4 +8,5 @@ This server was generated by the [swagger-codegen](https://github.com/swagger-ap The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox) -You can view the server in swagger-ui by pointing to http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}/sdoc.jsp \ No newline at end of file +You can view the server in swagger-ui by pointing to +http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}/swagger-ui.html \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache index d6a24b69311..4f3c5489169 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache @@ -8,8 +8,8 @@ import {{modelPackage}}.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import io.swagger.model.ApiResponse; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -35,8 +35,8 @@ public class {{classname}} { {{#operation}} @ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}) - @ApiResponses(value = { {{#responses}} - @ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},{{/hasMore}}{{/responses}} }) + @io.swagger.annotations.ApiResponses(value = { {{#responses}} + @io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},{{/hasMore}}{{/responses}} }) @RequestMapping(value = "{{path}}", {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}} {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache index 3b068adffdf..9896c3ac6d8 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache @@ -33,8 +33,7 @@ {{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} - target/${project.artifactId}-${project-version} - ${project.basedir}/conf/jetty/webdefault.xml + target/${project.artifactId}-${project.version} 8079 stopit @@ -63,49 +62,6 @@ - - com.googlecode.maven-download-plugin - download-maven-plugin - 1.2.1 - - - swagger-ui - - wget - - - https://github.com/swagger-api/swagger-ui/archive/v${swagger-ui-version}.tar.gz - true - ${project.build.directory} - - - - - - maven-resources-plugin - 2.6 - - - copy-resources - validate - - copy-resources - - - target/${project.artifactId}-${project.version} - - - ${project.build.directory}/swagger-ui-${swagger-ui-version}/dist - true - - index.html - - - - - - - @@ -163,21 +119,6 @@ - - io.springfox - springfox-core - ${springfox-version} - - - io.springfox - springfox-spi - ${springfox-version} - - - io.springfox - springfox-spring-web - ${springfox-version} - io.springfox springfox-swagger2 @@ -189,12 +130,6 @@ ${springfox-version} - - org.scalatest - scalatest_2.9.1 - ${scala-test-version} - test - junit junit @@ -217,13 +152,12 @@ 1.5.0 9.2.9.v20150224 - 2.1.0-M2 1.13 1.6.3 1.6.1 4.8.1 2.5 - 2.0.0-SNAPSHOT + 2.0.4-SNAPSHOT 4.0.9.RELEASE \ No newline at end of file diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index 30cd3a41484..0aaf79440b4 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -63,49 +63,6 @@ - - com.googlecode.maven-download-plugin - download-maven-plugin - 1.2.1 - - - swagger-ui - - wget - - - https://github.com/swagger-api/swagger-ui/archive/v${swagger-ui-version}.tar.gz - true - ${project.build.directory} - - - - - - maven-resources-plugin - 2.6 - - - copy-resources - validate - - copy-resources - - - target/${project.artifactId}-${project.version} - - - ${project.build.directory}/swagger-ui-${swagger-ui-version}/dist - true - - index.html - - - - - - - @@ -163,21 +120,6 @@ - - io.springfox - springfox-core - ${springfox-version} - - - io.springfox - springfox-spi - ${springfox-version} - - - io.springfox - springfox-spring-web - ${springfox-version} - io.springfox springfox-swagger2 @@ -189,12 +131,6 @@ ${springfox-version} - - org.scalatest - scalatest_2.9.1 - ${scala-test-version} - test - junit junit @@ -223,7 +159,7 @@ 1.6.1 4.8.1 2.5 - 2.0.0-SNAPSHOT + 2.0.4-SNAPSHOT 4.0.9.RELEASE \ No newline at end of file