-
Notifications
You must be signed in to change notification settings - Fork 335
Closed
Labels
compiler:coreIssues for @typespec/compilerIssues for @typespec/compilerfeatureNew feature or requestNew feature or request
Description
Describe the bug
The @typespec/openapi3 emitter supports @examples for models, but outputs incorrect examples for unions.
For example (playground link):
@example(#{ a: 1 })
union U {
number: {
a: integer,
},
text: {
s: string,
},
}should output with { a: 1 } as the example, but instead it is {}:
U:
anyOf:
- type: object
properties:
a:
type: integer
required:
- a
- type: object
properties:
s:
type: string
required:
- s
example: {}(The TypeSpec compiler correctly detects any errors in the @example tag, e.g. using @example(#{ a: "string" }) causes a compile error – so presumably the issue lies in the @typespec/openapi3 package.)
Reproduction
Or example:
@example(#{ a: 1 })
union U {
number: {
a: integer,
},
text: {
s: string,
},
}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
compiler:coreIssues for @typespec/compilerIssues for @typespec/compilerfeatureNew feature or requestNew feature or request