You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-17Lines changed: 46 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,11 @@
16
16
<em>End-to-end generics-aware OpenAPI clients — unified <code>{ data, meta }</code> responses without boilerplate.</em>
17
17
</p>
18
18
19
-
**Modern, type-safe OpenAPI client generation** — powered by **Spring Boot 3.4**, **Java 21**, and **OpenAPI Generator 7.16.0**.
20
-
This repository demonstrates a production-grade architecture where backend and client are fully aligned through generics, enabling nested generic envelopes (ServiceResponse<Page<T>>) and RFC 7807 ProblemDetail (Problem Details for HTTP APIs)–based error handling.
19
+
**Modern, type-safe OpenAPI client generation** — powered by **Spring Boot 3.4**, **Java 21**, and **OpenAPI Generator
20
+
7.16.0**.
21
+
This repository demonstrates a production-grade architecture where backend and client are fully aligned through
22
+
generics, enabling nested generic envelopes (ServiceResponse<Page<T>>) and RFC 7807 ProblemDetail (Problem Details for
23
+
HTTP APIs)–based error handling.
21
24
22
25
---
23
26
@@ -36,14 +39,16 @@ This repository demonstrates a production-grade architecture where backend and c
36
39
* 📘 [Adoption Guides](#-adoption-guides)
37
40
* 🔗 [References & Links](#-references--links)
38
41
39
-
> *A clean architecture pattern for building generics-aware OpenAPI clients that stay fully type-safe, consistent, and boilerplate-free.*
42
+
> *A clean architecture pattern for building generics-aware OpenAPI clients that stay fully type-safe, consistent, and
43
+
boilerplate-free.*
40
44
41
45
---
42
46
43
47
## 📦 Modules
44
48
45
49
*[**customer-service**](customer-service/README.md) — sample backend exposing `/v3/api-docs.yaml` via Springdoc
46
-
*[**customer-service-client**](customer-service-client/README.md) — generated OpenAPI client with generics-aware wrappers
50
+
*[**customer-service-client**](customer-service-client/README.md) — generated OpenAPI client with generics-aware
51
+
wrappers
47
52
48
53
---
49
54
@@ -54,6 +59,7 @@ When backend APIs wrap payloads in `ServiceResponse<T>` (e.g., the unified `{ da
54
59
the generator produces **duplicated models per endpoint** instead of a single reusable generic base.
55
60
56
61
This results in:
62
+
57
63
* ❌ Dozens of almost-identical response classes
58
64
* ❌ Higher maintenance overhead
59
65
* ❌ Harder to evolve a single envelope contract across services
@@ -66,7 +72,8 @@ This project provides a **full-stack pattern** to align Spring Boot services and
66
72
67
73
### Server-Side (Producer)
68
74
69
-
A `Springdoc` customizer automatically scans controller return types and marks generic wrappers (`ServiceResponse<T>`) using vendor extensions:
75
+
A `Springdoc` customizer automatically scans controller return types and marks generic wrappers (`ServiceResponse<T>`)
76
+
using vendor extensions:
70
77
71
78
```yaml
72
79
x-api-wrapper: true
@@ -77,15 +84,18 @@ x-data-item: CustomerDto
77
84
78
85
### Client-Side (Consumer)
79
86
80
-
Mustache overlays redefine OpenAPI templates to generate **thin, type-safe wrappers** extending a reusable base class `ServiceClientResponse<T>`.
87
+
Mustache overlays redefine OpenAPI templates to generate **thin, type-safe wrappers** extending a reusable base class
88
+
`ServiceClientResponse<T>`.
81
89
82
90
**Example generated output:**
83
91
84
92
```java
85
-
public class ServiceResponseCustomerDto extends ServiceClientResponse<CustomerDto> {}
93
+
public class ServiceResponseCustomerDto extends ServiceClientResponse<CustomerDto> {
94
+
}
86
95
```
87
96
88
-
This pattern supports **nested generics** like `ServiceClientResponse<Page<CustomerDto>>` and maps all error responses into **ProblemDetail** objects.
97
+
This pattern supports **nested generics** like `ServiceClientResponse<Page<CustomerDto>>` and maps all error responses
98
+
into **ProblemDetail** objects.
89
99
90
100
---
91
101
@@ -98,7 +108,7 @@ This pattern supports **nested generics** like `ServiceClientResponse<Page<Custo
0 commit comments