feat(openapi3): extend annotated enum strategy to unions of literals#11154
feat(openapi3): extend annotated enum strategy to unions of literals#11154tellnes wants to merge 1 commit into
Conversation
|
All changed packages have been documented.
Show changes
|
When `enum-strategy: annotated` is set, literal unions now emit as `oneOf`/`anyOf` of `const` subschemas with per-variant `title` and `description` from `@summary`/`@doc`, preserving documentation that the default `enum`-merge form discards. Falls back to default on OpenAPI 3.0.0 with a warning.
eff4f41 to
ad41540
Compare
Extends
enum-strategy: annotated(#10892, which fixed #5721) to unions of literals. That option previously stopped atenumdeclarations, so unions of literals still collapsed to a flatenum, dropping variant names,@summary, and docs.Before:
{ type: string, enum: ["https://example.com/errors/bad-request"] }After (with
enum-strategy: annotated):Behavior
defaultoutput unchanged.enum-strategy-not-supportedwarning.oneOfwhen the union has@oneOf, elseanyOf.titlefrom@summary,descriptionfrom@doc, both omitted when absent, matching the enum handling.Open question
The option is named
enum-strategybut now also covers unions of literals (both are "enumerated types" in OpenAPI terms). I broadened its description rather than renaming it. Happy to add an alias if preferred.