Skip to content

Commit f84fd45

Browse files
CryptoJonesAaron K. Clarkclaude
authored
docs(openapi): declare GET /v1/customer/bycompany/{id} 200 envelope (#341)
Same missing-content-schema pattern fixed for /v1/customer/{id} in #312, POST /v1/customer in #316, POST /v1/timeentry in #326, and POST /v1/customer/bulk in #332 — now for the paginated list endpoint. The spec previously said only `description: 'OK'`, so SDK generators reading the spec couldn't model the Link-header-paired pagination envelope the controller emits: { message, count, limit, offset, customers: Customer[] } Declare the shape and pin it 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>
1 parent 7f1e436 commit f84fd45

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

app/config/openapi.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,33 @@ const spec = {
700700
{ name: 'offset', in: 'query', schema: { type: 'integer', default: 0 } },
701701
],
702702
responses: {
703-
200: { description: 'OK' },
703+
200: {
704+
description: 'OK — paginated customer list',
705+
// Controller wraps the rows in a {message, count,
706+
// limit, offset, customers} envelope. Same
707+
// missing-content-schema pattern fixed for the
708+
// single GET in #312 and the bulk POST in #332 —
709+
// now also for the paginated list. Without the
710+
// declaration, SDK generators can't model the
711+
// Link-header-paired pagination envelope.
712+
content: {
713+
'application/json': {
714+
schema: {
715+
type: 'object',
716+
properties: {
717+
message: { type: 'string' },
718+
count: { type: 'integer' },
719+
limit: { type: 'integer' },
720+
offset: { type: 'integer' },
721+
customers: {
722+
type: 'array',
723+
items: { $ref: '#/components/schemas/Customer' },
724+
},
725+
},
726+
},
727+
},
728+
},
729+
},
704730
403: { description: 'Missing or invalid authKey' },
705731
},
706732
},

tests/api/openapi.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,25 @@ describe('OpenAPI spec', () => {
9292
expect(err.required).toEqual(['message']);
9393
});
9494

95+
test('GET /v1/customer/bycompany/{id} 200 declares the {message, count, limit, offset, customers} envelope', async () => {
96+
// Paginated list endpoint — controller emits the same envelope
97+
// every list endpoint uses. Pre-fix the spec said only
98+
// `description: 'OK'`, so SDK generators couldn't model the
99+
// shape clients see in response to a Link-header-paginated
100+
// walk. Same missing-content-schema fix pattern as #316
101+
// (single POST) and #332 (bulk POST).
102+
const res = await request(app).get('/openapi.json');
103+
const r200 = res.body.paths['/v1/customer/bycompany/{id}'].get.responses['200'];
104+
const schema = r200.content['application/json'].schema;
105+
expect(schema.type).toBe('object');
106+
expect(schema.properties.message.type).toBe('string');
107+
expect(schema.properties.count.type).toBe('integer');
108+
expect(schema.properties.limit.type).toBe('integer');
109+
expect(schema.properties.offset.type).toBe('integer');
110+
expect(schema.properties.customers.type).toBe('array');
111+
expect(schema.properties.customers.items.$ref).toBe('#/components/schemas/Customer');
112+
});
113+
95114
test('POST /v1/customer/bulk 201 declares the {message, count, customers} envelope', async () => {
96115
// makeBulkCreate (app/controllers/_bulk-helpers.js) emits
97116
// {message, count, <createdKey>}. The spec previously had

0 commit comments

Comments
 (0)