@@ -18,6 +18,7 @@ project.
1818Add these dependencies to your client module:
1919
2020``` xml
21+
2122<dependencies >
2223 <!-- Spring Boot (provided by host application) -->
2324 <dependency >
@@ -81,131 +82,146 @@ These plugins **work together** to unpack upstream templates, overlay your custo
8182client code.
8283
8384``` xml
85+
8486<build >
85- <plugins >
86- <!-- Unpack upstream OpenAPI templates -->
87- <plugin >
88- <groupId >org.apache.maven.plugins</groupId >
89- <artifactId >maven-dependency-plugin</artifactId >
90- <executions >
91- <execution >
92- <id >unpack-openapi-upstream-templates</id >
93- <phase >generate-sources</phase >
94- <goals ><goal >unpack</goal ></goals >
95- <configuration >
96- <artifactItems >
97- <artifactItem >
98- <groupId >org.openapitools</groupId >
99- <artifactId >openapi-generator</artifactId >
100- <version >${openapi.generator.version}</version >
101- <type >jar</type >
102- <includes >templates/Java/**</includes >
103- <outputDirectory >${openapi.templates.upstream}</outputDirectory >
104- </artifactItem >
105- </artifactItems >
106- </configuration >
107- </execution >
108- </executions >
109- </plugin >
110-
111- <!-- Overlay local Mustache templates on top of upstream -->
112- <plugin >
113- <groupId >org.apache.maven.plugins</groupId >
114- <artifactId >maven-resources-plugin</artifactId >
115- <executions >
116- <execution >
117- <id >copy-upstream-to-effective</id >
118- <phase >generate-sources</phase >
119- <goals ><goal >copy-resources</goal ></goals >
120- <configuration >
121- <outputDirectory >${openapi.templates.effective}</outputDirectory >
122- <resources >
123- <resource >
124- <directory >${openapi.templates.upstream}/templates</directory >
125- <includes ><include >Java/**</include ></includes >
126- </resource >
127- </resources >
128- </configuration >
129- </execution >
130- <execution >
131- <id >overlay-local-templates</id >
132- <phase >generate-sources</phase >
133- <goals ><goal >copy-resources</goal ></goals >
134- <configuration >
135- <outputDirectory >${openapi.templates.effective}/Java</outputDirectory >
136- <overwrite >true</overwrite >
137- <resources >
138- <resource >
139- <directory >src/main/resources/openapi-templates</directory >
140- <includes ><include >**/*.mustache</include ></includes >
141- </resource >
142- </resources >
143- </configuration >
144- </execution >
145- </executions >
146- </plugin >
147-
148- <!-- Generate OpenAPI client code -->
149- <plugin >
150- <groupId >org.openapitools</groupId >
151- <artifactId >openapi-generator-maven-plugin</artifactId >
152- <version >${openapi.generator.version}</version >
153- <executions >
154- <execution >
155- <id >generate-client</id >
156- <phase >generate-sources</phase >
157- <goals ><goal >generate</goal ></goals >
158- <configuration >
159- <inputSpec >${project.basedir}/src/main/resources/your-api-docs.yaml</inputSpec >
160- <generatorName >java</generatorName >
161- <library >restclient</library >
162- <output >${project.build.directory}/generated-sources/openapi</output >
163-
164- <apiPackage >your.base.openapi.client.generated.api</apiPackage >
165- <modelPackage >your.base.openapi.client.generated.dto</modelPackage >
166- <invokerPackage >your.base.openapi.client.generated.invoker</invokerPackage >
167-
168- <templateDirectory >${openapi.templates.effective}/Java</templateDirectory >
169- <generateSupportingFiles >true</generateSupportingFiles >
170- <generateApiTests >false</generateApiTests >
171- <generateModelTests >false</generateModelTests >
172-
173- <configOptions >
174- <useSpringBoot3 >true</useSpringBoot3 >
175- <useJakartaEe >true</useJakartaEe >
176- <serializationLibrary >jackson</serializationLibrary >
177- <dateLibrary >java8</dateLibrary >
178- <useBeanValidation >true</useBeanValidation >
179- <openApiNullable >false</openApiNullable >
180- <sourceFolder >src/gen/java</sourceFolder >
181- </configOptions >
182-
183- <additionalProperties >
184- <additionalProperty >commonPackage=your.base.openapi.client.common</additionalProperty >
185- </additionalProperties >
186- </configuration >
187- </execution >
188- </executions >
189- </plugin >
190-
191- <!-- Add generated sources to compilation -->
192- <plugin >
193- <groupId >org.codehaus.mojo</groupId >
194- <artifactId >build-helper-maven-plugin</artifactId >
195- <executions >
196- <execution >
197- <id >add-generated-sources</id >
198- <phase >generate-sources</phase >
199- <goals ><goal >add-source</goal ></goals >
200- <configuration >
201- <sources >
202- <source >${project.build.directory}/generated-sources/openapi/src/gen/java</source >
203- </sources >
204- </configuration >
205- </execution >
206- </executions >
207- </plugin >
208- </plugins >
87+ <plugins >
88+ <!-- Unpack upstream OpenAPI templates -->
89+ <plugin >
90+ <groupId >org.apache.maven.plugins</groupId >
91+ <artifactId >maven-dependency-plugin</artifactId >
92+ <executions >
93+ <execution >
94+ <id >unpack-openapi-upstream-templates</id >
95+ <phase >generate-sources</phase >
96+ <goals >
97+ <goal >unpack</goal >
98+ </goals >
99+ <configuration >
100+ <artifactItems >
101+ <artifactItem >
102+ <groupId >org.openapitools</groupId >
103+ <artifactId >openapi-generator</artifactId >
104+ <version >${openapi.generator.version}</version >
105+ <type >jar</type >
106+ <includes >templates/Java/**</includes >
107+ <outputDirectory >${openapi.templates.upstream}</outputDirectory >
108+ </artifactItem >
109+ </artifactItems >
110+ </configuration >
111+ </execution >
112+ </executions >
113+ </plugin >
114+
115+ <!-- Overlay local Mustache templates on top of upstream -->
116+ <plugin >
117+ <groupId >org.apache.maven.plugins</groupId >
118+ <artifactId >maven-resources-plugin</artifactId >
119+ <executions >
120+ <execution >
121+ <id >copy-upstream-to-effective</id >
122+ <phase >generate-sources</phase >
123+ <goals >
124+ <goal >copy-resources</goal >
125+ </goals >
126+ <configuration >
127+ <outputDirectory >${openapi.templates.effective}</outputDirectory >
128+ <resources >
129+ <resource >
130+ <directory >${openapi.templates.upstream}/templates</directory >
131+ <includes >
132+ <include >Java/**</include >
133+ </includes >
134+ </resource >
135+ </resources >
136+ </configuration >
137+ </execution >
138+ <execution >
139+ <id >overlay-local-templates</id >
140+ <phase >generate-sources</phase >
141+ <goals >
142+ <goal >copy-resources</goal >
143+ </goals >
144+ <configuration >
145+ <outputDirectory >${openapi.templates.effective}/Java</outputDirectory >
146+ <overwrite >true</overwrite >
147+ <resources >
148+ <resource >
149+ <directory >src/main/resources/openapi-templates</directory >
150+ <includes >
151+ <include >**/*.mustache</include >
152+ </includes >
153+ </resource >
154+ </resources >
155+ </configuration >
156+ </execution >
157+ </executions >
158+ </plugin >
159+
160+ <!-- Generate OpenAPI client code -->
161+ <plugin >
162+ <groupId >org.openapitools</groupId >
163+ <artifactId >openapi-generator-maven-plugin</artifactId >
164+ <version >${openapi.generator.version}</version >
165+ <executions >
166+ <execution >
167+ <id >generate-client</id >
168+ <phase >generate-sources</phase >
169+ <goals >
170+ <goal >generate</goal >
171+ </goals >
172+ <configuration >
173+ <inputSpec >${project.basedir}/src/main/resources/your-api-docs.yaml</inputSpec >
174+ <generatorName >java</generatorName >
175+ <library >restclient</library >
176+ <output >${project.build.directory}/generated-sources/openapi</output >
177+
178+ <apiPackage >your.base.openapi.client.generated.api</apiPackage >
179+ <modelPackage >your.base.openapi.client.generated.dto</modelPackage >
180+ <invokerPackage >your.base.openapi.client.generated.invoker</invokerPackage >
181+
182+ <templateDirectory >${openapi.templates.effective}/Java</templateDirectory >
183+ <generateSupportingFiles >true</generateSupportingFiles >
184+ <generateApiTests >false</generateApiTests >
185+ <generateModelTests >false</generateModelTests >
186+
187+ <configOptions >
188+ <useSpringBoot3 >true</useSpringBoot3 >
189+ <useJakartaEe >true</useJakartaEe >
190+ <serializationLibrary >jackson</serializationLibrary >
191+ <dateLibrary >java8</dateLibrary >
192+ <useBeanValidation >true</useBeanValidation >
193+ <openApiNullable >false</openApiNullable >
194+ <sourceFolder >src/gen/java</sourceFolder >
195+ </configOptions >
196+
197+ <additionalProperties >
198+ <additionalProperty >commonPackage=your.base.openapi.client.common</additionalProperty >
199+ </additionalProperties >
200+ </configuration >
201+ </execution >
202+ </executions >
203+ </plugin >
204+
205+ <!-- Add generated sources to compilation -->
206+ <plugin >
207+ <groupId >org.codehaus.mojo</groupId >
208+ <artifactId >build-helper-maven-plugin</artifactId >
209+ <executions >
210+ <execution >
211+ <id >add-generated-sources</id >
212+ <phase >generate-sources</phase >
213+ <goals >
214+ <goal >add-source</goal >
215+ </goals >
216+ <configuration >
217+ <sources >
218+ <source >${project.build.directory}/generated-sources/openapi/src/gen/java</source >
219+ </sources >
220+ </configuration >
221+ </execution >
222+ </executions >
223+ </plugin >
224+ </plugins >
209225</build >
210226```
211227
0 commit comments