Skip to content

Commit 6bb90c6

Browse files
committed
docs(customer-service): clarify enhanced OpenAPI contract and wrapper extensions in README
- Updated Architecture & Explanation sections to highlight that customer-service publishes an enhanced OpenAPI spec with x-api-wrapper extensions. - Clarified client-side consumption path and removed redundant consumer app details. - Added note that the spec is stored under customer-service-client as customer-api-docs.yaml. - Improved example response formatting with explicit ServiceResponse<T> wrapper mention.
1 parent 5c83482 commit 6bb90c6

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

customer-service/README.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ against.
2626
## 📊 Architecture at a Glance
2727

2828
```
29-
[customer-service] ── publishes ──> /v3/api-docs.yaml (OpenAPI contract)
29+
[customer-service] ── publishes ──> /v3/api-docs.yaml (OpenAPI contract with x-api-wrapper extensions)
3030
3131
└─ consumed by OpenAPI Generator (+ generics-aware templates)
3232
@@ -37,14 +37,13 @@ against.
3737

3838
### Explanation
3939

40-
* **customer-service** exposes the OpenAPI contract at `/v3/api-docs.yaml` (and Swagger UI).
41-
* **customer-service-client** runs the OpenAPI Generator against that contract, applying generics-aware Mustache
42-
templates to produce **thin wrapper classes**.
43-
* **Your applications** then depend on this generated client. They call `CustomerControllerApi` (and other APIs)
44-
directly without worrying about HTTP details, connection management, or response parsing.
40+
* **customer-service** exposes an **enhanced OpenAPI contract** at `/v3/api-docs.yaml` (and Swagger UI).
41+
It auto-registers generic wrappers (`ServiceResponse<T>`) using `OpenApiCustomizer` and `ResponseTypeIntrospector`,
42+
enriching the spec with vendor extensions:
43+
- `x-api-wrapper: true`
44+
- `x-api-wrapper-datatype: <T>`
4545

46-
➡️ This separation keeps the **server-side contract** clear, the **client auto-generated**, and the **consumer apps
47-
strongly typed**.
46+
* **customer-service-client** runs the OpenAPI Generator against this enhanced contract, applying generics-aware Mustache templates to generate **thin wrapper classes** instead of duplicating full models.
4847

4948
---
5049

@@ -81,7 +80,7 @@ curl -X POST "http://localhost:8084/customer-service/v1/customers" \
8180
-d '{"name":"Jane Doe","email":"[email protected]"}'
8281
```
8382

84-
**Expected response (shape):**
83+
**Expected response (wrapped in `ServiceResponse<CustomerCreateResponse>`):**
8584

8685
```json
8786
{
@@ -165,7 +164,32 @@ http://localhost:8084/customer-service/v1/customers
165164
* OpenAPI YAML → `http://localhost:8084/customer-service/v3/api-docs.yaml`
166165

167166
➡️ The YAML/JSON spec above is the **contract** that the client module (`customer-service-client`) consumes when
168-
generating code.
167+
generating code.
168+
For clarity, in this repository the file is saved under the client module as
169+
`src/main/resources/customer-api-docs.yaml`.
170+
171+
---
172+
173+
### Example Wrapper Snippet
174+
175+
The generated OpenAPI YAML (`/v3/api-docs.yaml`) includes wrapper schemas
176+
with vendor extensions that mark generic response envelopes:
177+
178+
```yaml
179+
ServiceResponseCustomerDto:
180+
allOf:
181+
- $ref: "#/components/schemas/ServiceResponse"
182+
- type: object
183+
properties:
184+
data:
185+
$ref: "#/components/schemas/CustomerDto"
186+
x-api-wrapper: true
187+
x-api-wrapper-datatype: CustomerDto
188+
```
189+
➡️ These `x-api-wrapper` fields are added automatically by the
190+
`OpenApiCustomizer` and `ResponseTypeIntrospector` so that the client
191+
generator knows which classes should become **thin wrappers** extending the
192+
generic base.
169193

170194
---
171195

0 commit comments

Comments
 (0)