feat: add versioned all-available source export catalog
This commit is contained in:
26
tools/openapi/check-source-export-runtime.mjs
Normal file
26
tools/openapi/check-source-export-runtime.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
/** Validate actual new-scope responses using the generated client validators. */
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { isDeepStrictEqual } from 'node:util';
|
||||
import {
|
||||
V2OrganizationSourceRecordsExportCatalogList200Response,
|
||||
V2OrganizationSourceRecordsExportCatalogRead200Response,
|
||||
V2OrganizationSourceRecordsExportTicket201Response,
|
||||
V2OrganizationSourceRecordsExportCatalogList400Response,
|
||||
} from './generated-zod/contract.ts';
|
||||
const validators = {
|
||||
catalog: V2OrganizationSourceRecordsExportCatalogList200Response,
|
||||
detail: V2OrganizationSourceRecordsExportCatalogRead200Response,
|
||||
'file-ticket': V2OrganizationSourceRecordsExportTicket201Response,
|
||||
'archive-ticket': V2OrganizationSourceRecordsExportTicket201Response,
|
||||
invalid: V2OrganizationSourceRecordsExportCatalogList400Response,
|
||||
};
|
||||
const cases = JSON.parse(readFileSync(process.argv[2], 'utf8'));
|
||||
const seen = new Set();
|
||||
for (const fixture of cases) {
|
||||
if (seen.has(fixture.name) || !validators[fixture.name]) throw new Error('Unexpected fixture');
|
||||
seen.add(fixture.name);
|
||||
const value = validators[fixture.name].parse(fixture.body);
|
||||
if (!isDeepStrictEqual(value, fixture.body)) throw new Error(`Lossy generated validator: ${fixture.name}`);
|
||||
}
|
||||
if (seen.size !== Object.keys(validators).length) throw new Error('Missing fixtures');
|
||||
console.log(`Source export generated Zod: ${seen.size} actual API responses passed`);
|
||||
Reference in New Issue
Block a user