diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/SpringfoxServerCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/SpringfoxServerCodegen.java
index 51fe4cb081b..7382d5f0bab 100644
--- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/SpringfoxServerCodegen.java
+++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/SpringfoxServerCodegen.java
@@ -10,12 +10,12 @@ import java.util.*;
import java.io.File;
public class SpringfoxServerCodegen extends JavaClientCodegen implements CodegenConfig {
- protected String invokerPackage = "com.concur.service.api";
- protected String groupId = "com.concur.service";
+ protected String invokerPackage = "io.swagger.api";
+ protected String groupId = "io.swagger";
protected String artifactId = "swagger-server";
protected String artifactVersion = "1.0.0";
protected String sourceFolder = "src/main/java";
- protected String title = "Concur Server";
+ protected String title = "Petstore Server";
protected String configPackage = "";
@@ -37,9 +37,9 @@ public class SpringfoxServerCodegen extends JavaClientCodegen implements Codegen
modelTemplateFiles.put("model.mustache", ".java");
apiTemplateFiles.put("api.mustache", ".java");
templateDir = "JavaSpringfox";
- apiPackage = "com.concur.service.api";
- modelPackage = "com.concur.service.model";
- configPackage = "com.concur.service.configuration";
+ apiPackage = "io.swagger.api";
+ modelPackage = "io.swagger.model";
+ configPackage = "io.swagger.configuration";
additionalProperties.put("invokerPackage", invokerPackage);
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringfox/SwaggerConfig.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringfox/SwaggerConfig.mustache
index 81418e4a9ef..f58adcf2ca4 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringfox/SwaggerConfig.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringfox/SwaggerConfig.mustache
@@ -1,40 +1,28 @@
package {{configPackage}};
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-
-import springdox.documentation.swagger2.annotations.EnableSwagger2;
-import springdox.documentation.spring.web.plugins.DocumentationConfigurer;
-
-import springdox.documentation.spi.DocumentationType;
-import springdox.documentation.service.ApiInfo;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-
-import java.util.Set;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
+@ComponentScan(basePackages = "{{apiPackage}}")
@EnableWebMvc
@EnableSwagger2 //Loads the spring beans required by the framework
public class SwaggerConfig {
-private DocumentationConfigurer documentationConfigurer;
-
- @Autowired
- public void setDocumentationConfigurer(DocumentationConfigurer configurer){
- this.documentationConfigurer = documentationConfigurer;
- }
-
@Bean
ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo(
"{{appName}}",
"{{appDescription}}",
- "1.0.0",
- "My Apps API terms of service",
+ "{{appVersion}}",
+ "{{infoUrl}}",
"{{infoEmail}}",
"{{licenseInfo}}",
"{{licenseUrl}}" );
@@ -42,14 +30,8 @@ private DocumentationConfigurer documentationConfigurer;
}
@Bean
- public DocumentationConfigurer customImplementation(){
- return new DocumentationConfigurer(DocumentationType.SWAGGER_2)
- .groupName("default")
- .includePatterns(".*replace {{appName}} with your api classes.*")
- .apiInfo(apiInfo());
+ public Docket customImplementation(){
+ return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
}
- @Bean
- ObjectMapper objectMapper() { return new ObjectMapper(); }
-
}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringfox/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringfox/api.mustache
index 9514cf1b565..007a4a75ccf 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringfox/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringfox/api.mustache
@@ -2,49 +2,50 @@ package {{apiPackage}};
import {{modelPackage}}.*;
-import com.wordnik.swagger.annotations.*;
-
-import com.sun.jersey.multipart.FormDataParam;
-
{{#imports}}import {{import}};
{{/imports}}
-import java.util.List;
-import {{package}}.NotFoundException;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.*;
-
-import java.io.InputStream;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+import com.wordnik.swagger.annotations.ApiParam;
+import com.wordnik.swagger.annotations.ApiResponse;
+import com.wordnik.swagger.annotations.ApiResponses;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RequestPart;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
import static org.springframework.http.MediaType.*;
@Controller
-@RequestMapping("/{{baseName}}",produces = {APPLICATION_JSON_VALUE})
+@RequestMapping(value = "/{{baseName}}", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/{{baseName}}", description = "the {{baseName}} API")
{{#operations}}
public class {{classname}} {
{{#operation}}
- {{#subresourceOperation}}@RequestMapping(value = "{{path}}", method = RequestMethod.{{httpMethod}} ){{/subresourceOperation}}
- {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
- {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}})
@ApiResponses(value = { {{#responses}}
- @ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}},
- {{/hasMore}}{{/responses}} })
-
- public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
+ @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}}
+ method = RequestMethod.{{httpMethod}})
+ public ResponseEntity<{{returnType}}> {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
{{/hasMore}}{{/allParams}})
throws NotFoundException {
// do some magic!
- return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
+ return new ResponseEntity<{{returnType}}>(HttpStatus.OK);
}
{{/operation}}
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringfox/formParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringfox/formParams.mustache
index ba842165f3d..83c928ea92e 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringfox/formParams.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringfox/formParams.mustache
@@ -1,2 +1,2 @@
-{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @FormDataParam("file") InputStream inputStream,
- @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
\ No newline at end of file
+{{#isFormParam}}{{#notFile}}
+@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@RequestPart("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileDetail{{/isFile}}{{/isFormParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringfox/headerParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringfox/headerParams.mustache
index 0f88692ad1d..dd0ea1ad4ce 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringfox/headerParams.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringfox/headerParams.mustache
@@ -1 +1 @@
-{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@HeaderParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
+{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@RequestHeader("{{paramName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringfox/pathParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringfox/pathParams.mustache
index 1f1b30887a4..4a6f7dfc922 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringfox/pathParams.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringfox/pathParams.mustache
@@ -1 +1 @@
-{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
\ No newline at end of file
+{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringfox/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringfox/pom.mustache
index 9ead2787b3c..44dd031f37e 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringfox/pom.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringfox/pom.mustache
@@ -33,7 +33,7 @@
{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}
- target/${project.artifactId}-${project.version}
+ target/${project.artifactId}-${project-version}
${project.basedir}/conf/jetty/webdefault.xml
8079
stopit
@@ -105,6 +105,45 @@
${jersey-version}
+
+
+ org.springframework
+ spring-core
+ ${spring-version}
+
+
+ org.springframework
+ spring-webmvc
+ ${spring-version}
+
+
+ org.springframework
+ spring-web
+ ${spring-version}
+
+
+
+
+ io.springfox
+ springfox-core
+ ${springfox-version}
+
+
+ io.springfox
+ springfox-spi
+ ${springfox-version}
+
+
+ io.springfox
+ springfox-spring-web
+ ${springfox-version}
+
+
+ io.springfox
+ springfox-swagger2
+ ${springfox-version}
+
+
org.scalatest
scalatest_2.9.1
@@ -125,11 +164,9 @@
- sonatype-snapshots
- https://oss.sonatype.org/content/repositories/snapshots
-
- true
-
+ jcenter-snapshots
+ jcenter
+ http://oss.jfrog.org/artifactory/oss-snapshot-local/
@@ -140,5 +177,7 @@
1.6.1
4.8.1
2.5
+ 2.0.0-SNAPSHOT
+ 4.0.9.RELEASE
\ No newline at end of file
diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringfox/queryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringfox/queryParams.mustache
index b9e80e5a7e7..2152d9f19ee 100644
--- a/modules/swagger-codegen/src/main/resources/JavaSpringfox/queryParams.mustache
+++ b/modules/swagger-codegen/src/main/resources/JavaSpringfox/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @QueryParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file