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

Suggestion: Support x-enumNames extension #234

Open
MattStaffordGS opened this issue Mar 17, 2017 · 2 comments
Open

Suggestion: Support x-enumNames extension #234

MattStaffordGS opened this issue Mar 17, 2017 · 2 comments

Comments

@MattStaffordGS
Copy link

The x-enumNames extension (generated by NSwagStudio in our case) includes the human readable name of an enum when you're using integers for enum rather than strings
It would be great if ReDoc could support being able to display what the integer element of an enum value means, rather than just the value

Currently it shows as
Valid values: 0 1 2

Showing something like
Valid values: Female (0) Male (1) Other (2)
would be really useful

   "PersonGender": {
      "type": "integer",
      "x-enumNames": [
        "Female",
        "Male",
        "Other"
      ],
      "enum": [
        0,
        1,
        2
      ],
      "description": ""
    },
@RicoSuter
Copy link

Any update on this?

Content & configuration

It would be great if ReDoc 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.

image

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:

@hleb-albau
Copy link
Contributor

Is it different from x-enum-descriptions extension?

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

No branches or pull requests

5 participants