Skip to content

Commit 1062fa4

Browse files
committed
fix issues
1 parent ec6a925 commit 1062fa4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1079
-1799
lines changed

bin/spring-mvc-petstore-j8-async-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringMVC -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring --library spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,java8=true,async=true"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringBoot -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring --library spring-mvc -o samples/server/petstore/spring-mvc-j8-async -c bin/spring-mvc-petstore-j8-async.json -DhideGenerationTimestamp=true,java8=true,async=true"
3030

3131
java $JAVA_OPTS -jar $executable $ags

bin/spring-stubs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l springboot -o samples/client/petstore/spring-stubs -DinterfaceOnly=true,singleContentTypes=true"
29+
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring -o samples/client/petstore/spring-stubs -DinterfaceOnly=true,singleContentTypes=true,hideGenerationTimestamp=true"
3030

3131
java $JAVA_OPTS -jar $executable $ags

bin/springboot-petstore-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringBoot -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring --library=spring-boot -o samples/server/petstore/springboot -DhideGenerationTimestamp=true"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringBoot -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring -o samples/server/petstore/springboot -DhideGenerationTimestamp=true"
3030

3131
echo "Removing files and folders under samples/server/petstore/springboot/src/main"
3232
rm -rf samples/server/petstore/springboot/src/main

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public SpringBootServerCodegen() {
4747

4848
supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
4949
supportedLibraries.put("spring-mvc", "Spring-MVC Server application using the SpringFox integration.");
50+
setLibrary(DEFAULT_LIBRARY);
5051

5152
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
5253
library.setDefault(DEFAULT_LIBRARY);
@@ -127,7 +128,7 @@ public void processOpts() {
127128
supportingFiles.add(new SupportingFile("application.properties",
128129
("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
129130
}
130-
if (library.equals("mvc")) {
131+
if (library.equals("spring-mvc")) {
131132
supportingFiles.add(new SupportingFile("webApplication.mustache",
132133
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebApplication.java"));
133134
supportingFiles.add(new SupportingFile("webMvcConfiguration.mustache",
Lines changed: 142 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,147 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2-
<modelVersion>4.0.0</modelVersion>
3-
<groupId>{{groupId}}</groupId>
4-
<artifactId>{{artifactId}}</artifactId>
5-
<packaging>jar</packaging>
6-
<name>{{artifactId}}</name>
7-
<version>{{artifactVersion}}</version>
8-
<build>
9-
<sourceDirectory>src/main/java</sourceDirectory>
10-
<plugins>
11-
<plugin>
12-
<groupId>org.apache.maven.plugins</groupId>
13-
<artifactId>maven-war-plugin</artifactId>
14-
<version>2.6</version>
15-
</plugin>
16-
<plugin>
17-
<artifactId>maven-failsafe-plugin</artifactId>
18-
<version>2.6</version>
19-
<executions>
20-
<execution>
21-
<goals>
22-
<goal>integration-test</goal>
23-
<goal>verify</goal>
24-
</goals>
25-
</execution>
26-
</executions>
27-
</plugin>
28-
<plugin>
29-
<groupId>org.eclipse.jetty</groupId>
30-
<artifactId>jetty-maven-plugin</artifactId>
31-
<version>${jetty-version}</version>
32-
<configuration>
33-
<webAppConfig>
34-
<contextPath>{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}</contextPath>
35-
</webAppConfig>
36-
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
37-
<stopPort>8079</stopPort>
38-
<stopKey>stopit</stopKey>
39-
<httpConnector>
40-
<port>8002</port>
41-
<idleTimeout>60000</idleTimeout>
42-
</httpConnector>
43-
</configuration>
44-
<executions>
45-
<execution>
46-
<id>start-jetty</id>
47-
<phase>pre-integration-test</phase>
48-
<goals>
49-
<goal>start</goal>
50-
</goals>
51-
<configuration>
52-
<scanIntervalSeconds>0</scanIntervalSeconds>
53-
<daemon>true</daemon>
54-
</configuration>
55-
</execution>
56-
<execution>
57-
<id>stop-jetty</id>
58-
<phase>post-integration-test</phase>
59-
<goals>
60-
<goal>stop</goal>
61-
</goals>
62-
</execution>
63-
</executions>
64-
</plugin>
65-
</plugins>
66-
</build>
67-
<dependencies>
68-
<dependency>
69-
<groupId>io.swagger</groupId>
70-
<artifactId>swagger-jersey-jaxrs</artifactId>
71-
<version>${swagger-core-version}</version>
72-
</dependency>
73-
<dependency>
74-
<groupId>org.slf4j</groupId>
75-
<artifactId>slf4j-log4j12</artifactId>
76-
<version>${slf4j-version}</version>
77-
</dependency>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>{{groupId}}</groupId>
4+
<artifactId>{{artifactId}}</artifactId>
5+
<packaging>jar</packaging>
6+
<name>{{artifactId}}</name>
7+
<version>{{artifactVersion}}</version>
8+
<build>
9+
<sourceDirectory>src/main/java</sourceDirectory>
10+
<plugins>
11+
<plugin>
12+
<groupId>org.apache.maven.plugins</groupId>
13+
<artifactId>maven-war-plugin</artifactId>
14+
<version>2.6</version>
15+
</plugin>
16+
<plugin>
17+
<artifactId>maven-failsafe-plugin</artifactId>
18+
<version>2.6</version>
19+
<executions>
20+
<execution>
21+
<goals>
22+
<goal>integration-test</goal>
23+
<goal>verify</goal>
24+
</goals>
25+
</execution>
26+
</executions>
27+
</plugin>
28+
<plugin>
29+
<groupId>org.eclipse.jetty</groupId>
30+
<artifactId>jetty-maven-plugin</artifactId>
31+
<version>${jetty-version}</version>
32+
<configuration>
33+
<webAppConfig>
34+
<contextPath>{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}</contextPath>
35+
</webAppConfig>
36+
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
37+
<stopPort>8079</stopPort>
38+
<stopKey>stopit</stopKey>
39+
<httpConnector>
40+
<port>8002</port>
41+
<idleTimeout>60000</idleTimeout>
42+
</httpConnector>
43+
</configuration>
44+
<executions>
45+
<execution>
46+
<id>start-jetty</id>
47+
<phase>pre-integration-test</phase>
48+
<goals>
49+
<goal>start</goal>
50+
</goals>
51+
<configuration>
52+
<scanIntervalSeconds>0</scanIntervalSeconds>
53+
<daemon>true</daemon>
54+
</configuration>
55+
</execution>
56+
<execution>
57+
<id>stop-jetty</id>
58+
<phase>post-integration-test</phase>
59+
<goals>
60+
<goal>stop</goal>
61+
</goals>
62+
</execution>
63+
</executions>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
<dependencies>
68+
<dependency>
69+
<groupId>org.slf4j</groupId>
70+
<artifactId>slf4j-log4j12</artifactId>
71+
<version>${slf4j-version}</version>
72+
</dependency>
7873

79-
<!--Spring dependencies -->
80-
<dependency>
81-
<groupId>org.springframework</groupId>
82-
<artifactId>spring-core</artifactId>
83-
<version>${spring-version}</version>
84-
</dependency>
85-
<dependency>
86-
<groupId>org.springframework</groupId>
87-
<artifactId>spring-webmvc</artifactId>
88-
<version>${spring-version}</version>
89-
</dependency>
90-
<dependency>
91-
<groupId>org.springframework</groupId>
92-
<artifactId>spring-web</artifactId>
93-
<version>${spring-version}</version>
94-
</dependency>
74+
<!--Spring dependencies -->
75+
<dependency>
76+
<groupId>org.springframework</groupId>
77+
<artifactId>spring-core</artifactId>
78+
<version>${spring-version}</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.springframework</groupId>
82+
<artifactId>spring-webmvc</artifactId>
83+
<version>${spring-version}</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.springframework</groupId>
87+
<artifactId>spring-web</artifactId>
88+
<version>${spring-version}</version>
89+
</dependency>
9590

96-
<!--SpringFox dependencies-->
97-
<dependency>
98-
<groupId>io.springfox</groupId>
99-
<artifactId>springfox-swagger2</artifactId>
100-
<version>${springfox-version}</version>
101-
</dependency>
102-
<dependency>
103-
<groupId>io.springfox</groupId>
104-
<artifactId>springfox-swagger-ui</artifactId>
105-
<version>${springfox-version}</version>
106-
</dependency>
91+
<!--SpringFox dependencies-->
92+
<dependency>
93+
<groupId>io.springfox</groupId>
94+
<artifactId>springfox-swagger2</artifactId>
95+
<version>${springfox-version}</version>
96+
</dependency>
97+
<dependency>
98+
<groupId>io.springfox</groupId>
99+
<artifactId>springfox-swagger-ui</artifactId>
100+
<version>${springfox-version}</version>
101+
</dependency>
107102

108-
<dependency>
109-
<groupId>junit</groupId>
110-
<artifactId>junit</artifactId>
111-
<version>${junit-version}</version>
112-
<scope>test</scope>
113-
</dependency>
114-
<dependency>
115-
<groupId>javax.servlet</groupId>
116-
<artifactId>servlet-api</artifactId>
117-
<version>${servlet-api-version}</version>
118-
</dependency>
119-
</dependencies>
120-
<properties>
121-
<swagger-core-version>1.5.8</swagger-core-version>
122-
<jetty-version>9.2.15.v20160210</jetty-version>
123-
<jersey-version>1.13</jersey-version>
124-
<slf4j-version>1.7.21</slf4j-version>
125-
<junit-version>4.12</junit-version>
126-
<servlet-api-version>2.5</servlet-api-version>
127-
<springfox-version>2.4.0</springfox-version>
128-
<spring-version>4.2.5.RELEASE</spring-version>
129-
</properties>
103+
{{#java8}}
104+
<dependency>
105+
<groupId>com.fasterxml.jackson.datatype</groupId>
106+
<artifactId>jackson-datatype-jsr310</artifactId>
107+
<version>${jackson-version}</version>
108+
</dependency>
109+
{{/java8}}
110+
{{^java8}}
111+
<dependency>
112+
<groupId>com.fasterxml.jackson.datatype</groupId>
113+
<artifactId>jackson-datatype-joda</artifactId>
114+
<version>${jackson-version}</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>joda-time</groupId>
118+
<artifactId>joda-time</artifactId>
119+
<version>2.9.4</version>
120+
</dependency>
121+
{{/java8}}
122+
123+
<dependency>
124+
<groupId>junit</groupId>
125+
<artifactId>junit</artifactId>
126+
<version>${junit-version}</version>
127+
<scope>test</scope>
128+
</dependency>
129+
<dependency>
130+
<groupId>javax.servlet</groupId>
131+
<artifactId>servlet-api</artifactId>
132+
<version>${servlet-api-version}</version>
133+
</dependency>
134+
</dependencies>
135+
<properties>
136+
<java.version>{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}</java.version>
137+
<maven.compiler.source>${java.version}</maven.compiler.source>
138+
<maven.compiler.target>${java.version}</maven.compiler.target>
139+
<jetty-version>9.2.15.v20160210</jetty-version>
140+
<slf4j-version>1.7.21</slf4j-version>
141+
<junit-version>4.12</junit-version>
142+
<servlet-api-version>2.5</servlet-api-version>
143+
<springfox-version>2.4.0</springfox-version>
144+
<jackson-version>2.4.5</jackson-version>
145+
<spring-version>4.2.5.RELEASE</spring-version>
146+
</properties>
130147
</project>

modules/swagger-codegen/src/main/resources/JavaSpringBoot/libraries/spring-mvc/swaggerUiConfiguration.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package {{configPackage}};
22

3+
import org.springframework.context.annotation.ComponentScan;
34
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.annotation.PropertySource;
6+
import org.springframework.context.annotation.Import;
47
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
58
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
69
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
10+
import springfox.documentation.swagger2.annotations.EnableSwagger2;
711

812
{{>generatedAnnotation}}
913
@Configuration

modules/swagger-codegen/src/main/resources/JavaSpringBoot/swaggerDocumentationConfig.mustache

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ public class SwaggerDocumentationConfig {
3131
return new Docket(DocumentationType.SWAGGER_2)
3232
.select()
3333
.apis(RequestHandlerSelectors.basePackage("{{apiPackage}}"))
34-
.build(){{#java8}}
34+
.build()
35+
{{#java8}}
3536
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
36-
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class){{/java8}}{{^java8}}
37+
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
38+
{{/java8}}
39+
{{^java8}}
3740
.directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
38-
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class){{/java8}}
41+
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
42+
{{/java8}}
3943
.apiInfo(apiInfo());
4044
}
4145

0 commit comments

Comments
 (0)