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
feat(customer-service): add full CRUD support with type-safe generic responses
- Implemented complete CRUD endpoints in CustomerController
- Introduced dedicated DTOs for create, update, list, and delete responses
- Added CustomerControllerAdvice for consistent error handling
- Enhanced unit tests for controller and service layers
- Updated README.md with CRUD usage examples
- Bumped service version to 0.3.0 to reflect new functionality
Copy file name to clipboardExpand all lines: README.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,14 +13,16 @@
13
13
</p>
14
14
15
15
**Type-safe client generation with Spring Boot & OpenAPI using generics.**
16
-
This repository demonstrates how to teach OpenAPI Generator to work with generics in order to avoid boilerplate, reduce duplicated wrappers, and keep client code clean.
16
+
This repository demonstrates how to teach OpenAPI Generator to work with generics in order to avoid boilerplate, reduce
17
+
duplicated wrappers, and keep client code clean.
17
18
18
19
---
19
20
20
21
## 🚀 Problem Statement
21
22
22
23
Most backend teams standardize responses with a generic wrapper like `ApiResponse<T>`.
23
-
However, **OpenAPI Generator does not natively support generics** — instead, it generates one wrapper per endpoint (duplicating fields like `status`, `message`, and `errors`).
24
+
However, **OpenAPI Generator does not natively support generics** — instead, it generates one wrapper per endpoint
25
+
(duplicating fields like `status`, `message`, and `errors`).
Copy file name to clipboardExpand all lines: customer-service-client/README.md
+39-17Lines changed: 39 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,20 @@
1
1
# customer-service-client
2
2
3
-
Generated Java client for the demo **customer-service**, showcasing **type‑safe generic responses** with OpenAPI + a custom Mustache template (wrapping payloads in a reusable `ApiClientResponse<T>`).
3
+
Generated Java client for the demo **customer-service**, showcasing **type-safe generic responses** with OpenAPI + a
4
+
custom Mustache template (wrapping payloads in a reusable `ApiClientResponse<T>`).
4
5
5
-
This module demonstrates how to evolve OpenAPI Generator with minimal customization to support generic response envelopes — avoiding duplicated wrappers and preserving strong typing.
6
+
This module demonstrates how to evolve OpenAPI Generator with minimal customization to support generic response
7
+
envelopes — avoiding duplicated wrappers and preserving strong typing.
6
8
7
9
---
8
10
9
11
## ✅ What You Get
10
12
11
13
* Generated code using **OpenAPI Generator** (`restclient` with Spring Framework `RestClient`).
12
14
* A reusable generic base: `io.github.bsayli.openapi.client.common.ApiClientResponse<T>`.
13
-
* Thin wrappers per endpoint (e.g. `ApiResponseCustomerCreateResponse`) that extend the base.
14
-
* Spring Boot configuration to auto‑expose the client as beans.
15
-
*A focused integration test using **OkHttp MockWebServer**.
15
+
* Thin wrappers per endpoint (e.g. `ApiResponseCustomerCreateResponse`, `ApiResponseCustomerUpdateResponse`).
16
+
* Spring Boot configuration to auto-expose the client as beans.
17
+
*Focused integration tests using **OkHttp MockWebServer** covering all CRUD endpoints.
16
18
17
19
---
18
20
@@ -23,14 +25,14 @@ This module demonstrates how to evolve OpenAPI Generator with minimal customizat
23
25
```bash
24
26
cd customer-service
25
27
mvn spring-boot:run
26
-
# Service base URL: http://localhost:8084/customer
28
+
# Service base URL: http://localhost:8084/customer-service
* Business code depends only on the adapter interface.
173
+
* Naming conventions are consistent with the service (createCustomer, getCustomer, getCustomers, updateCustomer, deleteCustomer).
152
174
153
175
---
154
176
@@ -177,7 +199,7 @@ Integration test with MockWebServer:
177
199
mvn -q -DskipITs=false test
178
200
```
179
201
180
-
It enqueues a `201` response and asserts correct mapping into `ApiResponseCustomerCreateResponse`.
202
+
It enqueues responses for **all CRUD operations**and asserts correct mapping into the respective wrappers (e.g. `ApiResponseCustomerCreateResponse`, `ApiResponseCustomerUpdateResponse`).
Copy file name to clipboardExpand all lines: customer-service-client/src/main/java/io/github/bsayli/openapi/client/adapter/config/CustomerApiClientConfig.java
Copy file name to clipboardExpand all lines: customer-service-client/src/main/java/io/github/bsayli/openapi/client/adapter/impl/CustomerClientAdapterImpl.java
0 commit comments