Files
ersatztv/web/scripts/generate-openapi-types.test.mjs
T
2026-07-02 18:36:56 +02:00

48 lines
1.2 KiB
JavaScript

import { describe, expect, it } from 'vitest';
import { generateTypes } from './generate-openapi-types.mjs';
describe('generate-openapi-types', () => {
it('emits only schemas and ignores non-operation path item keys', () => {
const output = generateTypes({
components: {
schemas: {
ProblemDetails: {
properties: {
detail: { type: 'string' }
},
type: 'object'
}
}
},
paths: {
'/api/items/{id}': {
parameters: [
{
in: 'path',
name: 'id',
schema: { type: 'integer' }
}
],
get: {
operationId: 'GetItem',
responses: {
200: {
content: {
'application/json': {
schema: { $ref: '#/components/schemas/ProblemDetails' }
}
}
}
}
}
}
}
});
expect(output).toContain('export interface components');
expect(output).toContain('"ProblemDetails"');
expect(output).not.toContain('export interface operations');
expect(output).not.toContain('"parameters"');
});
});