redoc icon indicating copy to clipboard operation
redoc copied to clipboard

Array of enums ignores enum's schema description when rendered

Open flaksp opened this issue 5 years ago β€’ 4 comments

Example array schema:

{
  "description": "Π ΠΎΠ»ΠΈ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ.",
  "items": {
    "description": "Роль ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Ρ.\n\n* `ROLE_DEVELOPER`. Π Π°Π·Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊ (ΠΈΠΌΠ΅Π΅Ρ‚ всС Π²ΠΎΠ·ΠΌΠΎΠΆΠ½Ρ‹Π΅ ΠΏΡ€Π°Π²Π°).\n* `ROLE_MANAGER`. ΠœΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ (Π½Π° Π΄Π°Π½Π½Ρ‹ΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ‚ являСтся синонимом слова \"Π°Π΄ΠΌΠΈΠ½\").\n* `ROLE_MEDICAL_REPRESENTATIVE`. ΠœΠ΅Π΄ΠΈΡ†ΠΈΠ½ΡΠΊΠΈΠΉ ΠΏΡ€Π΅Π΄ΡΡ‚Π°Π²ΠΈΡ‚Π΅Π»ΡŒ.",
    "example": "ROLE_DEVELOPER",
    "title": "Role",
    "type": "string",
    "nullable": false,
    "readOnly": false,
    "writeOnly": false,
    "enum": [
      "ROLE_DEVELOPER",
      "ROLE_MANAGER",
      "ROLE_MEDICAL_REPRESENTATIVE"
    ]
  },
  "maxItems": 3,
  "minItems": 0,
  "uniqueItems": true,
  "type": "array",
  "nullable": false
}

That's how ReDoc renders it in response section:

image

That's how ReDoc renders it in parameters section:

image

As you may see, ReDoc ignores description of enum schema. I didn't tested how ReDoc renders it in request section, but I'm sure result will be the same as in response section.

flaksp avatar May 08 '19 16:05 flaksp

Do you have any ideas of how to render it? I'm not sure what's the best behavior here.. Just append items description bellow array description?

RomanHotsiy avatar May 09 '19 12:05 RomanHotsiy

@RomanGotsiy, yes, appending below seems like a good idea.

Here's some example how I see it:

image

Or maybe it's better to indent it a bit:

image

Note that I have removed line "Items Enum".

flaksp avatar May 11 '19 19:05 flaksp

Also, we can generate description from popular extension x-enum-descriptions

hleb-albau avatar Oct 16 '20 09:10 hleb-albau

Also, can we get rid of the word "Enum:" the actual name of the property in OAS (enum) bares no meaning to the end user of the API Docs. You could name it "Options" which is the word mentioned in the Open API Specification section 4.8.6.1

ernestomi avatar Dec 23 '21 23:12 ernestomi