Skip to content

feat(customer): add singular customer key on GET /v1/customer/:id#292

Merged
CryptoJones merged 1 commit into
masterfrom
feat/customer-getById-add-singular-key
May 19, 2026
Merged

feat(customer): add singular customer key on GET /v1/customer/:id#292
CryptoJones merged 1 commit into
masterfrom
feat/customer-getById-add-singular-key

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Summary

The 200 response for GET /v1/customer/:id historically wrapped the single customer object under a plural customers key — a wart from before the codebase standardized on singular-for-single-row across the other 15 entities (worker, billingtype, job, ...). SDK clients generating typed accessors had to special-case Customer against every other entity.

Surface the singular customer key in the same response, alongside the existing customers key. Existing clients reading customers keep working unchanged; new code can use customer and match the rest of the API.

Backward compatibility

  • customers stays in the response for now — a future major version can drop it.
  • Both keys reference the same object, so the wire-size delta is negligible (one extra JSON pointer).

Test plan

  • npm run lint && npm test — 761 passing.
  • Existing customer tests don't assert the response shape body fields, so no test updates needed; the change is additive.

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

The 200 response for \`GET /v1/customer/:id\` historically wrapped the
single customer object under a plural \`customers\` key — a wart from
before the codebase standardized on singular-for-single-row across
the other 15 entities (\`worker\`, \`billingtype\`, \`job\`, ...). SDK
clients generating typed accessors had to special-case Customer
against every other entity.

Surface the singular \`customer\` key in the same response, alongside
the existing \`customers\` key. Existing clients reading \`customers\`
keep working unchanged; new code can use \`customer\` and match
the rest of the API.

The pluralized key stays in the response for backward compat — a
future major version can drop it; until then the cost is one extra
JSON-payload reference (no payload size increase since both keys
reference the same object).

761 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit fe6bd22 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the feat/customer-getById-add-singular-key branch May 19, 2026 16:15
CryptoJones added a commit that referenced this pull request May 19, 2026
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: Aaron K. Clark <akclark@thenetwerk.net>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant