[openapi3] add enum-mode option for annotated enums in 3.1+#10893
Closed
timotheeguerin wants to merge 1 commit into
Closed
[openapi3] add enum-mode option for annotated enums in 3.1+#10893timotheeguerin wants to merge 1 commit into
enum-mode option for annotated enums in 3.1+#10893timotheeguerin wants to merge 1 commit into
Conversation
Adds opt-in `enum-mode: annotated` emitter option that renders enums as `oneOf` of `const` subschemas with per-member `title`/`description` sourced from `@summary`/`@doc`, matching OpenAPI 3.1's annotated enumerations pattern. Default `enum` preserves existing flat output. Ignored for OpenAPI 3.0. Fixes microsoft#5721 Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5721
Adds an opt-in
enum-modeemitter option to@typespec/openapi3. When set to"annotated", enums are rendered using the OpenAPI 3.1 annotated enumerations pattern — aoneOfof single-constsubschemas with per-membertitle/descriptionpulled from@summary/@doc:The default
"enum"preserves today's flatenum: [...]output. The option is silently ignored for OpenAPI 3.0 sinceconstannotated enums are a 3.1 construct. 3.2 inherits the 3.1 emitter and so picks the behavior up automatically.Test plan
pnpm -F @typespec/openapi3 build— cleanpnpm -F @typespec/openapi3 test— 2532 tests pass, including 5 new cases:@doc→descriptionon each subschema@summary→titleon each subschema{type, const}subschemas@docstill applied to the wrapping schemaenum-mode: annotated→ option ignored (regression guard)🤖 Generated with Claude Code