Skip to content

Commit f6d78f7

Browse files
committed
Add example of OpenApi generation for Spring Boot app
1 parent 9c19751 commit f6d78f7

File tree

3 files changed

+150
-2
lines changed

3 files changed

+150
-2
lines changed

openapi-generator-sample/openapi-generator/pom.xml openapi-generator-sample/openapi-generator-java/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<version>1.0-SNAPSHOT</version>
1010
</parent>
1111

12-
<artifactId>openapi-generator</artifactId>
12+
<artifactId>openapi-generator-java</artifactId>
1313

1414
<properties>
1515
<swagger-annotations-version>1.5.8</swagger-annotations-version>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>by.andd3dfx</groupId>
8+
<artifactId>openapi-generator-sample</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>openapi-generator-spring</artifactId>
13+
14+
<properties>
15+
<springfox.version>2.9.2</springfox.version>
16+
<swagger-ui.version>4.15.5</swagger-ui.version>
17+
</properties>
18+
19+
<build>
20+
<plugins>
21+
<!-- activate the plugin -->
22+
<plugin>
23+
<groupId>org.openapitools</groupId>
24+
<artifactId>openapi-generator-maven-plugin</artifactId>
25+
<version>7.6.0</version>
26+
<dependencies>
27+
<dependency>
28+
<groupId>${project.groupId}</groupId>
29+
<artifactId>openapi-contract</artifactId>
30+
<version>1.0-SNAPSHOT</version>
31+
</dependency>
32+
</dependencies>
33+
<executions>
34+
<execution>
35+
<id>spring-server</id>
36+
<goals>
37+
<goal>generate</goal>
38+
</goals>
39+
<configuration>
40+
<!-- specify the OpenAPI spec -->
41+
<inputSpec>openapi.yaml</inputSpec>
42+
43+
<!-- target to generate java server code -->
44+
<generatorName>spring</generatorName>
45+
46+
<!-- hint: if you want to generate java client code
47+
you can use the following generator: <generatorName>java</generatorName> -->
48+
49+
<!-- pass any necessary config options -->
50+
<configOptions>
51+
<documentationProvider>springfox</documentationProvider>
52+
<serializableModel>true</serializableModel>
53+
<snapshotVersion>true</snapshotVersion>
54+
</configOptions>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-compiler-plugin</artifactId>
62+
<version>${maven-compiler-plugin.version}</version>
63+
<configuration>
64+
<source>${java.version}</source>
65+
<target>${java.version}</target>
66+
<proc>none</proc>
67+
</configuration>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
72+
<dependencyManagement>
73+
<dependencies>
74+
<dependency>
75+
<!-- Import dependency management from Spring Boot -->
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-dependencies</artifactId>
78+
<version>2.7.18</version>
79+
<type>pom</type>
80+
<scope>import</scope>
81+
</dependency>
82+
</dependencies>
83+
</dependencyManagement>
84+
85+
<dependencies>
86+
<dependency>
87+
<groupId>org.springframework.boot</groupId>
88+
<artifactId>spring-boot-starter-web</artifactId>
89+
</dependency>
90+
<dependency>
91+
<groupId>org.springframework.data</groupId>
92+
<artifactId>spring-data-commons</artifactId>
93+
</dependency>
94+
95+
<!--SpringFox dependencies -->
96+
<dependency>
97+
<groupId>io.springfox</groupId>
98+
<artifactId>springfox-swagger2</artifactId>
99+
<version>${springfox.version}</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.webjars</groupId>
103+
<artifactId>swagger-ui</artifactId>
104+
<version>${swagger-ui.version}</version>
105+
</dependency>
106+
<dependency>
107+
<groupId>org.webjars</groupId>
108+
<artifactId>webjars-locator-core</artifactId>
109+
</dependency>
110+
111+
<!-- @Nullable annotation -->
112+
<dependency>
113+
<groupId>com.google.code.findbugs</groupId>
114+
<artifactId>jsr305</artifactId>
115+
<version>3.0.2</version>
116+
</dependency>
117+
<dependency>
118+
<groupId>com.fasterxml.jackson.dataformat</groupId>
119+
<artifactId>jackson-dataformat-yaml</artifactId>
120+
</dependency>
121+
<dependency>
122+
<groupId>com.fasterxml.jackson.datatype</groupId>
123+
<artifactId>jackson-datatype-jsr310</artifactId>
124+
</dependency>
125+
<dependency>
126+
<groupId>org.openapitools</groupId>
127+
<artifactId>jackson-databind-nullable</artifactId>
128+
<version>0.2.6</version>
129+
</dependency>
130+
131+
<!-- Bean Validation API support -->
132+
<dependency>
133+
<groupId>org.springframework.boot</groupId>
134+
<artifactId>spring-boot-starter-validation</artifactId>
135+
</dependency>
136+
<dependency>
137+
<groupId>com.fasterxml.jackson.core</groupId>
138+
<artifactId>jackson-databind</artifactId>
139+
</dependency>
140+
<dependency>
141+
<groupId>org.springframework.boot</groupId>
142+
<artifactId>spring-boot-starter-test</artifactId>
143+
<scope>test</scope>
144+
</dependency>
145+
</dependencies>
146+
147+
</project>

openapi-generator-sample/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<modules>
1616
<module>openapi-contract</module>
17-
<module>openapi-generator</module>
17+
<module>openapi-generator-java</module>
18+
<module>openapi-generator-spring</module>
1819
</modules>
1920
</project>

0 commit comments

Comments
 (0)