docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
Free object ( additionalProperties: true ) in a oneOf did not render
Describe the bug
An error occurs when I have an entity whose property contains a oneOf referring to another entity of type free (additionalProperties to true)
Example :
{
"$id": "User",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"email": {
"type": "string"
},
"parent": {
"oneOf": [
{
"$ref": "FreeObject#"
},
{
"type": "null"
}
]
}
}
{
"$id": "FreeObject",
"type": "object",
"additionalProperties": true
}
Expected behavior
the FreeObject entity should in this case generate a property name* any at the rendering level :
Current behavior
The command to generate the doc goes well ( docusaurus gen-api-docs all ). On the other hand, in this case it generates an empty <SchemaTabs></SchemaTabs> which then causes a build error
Screenshots
Context
Your Environment
- Version used: 2.0.4 and docusaurus 2.4.3
- Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): nodeJs 20
- Operating System and version (desktop or mobile): macOS
- Link to your project:
Hi @marco10024, thanks for reporting. Seems like an edge case we didn't account for, i.e. a oneOf/anyOf with a nested additionalProperties object. I'll see if I can get to it or hopefully someone in the community can lend a hand.
Hello @sserrata , thank you for your answer. yes it's a bit of a special case, I hope it will be easy to manage on your side. for the moment I patched this with a sed once the doc is generated if it can help other people in my case:
"fix": "sed -i 's/<SchemaTabs><\\/SchemaTabs>/<div style={{\"marginLeft\":\"1rem\"}}><SchemaItem name={\"property name*\"} required={false} schemaName={\"any\"} qualifierMessage={undefined} schema={{\"type\":\"object\",\"additionalProperties\":true}} collapsible={false} discriminator={false}><\\/SchemaItem><\\/div>/g' ./docs/api/*.mdx",
"generate-api-docs": "docusaurus gen-api-docs all && npm run fix",
Hi @marco10024, I believe this issue has been resolved with recent changes. Much appreciated if you could test 0.0.0-730 canary release - please reopen this issue if needed. Thanks!