Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/config/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ const versionInfoSchema = {
type: 'object',
properties: {
viId: { type: 'integer', readOnly: true },
viVersion: { type: 'string' },
// viVersion mirrors versioninfo.schema.js: 1..255 chars. SemVer
// is much shorter than 255 in practice, but the cap matches
// every other free-text "name/identifier" column in the API
// for consistency.
viVersion: { type: 'string', minLength: 1, maxLength: 255 },
viDate: { type: 'string', format: 'date-time' },
},
};
Expand Down
11 changes: 11 additions & 0 deletions tests/api/openapi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ describe('OpenAPI spec', () => {
expect(schemas.TimeEntry.properties.teStartedAt).toBeDefined();
});

test('VersionInfo.viVersion pins the 1..255 bound from the validator', async () => {
// Mirrors versioninfo.schema.js. SDK generators expose viVersion
// as `string`; without minLength/maxLength they can't catch a
// client sending a 10k-char "version" string before the server
// does.
const res = await request(app).get('/openapi.json');
const vi = res.body.components.schemas.VersionInfo;
expect(vi.properties.viVersion.minLength).toBe(1);
expect(vi.properties.viVersion.maxLength).toBe(255);
});

test('PurchaseOrderHeader pins the validator field-length bounds', async () => {
// Mirrors purchaseorderheader.schema.js. Without these, SDK
// generators expose pohReference/pohTerms as unbounded strings
Expand Down