Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

JoshThor
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently only the x-enumNames extension is supported for specifying names for enums, however the popular openapi generator only supports the x-enum-varnames extension.

Issue Number: N/A

What is the new behavior?

Add support for the x-enum-varnames and x-enum-descriptions extensions to be added to the schema.

Example:

enum StatusEnum {
  APPROVED = 1,
  PENDING,
  REJECTED
 }

  @ApiProperty({
    description: 'The status enum example',
    enum: StatusEnum,
    enumName: 'StatusEnum',
    'x-enum-varnames': ['APPROVED', 'PENDING', 'REJECTED'],
    'x-enum-descriptions': ['Approved State', 'Pending State', 'Rejected State']
  })
  statusEnum: StatusEnum;

Would generate:

   {
      "StatusEnum ": {
        "type": "number",
        "enum": [
          1,
          2,
          3
        ],
        "description": "The status enum example",
        "x-enum-varnames": [
          "APPROVED",
          "PENDING",
          "REJECTED"
        ],
        "x-enum-descriptions": [
          "Approved State",
          "Pending State",
          "Rejected State"
        ]
      }
   }

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Add support for enum varnames (x-enum-varnames) and description extensions (x-enum-descriptions).
@kumv-net
Copy link

kumv-net commented Apr 1, 2025

cool

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.