-
Notifications
You must be signed in to change notification settings - Fork 351
[Bug]: Implicit visibility with @discriminated unions can create duplicate type names #8677
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingemitter:openapi3Issues for @typespec/openapi3 emitterIssues for @typespec/openapi3 emittertriaged:core
Milestone
Description
Describe the bug
import "@typespec/http";
using TypeSpec.Http;
model M {
@visibility(Lifecycle.Create)
prop: string;
}
@discriminated
union U {
variant: M,
}
@put op createOrUpdate(@body body: U): U;Because the @discriminated union creates its own envelope shapes, it wants to synthesize a schema named UVariant for variant's envelope shape. However, because the inner property prop is only visible in Create phases, implicit visibility is triggered. This causes OpenAPI to create two different schemas both named UVariant. Note that you have to use Create or Update visibility to trigger the bug. If you use Read visibility, the bug is not triggered because the same schema can be reused via. readOnly.
Reproduction
Minimal repro: TypeSpec Playground
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingemitter:openapi3Issues for @typespec/openapi3 emitterIssues for @typespec/openapi3 emittertriaged:core