docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

Free object ( additionalProperties: true ) in a oneOf did not render

Open marco10024 opened this issue 1 year ago • 2 comments

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 :

Capture d’écran 2024-02-07 à 09 30 50

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

Capture d’écran 2024-02-07 à 09 36 32 Capture d’écran 2024-02-07 à 09 36 55

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:

marco10024 avatar Feb 07 '24 08:02 marco10024

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.

sserrata avatar Mar 12 '24 15:03 sserrata

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",

marco10024 avatar Mar 12 '24 15:03 marco10024

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!

sserrata avatar Jun 28 '24 18:06 sserrata