PaloAltoNetworks / PaloAltoNetworks/docusaurus-openapi-docs
Unable to render example from schema when using anyOf or other multiple responses
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 315
- Avg merge
- 7d 5h
- Merged PRs (30d)
- 7
Description
Describe the bug
I noticed that it can't render the example from the schema when using anyof. It does know that there are two possible responses, but not what the schema is. I do know each one is correct because they are being used elsewhere and that renders.
"EnvironmentsResponse": {
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"description": "A collection of environment information.",
"anyOf": [
{
"type": "array",
"items": {
"$ref": "#/components/schemas/Environment"
}
},
{
"type": "array",
"items": {
"$ref": "#/components/schemas/EnvironmentSummary"
}
}
]
}
}
},
Expected behavior
It should render each response.
Current behavior
Doesn't render each response. Instead returns
{
"data": [
null
]
}
Possible solution
Steps to reproduce
https://preview-docs.coalesce.io/docs/api/coalesce/get-environments (no schema example)
https://preview-docs.coalesce.io/docs/api/coalesce/get-environment (Schema example working)
They both share the Environment Component.
Every endpoint that has multiple responses doesn't render an example.
List Nodes
Get Node
List Workspace Nodes
It does work in Swagger Editor.
Context
Not able to provide response examples when there are multiple options.
Your Environment
"@docusaurus/core": "^3.5.2",
"@docusaurus/preset-classic": "^3.5.2",
"docusaurus-plugin-openapi-docs": "^4.0.1",
"docusaurus-theme-openapi-docs": "^4.0.1",
- Version used: 4.0.1
- Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): Chrome Version 127.0.6533.120 (Official Build) (arm64).
- Node v20.11.0
- Operating System and version (desktop or mobile): Mac Sonoma 14.6.1.
- Link to your project:
https://preview-docs.coalesce.io/docs/api/coalesce/get-environments (no schema example)
https://preview-docs.coalesce.io/docs/api/coalesce/get-environment (Schema example working)
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 schema examples at the linked get-environments and get-environment pages, then compare how responses using anyOf or multiple response options are rendered. Done means each valid response produces a populated example instead of a null item, with coverage for the listed endpoints if tests are available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, react, typescript
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100