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

Allow more than one x-codeSample

Open tjperry07 opened this issue 7 months ago • 0 comments

Is your feature request related to a problem?

While x-codeSamples does work, you can only have one per language. Otherwise you get a

Docusaurus error: Duplicate values "PowerShell, PowerShell" found in <Tabs>. Every value needs to be unique.

or whatever language you're using.

Describe the solution you'd like

The ability to have multiple x-codeSamples of the same language on an endpoint.

        "x-codeSamples": [
          {
            "lang": "Python",
            "label": "KeyPair Auth",
            "source": {
              "$ref": "./code-samples/rerun/python_requests_keypair.py"
            }
          },
          {
            "lang": "Python",
            "label": "Basic Auth",
            "source": {
              "$ref": "./code-samples/rerun/python_requests_basic.py"
            }
          },
          {
            "lang": "Python",
            "label": "OAuth",
            "source": {
              "$ref": "./code-samples/rerun/python_requests_oauth.py"
            }
          },
          {
            "lang": "PowerShell",
            "label": "KeyPair Auth",
            "source": {
              "$ref": "./code-samples/rerun/powershell_keypair.ps1"
            }
          },
          {
            "lang": "PowerShell",
            "label": "OAuth",
            "source": {
              "$ref": "./code-samples/rerun/powershell_oauth.ps1"
            }
          },
          {
            "lang": "PowerShell",
            "label": "Basic Auth",
            "source": {
              "$ref": "./code-samples/rerun/powershell_basic.ps1"
            }
          }
        ],

Describe alternatives you've considered

I have a workaround already mentioned in https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/1036. I spun up a clean version without any workarounds to test x-CodeSamples.

Additional context

"docusaurus-plugin-openapi-docs": "^4.5.1",
"docusaurus-theme-openapi-docs": "^4.5.1",
"@docusaurus/preset-classic": "^3.7.0",

tjperry07 avatar Jul 10 '25 19:07 tjperry07