Describe the bug
With @typespec/openapi3 1.16.0, distinct variants of a discriminated union reuse the first envelope schema when their payload types match. The emitter repeats that schema in oneOf and points every discriminator mapping to it. The other envelope schemas are missing from the output.
For example:
@discriminated(#{
discriminatorPropertyName: "tag",
envelopePropertyName: "contents"
})
union Limit {
daily: string,
weekly: string,
monthly: string,
}
This produces a oneOf schema that references LimitDaily three times, and rejects any payload with "tag":"weekly" or "tag":"monthly".
Reproduction
Playground
Checklist
Describe the bug
With
@typespec/openapi31.16.0, distinct variants of a discriminated union reuse the first envelope schema when their payload types match. The emitter repeats that schema inoneOfand points every discriminator mapping to it. The other envelope schemas are missing from the output.For example:
This produces a
oneOfschema that referencesLimitDailythree times, and rejects any payload with"tag":"weekly"or"tag":"monthly".Reproduction
Playground
Checklist