diff --git a/packages/openapi/src/core/normalize.test.ts b/packages/openapi/src/core/normalize.test.ts index 249fba04..bda13cea 100644 --- a/packages/openapi/src/core/normalize.test.ts +++ b/packages/openapi/src/core/normalize.test.ts @@ -101,6 +101,19 @@ describe('normalize', () => { expect(ir.operations[0]?.responses[0]?.contentType).toBe('application/json'); }); + it('keeps trace operations instead of silently dropping them', () => { + const ir = normalize({ + openapi: '3.0.0', + info: { title: 'Trace', version: '1' }, + paths: { + '/debug': { trace: { operationId: 'traceDebug', responses: { '200': { description: 'ok' } } } }, + }, + }); + expect(ir.operations).toHaveLength(1); + expect(ir.operations[0]?.method).toBe('trace'); + expect(ir.operations[0]?.id).toBe('traceDebug'); + }); + it('auto-generates operationId when missing', () => { const ir = normalize({ openapi: '3.0.0', diff --git a/packages/openapi/src/core/normalize.ts b/packages/openapi/src/core/normalize.ts index 925dcd9c..dfc62bac 100644 --- a/packages/openapi/src/core/normalize.ts +++ b/packages/openapi/src/core/normalize.ts @@ -8,7 +8,9 @@ import type { SecurityScheme, } from './types.js'; -const METHODS: HttpMethod[] = ['get', 'post', 'put', 'delete', 'patch', 'head', 'options']; +// `trace` is part of the OpenAPI 3 Operations Object — without it, trace +// operations are silently dropped from the IR and every generator output. +const METHODS: HttpMethod[] = ['get', 'post', 'put', 'delete', 'patch', 'head', 'options', 'trace']; // Walks a parsed OpenAPI 3.x document and produces our internal IR. // $ref resolution is intentionally shallow: we only resolve refs that point diff --git a/packages/openapi/src/core/types.ts b/packages/openapi/src/core/types.ts index aa8cdd50..83dbd31c 100644 --- a/packages/openapi/src/core/types.ts +++ b/packages/openapi/src/core/types.ts @@ -3,7 +3,7 @@ // keep JSON Schema as a pass-through `unknown` to avoid reimplementing it; // generators that need richer typing can walk it themselves. -export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options'; +export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head' | 'options' | 'trace'; export interface Parameter { name: string;