Skip to content

fix(openapi3): preserve envelopes for variants sharing a payload type - #11990

Draft
Timothee Guerin (timotheeguerin) wants to merge 1 commit into
microsoft:mainfrom
timotheeguerin:fix/openapi3-union-envelope-identity
Draft

Timothee Guerin (timotheeguerin) wants to merge 1 commit into
microsoft:mainfrom
timotheeguerin:fix/openapi3-union-envelope-identity

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

Since 1.6.0, discriminated union variants with the same payload type reuse the first variant's envelope. This repeats its schema in oneOf and points every discriminator mapping to it, rejecting valid variants.

@discriminated(#{ discriminatorPropertyName: "tag", envelopePropertyName: "contents" })
union Limit {
  daily: string,
  weekly: string,
  monthly: string,
}

This now emits distinct LimitDaily, LimitWeekly, and LimitMonthly envelopes with matching discriminator values. Envelope caching uses the variant name within its union, preserving visibility-specific reuse.

Fixes the regression introduced by #8711.

Fixes #11979.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:openapi3 Issues for @typespec/openapi3 emitter label Sep 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/openapi3@11990

commit: 352c232

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/openapi3
Show changes

@typespec/openapi3 - fix ✏️

Preserve distinct discriminated union envelopes when variants share the same payload type.

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:openapi3 Issues for @typespec/openapi3 emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenAPI3 merges discriminated union envelopes when variants share a payload type

1 participant