Problem with rendering multiple schema examples in complex json schema.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
when using oneOf, only one of the schema examples renders. Redoc doesn't seem to have the option for picking from the oneOf.
In my example below, Redoc only renders the example from AdministrativeArea.
"schema": {
"type": "object",
"properties": {
"hits": {
"type": "integer",
"format": "int32"
},
"data": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/components/schemas/AdministrativeArea"
},
{
"$ref": "#/components/schemas/EmploymentCategory"
}, ...
However, multiple examples can be rendered if the schema is simplified as below. But our openapi spec is more complex than it.
"schema": {
"description": "Enhanced entity",
"oneOf": [
{
"$ref": "#/components/schemas/OrganizationResponse"
},
{
"$ref": "#/components/schemas/PersonResponse"
}
]
}
Is there a bug in my OpenAPI spec or is it a bug with Redoc? Any help is appreciated. Thanks in advance!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the nested oneOf schema example and compare it with the simplified oneOf example shown in the issue. Check how Redoc renders examples for array items and referenced schemas, then verify the result against the OpenAPI specification; done means the reported complex schema behavior is explained and corrected or documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, react, typescript
- Domain
- api, documentation, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100