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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New possibility to add enums with labels through oneof #928

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Misfits09
Copy link

@Misfits09 Misfits09 commented May 19, 2023

As discussed in this Stackoverflow thread there is no way to create enums with labels out of the box (like enums of integers for some configurations). The simplest workaround is to use a oneOf with constant values.

As show below, displayed with rapidoc this leads in a very confusing documentation :

Openapi schema sample
{
        "format": "int32",
        "oneOf": [
          {
            "const": 0,
            "format": "int32",
            "title": "LAST_UPDATED_SOURCE_NOT_SET",
            "type": "const"
          },
          {
            "const": 1,
            "format": "int32",
            "title": "BIKE_GPS",
            "type": "const",
            "description": "some description"
          },
          {
            "const": 2,
            "format": "int32",
            "title": "APP_DATA",
            "type": "const",
            "description": "some other description"
          }]
}

Capture d鈥檈虂cran 2023-05-19 a虁 15 40 27

Therefore I implemented a more suited way to display a one iff it contains only constant values :

Capture d鈥檈虂cran 2023-05-19 a虁 15 40 02

Hope you find this convincing 馃槈

@Misfits09 Misfits09 force-pushed the feature/oneof-enum-with-labels branch from e11ac1c to ef4e59b Compare June 8, 2023 07:22
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.

None yet

1 participant