From d155ddd026505a44ba2f4b8566d9649f4a0ac21f Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 9 Jun 2015 13:15:03 +0800 Subject: [PATCH] rollback java spring mvc template --- .../main/resources/JavaSpringMVC/api.mustache | 34 +- .../JavaSpringMVC/apiException.mustache | 10 +- .../JavaSpringMVC/apiOriginFilter.mustache | 30 +- .../JavaSpringMVC/apiResponseMessage.mustache | 108 ++--- .../JavaSpringMVC/formParams.mustache | 2 +- .../resources/JavaSpringMVC/model.mustache | 64 +-- .../JavaSpringMVC/notFoundException.mustache | 10 +- .../main/resources/JavaSpringMVC/pom.mustache | 453 +++++++++--------- .../JavaSpringMVC/swaggerConfig.mustache | 32 +- .../swaggerUiConfiguration.mustache | 58 +-- .../JavaSpringMVC/webApplication.mustache | 24 +- .../webMvcConfiguration.mustache | 8 +- 12 files changed, 415 insertions(+), 418 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache index 657aab0e36..d6a24b6931 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache @@ -31,23 +31,23 @@ import static org.springframework.http.MediaType.*; @RequestMapping(value = "/{{baseName}}", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/{{baseName}}", description = "the {{baseName}} API") {{#operations}} - public class {{classname}} { - {{#operation}} +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}} }) - @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 new ResponseEntity<{{returnType}}>(HttpStatus.OK); - } + @ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}) + @ApiResponses(value = { {{#responses}} + @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 new ResponseEntity<{{returnType}}>(HttpStatus.OK); + } - {{/operation}} - } + {{/operation}} +} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache index fbb96ab903..ffab3b1088 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache @@ -1,9 +1,9 @@ package {{apiPackage}}; public class ApiException extends Exception{ -private int code; -public ApiException (int code, String msg) { -super(msg); -this.code = code; -} + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } } diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache index 123a8734f9..68675432c6 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache @@ -6,21 +6,21 @@ import javax.servlet.*; import javax.servlet.http.HttpServletResponse; public class ApiOriginFilter implements javax.servlet.Filter { -@Override -public void doFilter(ServletRequest request, ServletResponse response, -FilterChain chain) throws IOException, ServletException { -HttpServletResponse res = (HttpServletResponse) response; -res.addHeader("Access-Control-Allow-Origin", "*"); -res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); -res.addHeader("Access-Control-Allow-Headers", "Content-Type"); -chain.doFilter(request, response); -} + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } -@Override -public void destroy() { -} + @Override + public void destroy() { + } -@Override -public void init(FilterConfig filterConfig) throws ServletException { -} + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache index d625431db4..94711b26ef 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache @@ -4,65 +4,65 @@ import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement public class ApiResponseMessage { -public static final int ERROR = 1; -public static final int WARNING = 2; -public static final int INFO = 3; -public static final int OK = 4; -public static final int TOO_BUSY = 5; + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; -int code; -String type; -String message; + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } -public ApiResponseMessage(){} + @XmlTransient + public int getCode() { + return code; + } -public ApiResponseMessage(int code, String message){ -this.code = code; -switch(code){ -case ERROR: -setType("error"); -break; -case WARNING: -setType("warning"); -break; -case INFO: -setType("info"); -break; -case OK: -setType("ok"); -break; -case TOO_BUSY: -setType("too busy"); -break; -default: -setType("unknown"); -break; -} -this.message = message; -} + public void setCode(int code) { + this.code = code; + } -@XmlTransient -public int getCode() { -return code; -} + public String getType() { + return type; + } -public void setCode(int code) { -this.code = code; -} + public void setType(String type) { + this.type = type; + } -public String getType() { -return type; -} + public String getMessage() { + return message; + } -public void setType(String type) { -this.type = type; -} - -public String getMessage() { -return message; -} - -public void setMessage(String message) { -this.message = message; -} + public void setMessage(String message) { + this.message = message; + } } diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/formParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/formParams.mustache index c2773bc5da..402a684f86 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/formParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/formParams.mustache @@ -1,2 +1,2 @@ {{#isFormParam}}{{#notFile}} - @ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestPart("file") MultipartFile fileDetail{{/isFile}}{{/isFormParam}} \ No newline at end of file +@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestPart(value="{{paramName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{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/JavaSpringMVC/model.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache index 7e0640585b..300d5e61dd 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache @@ -7,45 +7,45 @@ import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} - {{#model}}{{#description}} - /** - * {{description}} - **/{{/description}} - @ApiModel(description = "{{{description}}}") - public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { - {{#vars}}{{#isEnum}} - public enum {{datatypeWithEnum}} { - {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} - }; - private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}} - private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}} +{{#model}}{{#description}} +/** + * {{description}} + **/{{/description}} +@ApiModel(description = "{{{description}}}") +public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { + {{#vars}}{{#isEnum}} + public enum {{datatypeWithEnum}} { + {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} + }; + private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}} + private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}} - {{#vars}} - /**{{#description}} - * {{{description}}}{{/description}}{{#minimum}} - * minimum: {{minimum}}{{/minimum}}{{#maximum}} - * maximum: {{maximum}}{{/maximum}} - **/ - @ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") - @JsonProperty("{{name}}") - public {{{datatypeWithEnum}}} {{getter}}() { - return {{name}}; - } - public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - } + {{#vars}} + /**{{#description}} + * {{{description}}}{{/description}}{{#minimum}} + * minimum: {{minimum}}{{/minimum}}{{#maximum}} + * maximum: {{maximum}}{{/maximum}} + **/ + @ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") + @JsonProperty("{{name}}") + public {{{datatypeWithEnum}}} {{getter}}() { + return {{name}}; + } + public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { + this.{{name}} = {{name}}; + } - {{/vars}} + {{/vars}} - @Override - public String toString() { + @Override + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class {{classname}} {\n"); {{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}} {{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n"); {{/vars}}sb.append("}\n"); return sb.toString(); - } - } - {{/model}} + } +} +{{/model}} {{/models}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache index 499a1d1dcc..8ab2c99e4f 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache @@ -1,9 +1,9 @@ package {{apiPackage}}; public class NotFoundException extends ApiException { -private int code; -public NotFoundException (int code, String msg) { -super(code, msg); -this.code = code; -} + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } } diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache index a6fe9f9a29..3b068adffd 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache @@ -1,232 +1,229 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - src/main/java - - - org.apache.maven.plugins - maven-war-plugin - 2.1.1 - - - maven-failsafe-plugin - 2.6 - - - - integration-test - verify - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty-version} - - - {{^contextPath}} - /{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} - - target/${project.artifactId}-${project-version} - ${project.basedir}/conf/jetty/webdefault.xml - 8079 - stopit - - 8002 - 60000 - - - - - start-jetty - pre-integration-test - - start - - - 0 - true - - - - stop-jetty - post-integration-test - - stop - - - - - - 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 - - - - - - - - - - - - io.swagger - swagger-jersey-jaxrs - ${swagger-core-version} - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - - - com.sun.jersey - jersey-core - ${jersey-version} - - - com.sun.jersey - jersey-json - ${jersey-version} - - - com.sun.jersey - jersey-servlet - ${jersey-version} - - - com.sun.jersey.contribs - jersey-multipart - ${jersey-version} - - - com.sun.jersey - jersey-server - ${jersey-version} - + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + + src/main/java + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + maven-failsafe-plugin + 2.6 + + + + integration-test + verify + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty-version} + + + {{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} + + target/${project.artifactId}-${project-version} + ${project.basedir}/conf/jetty/webdefault.xml + 8079 + stopit + + 8002 + 60000 + + + + + start-jetty + pre-integration-test + + start + + + 0 + true + + + + stop-jetty + post-integration-test + + stop + + + + + + 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 + + + + + + + + + + + + io.swagger + swagger-jersey-jaxrs + ${swagger-core-version} + + + org.slf4j + slf4j-log4j12 + ${slf4j-version} + + + com.sun.jersey + jersey-core + ${jersey-version} + + + com.sun.jersey + jersey-json + ${jersey-version} + + + com.sun.jersey + jersey-servlet + ${jersey-version} + + + com.sun.jersey.contribs + jersey-multipart + ${jersey-version} + + + com.sun.jersey + jersey-server + ${jersey-version} + - - - org.springframework - spring-core - ${spring-version} - - - org.springframework - spring-webmvc - ${spring-version} - - - org.springframework - spring-web - ${spring-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} - - - io.springfox - springfox-swagger-ui - ${springfox-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} + + + io.springfox + springfox-swagger-ui + ${springfox-version} + - - org.scalatest - scalatest_2.9.1 - ${scala-test-version} - test - - - junit - junit - ${junit-version} - test - - - javax.servlet - servlet-api - ${servlet-api-version} - - - - - jcenter-snapshots - jcenter - http://oss.jfrog.org/artifactory/oss-snapshot-local/ - - - - 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 - 4.0.9.RELEASE - + + org.scalatest + scalatest_2.9.1 + ${scala-test-version} + test + + + junit + junit + ${junit-version} + test + + + javax.servlet + servlet-api + ${servlet-api-version} + + + + + jcenter-snapshots + jcenter + http://oss.jfrog.org/artifactory/oss-snapshot-local/ + + + + 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 + 4.0.9.RELEASE + \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache index 9542585a69..b33ee7fc99 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache @@ -19,22 +19,22 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) public class SwaggerConfig { -@Bean -ApiInfo apiInfo() { -ApiInfo apiInfo = new ApiInfo( -"{{appName}}", -"{{{appDescription}}}", -"{{appVersion}}", -"{{infoUrl}}", -"{{infoEmail}}", -"{{licenseInfo}}", -"{{licenseUrl}}" ); -return apiInfo; -} + @Bean + ApiInfo apiInfo() { + ApiInfo apiInfo = new ApiInfo( + "{{appName}}", + "{{{appDescription}}}", + "{{appVersion}}", + "{{infoUrl}}", + "{{infoEmail}}", + "{{licenseInfo}}", + "{{licenseUrl}}" ); + return apiInfo; + } -@Bean -public Docket customImplementation(){ -return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()); -} + @Bean + public Docket customImplementation(){ + return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()); + } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache index 78b0705f6c..652dc31035 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache @@ -9,38 +9,38 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { -private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; + private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; -private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { -"classpath:/META-INF/resources/", "classpath:/resources/", -"classpath:/static/", "classpath:/public/" }; + private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { + "classpath:/META-INF/resources/", "classpath:/resources/", + "classpath:/static/", "classpath:/public/" }; -private static final String[] RESOURCE_LOCATIONS; -static { -RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length -+ SERVLET_RESOURCE_LOCATIONS.length]; -System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0, -SERVLET_RESOURCE_LOCATIONS.length); -System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, -SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length); -} + private static final String[] RESOURCE_LOCATIONS; + static { + RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length + + SERVLET_RESOURCE_LOCATIONS.length]; + System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0, + SERVLET_RESOURCE_LOCATIONS.length); + System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, + SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length); + } -private static final String[] STATIC_INDEX_HTML_RESOURCES; -static { -STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length]; -for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) { -STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html"; -} -} + private static final String[] STATIC_INDEX_HTML_RESOURCES; + static { + STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length]; + for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) { + STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html"; + } + } -@Override -public void addResourceHandlers(ResourceHandlerRegistry registry) { -if (!registry.hasMappingForPattern("/webjars/**")) { -registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); -} -if (!registry.hasMappingForPattern("/**")) { -registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); -} -} + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + if (!registry.hasMappingForPattern("/webjars/**")) { + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + } + if (!registry.hasMappingForPattern("/**")) { + registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); + } + } } diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache index 1a2c1bb094..6910ad11b7 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache @@ -4,18 +4,18 @@ import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatche public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { -@Override -protected Class[] getRootConfigClasses() { -return new Class[] { SwaggerConfig.class }; -} + @Override + protected Class[] getRootConfigClasses() { + return new Class[] { SwaggerConfig.class }; + } -@Override -protected Class[] getServletConfigClasses() { -return new Class[] { WebMvcConfiguration.class }; -} + @Override + protected Class[] getServletConfigClasses() { + return new Class[] { WebMvcConfiguration.class }; + } -@Override -protected String[] getServletMappings() { -return new String[] { "/" }; -} + @Override + protected String[] getServletMappings() { + return new String[] { "/" }; + } } diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache index 67ec632ab8..03904e51e7 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache @@ -4,8 +4,8 @@ import org.springframework.web.servlet.config.annotation.DefaultServletHandlerCo import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; public class WebMvcConfiguration extends WebMvcConfigurationSupport { -@Override -public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { -configurer.enable(); -} + @Override + public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { + configurer.enable(); + } }