Skip to content

Fix examples not populating in openapi3 outputs when versioned union variants have enum parameters#9323

Closed
FrankShaw wants to merge 1 commit intomicrosoft:mainfrom
FrankShaw:fix/examples-versioned-unions-with-enums
Closed

Fix examples not populating in openapi3 outputs when versioned union variants have enum parameters#9323
FrankShaw wants to merge 1 commit intomicrosoft:mainfrom
FrankShaw:fix/examples-versioned-unions-with-enums

Conversation

@FrankShaw
Copy link

Fixes #9229

I took a stab at fixing this. I am not sure whether this is the proper solution, but maybe it can be a starting point. I'm willing to adapt the solution based on feedback.

What I found is that when checking whether an operation example is assignable to an operation in a versioned API, the type-relation-checker for Enums only does a reference comparison of the enum from the example value to the source enum. This breaks because the enum coming from the doc being built is a clone of the original enum (done when creating the versioned projections). I didn't think there was really much that can be done about the fact that a clone of the original enum is created for each version, so I figured I would add a secondary deep compare of the two enums if the original reference comparison fails

@microsoft-github-policy-service microsoft-github-policy-service bot added compiler:core Issues for @typespec/compiler emitter:openapi3 Issues for @typespec/openapi3 emitter labels Jan 11, 2026
@FrankShaw
Copy link
Author

@microsoft-github-policy-service agree

@timotheeguerin
Copy link
Member

Hi @FrankShaw I believe this was fixed in #9308 and will be available in this week release. Looks like we had a duplicate issue for this.

next playground with the repro of the issue

@FrankShaw
Copy link
Author

Thanks for the heads up @timotheeguerin closing this PR then 😄

@FrankShaw FrankShaw closed this Jan 12, 2026
@FrankShaw FrankShaw deleted the fix/examples-versioned-unions-with-enums branch January 12, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler emitter:openapi3 Issues for @typespec/openapi3 emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: enum examples are not correctly translated to OpenAPI using @opExample.

2 participants