Skip to content

feat(openapi3): Add x-enum-varnames extension support for Enum emitter#10166

Open
thormme wants to merge 8 commits intomicrosoft:mainfrom
thormme:main
Open

feat(openapi3): Add x-enum-varnames extension support for Enum emitter#10166
thormme wants to merge 8 commits intomicrosoft:mainfrom
thormme:main

Conversation

@thormme
Copy link
Copy Markdown

@thormme thormme commented Mar 26, 2026

The OpenAPI3 emitter now emits the x-enum-varnames array containing the enum keys when the include-x-enum-varnames option is specified.

Changes

  • Added new boolean option to the @typespec/openapi3 emitter: include-x-enum-varnames
  • Added test coverage: 4 test cases covering true/false/default values, and key order consistency.

include-x-enum-varnames

Type: boolean

True if the generated openapi enums should have the x-enum-varnames extension emitted.
This maintains the key of any enum value that defines it in the form key: value.
The default behavior is to use the value as both the key and value.

Default: false

Example

TypeSpec Input:

enum FruitType {
  apple: "Apples",
  grape: "Grapes",
  cherry: "Cherries"
}

tspconfig.yaml

"@typespec/openapi3":
  include-x-enum-varnames: true

OpenApi3 Output:

FruitType:
  type: string
  enum:
    - Apples
    - Grapes
    - Cherries
  x-enum-varnames:
    - apple
    - grape
    - cherry

@microsoft-github-policy-service microsoft-github-policy-service bot added meta:website TypeSpec.io updates emitter:openapi3 Issues for @typespec/openapi3 emitter openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter labels Mar 26, 2026
@thormme
Copy link
Copy Markdown
Author

thormme commented Mar 26, 2026

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:openapi3 Issues for @typespec/openapi3 emitter meta:website TypeSpec.io updates openapi3:converter Issues for @typespec/openapi3 openapi to typespec converter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant