Skip to content

docs(openapi): fix GET /v1/customer/{id} 200 response-shape drift (#312)#313

Merged
CryptoJones merged 1 commit into
masterfrom
docs/openapi-customer-getbyid-response-shape
May 19, 2026
Merged

docs(openapi): fix GET /v1/customer/{id} 200 response-shape drift (#312)#313
CryptoJones merged 1 commit into
masterfrom
docs/openapi-customer-getbyid-response-shape

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #312.

Summary

The spec said the body was a bare Customer. The controller returns a {message, customer, customers} envelope. SDK code-gen built clients expecting the wrong shape.

Update the 200 schema to describe the envelope, and add the missing 404 entry the controller emits on a missing row. Pin both with a test.

Test plan

  • npm run lint && npm test — 778 passing (was 777).

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

The OpenAPI spec declared the 200 body as a bare Customer
(`$ref: '#/components/schemas/Customer'`). The controller actually
wraps the row in a `{message, customer, customers}` envelope — the
dual `customer` (singular) + `customers` (plural, backward-compat
wart from before #292) key is documented in customercontroller.js's
findAndRespond.

SDK code-gen (openapi-typescript, quicktype, etc.) reading the
spec built clients expecting the bare row, then failed to find the
fields at runtime because they live one level deeper inside the
envelope.

Fix the spec to describe the actual envelope shape:
  {
    message: string,
    customer: Customer,
    customers: Customer
  }

Also document the 404 response that the controller emits when the
row is missing — was previously not in the spec, so SDK clients
couldn't model that branch either.

Pin both with a test in tests/api/openapi.test.js.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 18ad696 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the docs/openapi-customer-getbyid-response-shape branch May 19, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI: GET /v1/customer/{id} response shape drift (bare Customer vs envelope)

1 participant