2

Redoc is a great tool, but I'm struggling to understand how it works. Currently I've been tasked with copying some docs from api-docs.io to be self served using redoc.

However, my issue is that the schemas aren't appearing in the side bar as they do on the api-docs site. I'm not sure how I can get models to show on the side as well... And I'm fairly new to api documentation. You can also check out how the models are displayed here. And see another example below.

enter image description here

I've taken a look to see if this is a feature of redoc and came across this merged PR which (based on the discussion in the PR's issue) states that we should add an html element, SchemaDefinition. I am using the basic html file (suggested in the readme of the redoc repo), but we want to use a json schema (which is referenced with spec-url) to render the docs on redoc so I'm struggling to understand how I can manipulate the side bar using just the html element.

Maybe it's just my understanding of how redoc works that is lacking. If you feel that's the case, a quick explanation would be wonderful.

osacognitive
  • 103
  • 7

1 Answers1

0

You have to modify the json with additional information.

Sample json (without sidebar model section): https://petstore3.swagger.io/api/v3/openapi.json

Add to "tags" array

{
  "name": "pet_model",
  "description": <SchemaDefinition schemaRef="#/components/schemas/Pet" />,
  "x-displayName": "Pet"
},
{
  "name": "user_model",  
  "description": <SchemaDefinition schemaRef="#/components/schemas/User" />,
  "x-displayName": "User"
}

Then to group the sidebar add the x-tagGroups extension

...
"tags": [...],

"x-tagGroups": [{
  "name": "Api",
  "tags": ["pet", "store", "user"]
},
{
  "name": "Models",
  "tags": ["pet_model", "user_model"]
}],

"paths": ...