docs(openapi): fix GET /v1/customer/{id} 200 response-shape drift (#312)#313
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/