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
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,8 @@
17
17
</p>
18
18
19
19
**Type-safe client generation with Spring Boot & OpenAPI using generics.**
20
-
This repository demonstrates how to extend OpenAPI Generator to support **nested generics** and the new unified `{ data, meta }` response model — eliminating duplicated wrappers and repetitive boilerplate.
20
+
This repository demonstrates how to extend OpenAPI Generator to support **nested generics** and the new unified
21
+
`{ data, meta }` response model — eliminating duplicated wrappers and repetitive boilerplate.
21
22
22
23
---
23
24
@@ -34,20 +35,24 @@ This repository demonstrates how to extend OpenAPI Generator to support **nested
34
35
* 📘 [Adoption Guides](#-adoption-guides)
35
36
* 🔗 [References & Links](#-references--links)
36
37
37
-
> *A practical reference for building fully generics-aware OpenAPI clients using Spring Boot 3.4, Java 21, and Mustache overlays.*
38
+
> *A practical reference for building fully generics-aware OpenAPI clients using Spring Boot 3.4, Java 21, and Mustache
*[**customer-service-client**](customer-service-client/README.md) — generated OpenAPI client with generics-aware wrappers
46
+
*[**customer-service-client**](customer-service-client/README.md) — generated OpenAPI client with generics-aware
47
+
wrappers
45
48
46
49
---
47
50
48
51
## 🚀 Problem & Motivation
49
52
50
-
OpenAPI Generator doesn’t natively understand **generic types**. When backend responses use envelopes like `ServiceResponse<T>`, the generator produces one wrapper per endpoint, duplicating fields (`status`, `message`, `errors`, or now `data`, `meta`).
53
+
OpenAPI Generator doesn’t natively understand **generic types**. When backend responses use envelopes like
54
+
`ServiceResponse<T>`, the generator produces one wrapper per endpoint, duplicating fields (`status`, `message`,
55
+
`errors`, or now `data`, `meta`).
51
56
52
57
This leads to:
53
58
@@ -61,12 +66,14 @@ This leads to:
61
66
62
67
This repository defines a **complete pattern** for Spring Boot + OpenAPI Generator:
63
68
64
-
* On the **server side**, a `Springdoc` customizer automatically marks generic wrappers (`ServiceResponse<T>`) with vendor extensions:
69
+
* On the **server side**, a `Springdoc` customizer automatically marks generic wrappers (`ServiceResponse<T>`) with
70
+
vendor extensions:
65
71
66
72
*`x-api-wrapper`
67
73
*`x-api-wrapper-datatype`
68
74
*`x-data-container` / `x-data-item`
69
-
* On the **client side**, Mustache overlays generate **thin wrappers** extending the reusable generic base class `ServiceClientResponse<T>`.
75
+
* On the **client side**, Mustache overlays generate **thin wrappers** extending the reusable generic base class
76
+
`ServiceClientResponse<T>`.
70
77
71
78
Example generated wrapper:
72
79
@@ -76,14 +83,15 @@ public class ServiceResponseCustomerDto
76
83
}
77
84
```
78
85
79
-
This new structure supports **nested generics** like `ServiceClientResponse<Page<CustomerDto>>` and includes both `data` and `meta` sections.
86
+
This new structure supports **nested generics** like `ServiceClientResponse<Page<CustomerDto>>` and includes both `data`
0 commit comments