swagger-api / swagger-api/swagger-ui
Support x-enumNames for integer enums
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Content & configuration
It would be great if the Swagger UI could take x-enumNames into account if it is available. It is generated by the NSwag swagger toolchain and defines the enum names (not the values) and is useful for number enums (i.e. when the human readable names are missing).
Swagger/OpenAPI definition:
"PersonGender": {
"type": "integer",
"x-enumNames": [
"Female",
"Male",
"Other"
],
"enum": [
0,
1,
2
],
"description": ""
},
Is your feature request related to a problem?
Right now the generator has to generate a "special" description so that the user knows the mapping - but this is not very structured.

Describe the solution you'd like
If there's an x-enumNames property in an enum schema, render the name in the dropdown with the same index as the value and submit the correct enum value. This way the description is not needed anymore.
Describe alternatives you've considered
Right now we are using the description with the mappings - but that is not optimal...
Additional context
Refs:
- Original issue in NSwag: https://github.com/RicoSuter/NSwag/issues/1993
- Issue in ReDoc: https://github.com/Rebilly/ReDoc/issues/234
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation file or test is named. Start by locating Swagger UI's enum dropdown rendering and the schema handling for integer enums, then compare the x-enumNames and enum arrays by index; done means displaying each human-readable name while submitting its corresponding numeric value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100