From 83e19fb5568f2bf8eac6bd7ff47c88a6bd768711 Mon Sep 17 00:00:00 2001 From: Jens Verbeken Date: Fri, 3 Apr 2026 23:01:10 +0200 Subject: [PATCH] fix(openapi3): missing discriminator mapping entry when first union variant causes circular emit --- packages/openapi3/src/schema-emitter.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/openapi3/src/schema-emitter.ts b/packages/openapi3/src/schema-emitter.ts index a6970792702..520d8503af6 100644 --- a/packages/openapi3/src/schema-emitter.ts +++ b/packages/openapi3/src/schema-emitter.ts @@ -720,7 +720,13 @@ export class OpenAPI3SchemaEmitterBase< for (const [key, model] of variants.entries()) { const ref = this.emitter.emitTypeReference(model); compilerAssert(ref.kind === "code", "Unexpected ref schema. Should be kind: code"); - mapping[key] = (ref.value as any).$ref; + if (ref.value instanceof Placeholder) { + ref.value.onValue((resolvedValue) => { + mapping[key] = (resolvedValue as any).$ref; + }); + } else { + mapping[key] = (ref.value as any).$ref; + } } return mapping; }