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

zero-property JSON response object schema leads to MimeTabs/TabItem error

Open bnewbold opened this issue 1 year ago • 0 comments

Describe the bug

If I have a response JSON object with no fields, like:

        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
        }

then MDX generation succeeds, and npx docusaurus-mdx-checker passes, but when I actually build I get an error like:

Error: Docusaurus error: Bad <Tabs> child <TabItem>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.

The issue seems to be a <MimeTabs> MDX element with no body.

Expected behavior

Ideally the generated response section would show that the response must be mimetype application/json, and maybe that the body is supposed to be an object (eg, not a JSON string). But really anything would be fine as long as the docs could actually compile.

Current behavior

Fails to build, as described above.

Possible solution

Relevant code seems to be: https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/d2ff97b0ee8ec4da06348a1abcabe5ea8fe55eba/packages/docusaurus-plugin-openapi-docs/src/markdown/createResponseSchema.ts#L64

Steps to reproduce

(see above)

Context

This prevented building docs.bsky.app (https://github.com/bluesky-social/bsky-docs). Plan is to work around by creating a fake/bogus parameter _unknown_ so that the parameter list isn't empty.

Your Environment

  • Version used: docusaurus-plugin-openapi-docs v3.0.0-beta.10
  • Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): node v18.13.0 / npm 8.19.3
  • Operating System and version (desktop or mobile): debian linux amd64
  • Link to your project: https://github.com/bluesky-social/bsky-docs

bnewbold avatar Apr 30 '24 00:04 bnewbold