Skip to content

Commit aff3400

Browse files
committed
docs(client): update client-side adoption guides and README for generator cleanup
- Updated client-side adoption documentation with Spotless plugin integration and `.openapi-generator-ignore` rules for redundant DTO cleanup. - Revised customer-service-client README.md to include ignore patterns section. - Ensured consistency between client-side build setup and actual generator behavior.
1 parent 1a52f20 commit aff3400

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

customer-service-client/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,22 @@ try {
252252

253253
---
254254

255+
### 🧹 Ignoring Redundant Generated DTOs
256+
257+
The following patterns in [`.openapi-generator-ignore`](.openapi-generator-ignore) prevent redundant DTOs from being regenerated.
258+
These classes already exist in the shared `common` package and are excluded from code generation.
259+
260+
```bash
261+
# --- Custom additions for generated DTO cleanup ---
262+
**/src/gen/java/**/generated/dto/Page*.java
263+
**/src/gen/java/**/generated/dto/ServiceResponse.java
264+
**/src/gen/java/**/generated/dto/ServiceResponseVoid.java
265+
**/src/gen/java/**/generated/dto/Meta.java
266+
**/src/gen/java/**/generated/dto/Sort.java
267+
```
268+
269+
---
270+
255271
## 📚 Notes
256272

257273
* **Toolchain:** Java 21, Spring Boot 3.4.10, OpenAPI Generator 7.16.0

docs/adoption/client-side-adoption-pom.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ Define reusable properties to simplify plugin management and template resolution
7272
<openapi.generator.version>7.16.0</openapi.generator.version>
7373
<openapi.templates.upstream>${project.build.directory}/openapi-templates-upstream</openapi.templates.upstream>
7474
<openapi.templates.effective>${project.build.directory}/openapi-templates-effective</openapi.templates.effective>
75+
<build.helper.plugin.version>3.6.0</build.helper.plugin.version>
76+
<maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
77+
<maven.dependency.plugin.version>3.8.1</maven.dependency.plugin.version>
78+
<spotless-maven-plugin.version>3.0.0</spotless-maven-plugin.version>
7579
</properties>
7680
```
7781

@@ -195,8 +199,9 @@ These plugins work in sequence to **unpack, overlay, and compile** OpenAPI templ
195199
</configOptions>
196200

197201
<additionalProperties>
198-
<commonPackage>commonPackage=your.base.openapi.client.common</commonPackage>
202+
<additionalProperty>commonPackage=your.base.openapi.client.common</additionalProperty>
199203
</additionalProperties>
204+
<ignoreFileOverride>${project.basedir}/.openapi-generator-ignore</ignoreFileOverride>
200205
</configuration>
201206
</execution>
202207
</executions>
@@ -221,6 +226,35 @@ These plugins work in sequence to **unpack, overlay, and compile** OpenAPI templ
221226
</execution>
222227
</executions>
223228
</plugin>
229+
230+
<!-- 5️⃣ Clean up generated imports (Spotless) -->
231+
232+
<plugin>
233+
<groupId>com.diffplug.spotless</groupId>
234+
<artifactId>spotless-maven-plugin</artifactId>
235+
<version>${spotless-maven-plugin.version}</version>
236+
237+
<configuration>
238+
<java>
239+
<includes>
240+
<include>target/generated-sources/openapi/src/gen/java/**/*.java</include>
241+
</includes>
242+
<removeUnusedImports>
243+
<engine>cleanthat-javaparser-unnecessaryimport</engine>
244+
</removeUnusedImports>
245+
</java>
246+
</configuration>
247+
<executions>
248+
<execution>
249+
<id>spotless-apply-generated</id>
250+
<phase>process-sources</phase>
251+
<goals>
252+
<goal>apply</goal>
253+
</goals>
254+
</execution>
255+
</executions>
256+
</plugin>
257+
224258
</plugins>
225259
</build>
226260
```
@@ -235,6 +269,7 @@ These plugins work in sequence to **unpack, overlay, and compile** OpenAPI templ
235269
| **maven-resources-plugin** | Overlays your local Mustache templates on top of upstream ones. |
236270
| **openapi-generator-maven-plugin** | Generates type-safe client code using the effective templates. |
237271
| **build-helper-maven-plugin** | Ensures generated sources are included in the compilation phase. |
272+
| **spotless-maven-plugin** | Automatically removes unused imports and keeps generated sources clean. |
238273

239274
Together, these guarantee your **generics‑aware response wrappers** (e.g., `ServiceClientResponse<T>`) are generated
240275
cleanly and consistently across builds.

docs/adoption/client-side-adoption.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,34 @@ new `{ data, meta }` response structure and RFC 9457 `ProblemDetail` error model
6161

6262
---
6363

64+
### 🧹 Ignoring Redundant Generated DTOs
65+
66+
To prevent OpenAPI Generator from re-creating DTOs that already exist in the shared `common` package,
67+
add the following patterns to your `.openapi-generator-ignore` file.
68+
This avoids redundant model generation (e.g., `Page`, `Meta`, `Sort`, `ServiceResponse`) and keeps diffs minimal.
69+
70+
```bash
71+
# --- Custom additions for generated DTO cleanup ---
72+
**/src/gen/java/**/generated/dto/Page*.java
73+
**/src/gen/java/**/generated/dto/ServiceResponse.java
74+
**/src/gen/java/**/generated/dto/ServiceResponseVoid.java
75+
**/src/gen/java/**/generated/dto/Meta.java
76+
**/src/gen/java/**/generated/dto/Sort.java
77+
```
78+
79+
> **Note:**
80+
> The paths above assume your `openapi-generator-maven-plugin` uses
81+
> `sourceFolder=src/gen/java`.
82+
> If your configuration differs, adjust the directory prefix accordingly.
83+
>
84+
> Also make sure your POM specifies the file override:
85+
>
86+
> ```xml
87+
> <ignoreFileOverride>${project.basedir}/.openapi-generator-ignore</ignoreFileOverride>
88+
> ```
89+
90+
---
91+
6492
## 🧩 Core Classes (Shared Base)
6593
6694
Copy these into your client module under `openapi/client/common`:

0 commit comments

Comments
 (0)