RapiDoc icon indicating copy to clipboard operation
RapiDoc copied to clipboard

New possibility to add enums with labels through oneof

Open Misfits09 opened this issue 2 years ago • 0 comments

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 à 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 à 15 40 02

Hope you find this convincing 😉

Misfits09 avatar May 19 '23 13:05 Misfits09