Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(enum): add support for enum varnames and descriptions #3310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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).
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.

2 participants