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

Adding second API reference to sidebar results in Hook usedoc error

Open cdstull opened this issue 1 year ago • 2 comments

Describe the bug

When I add a second API reference to my site it results in a "Hook useDocsVersion is called outside the <DocsVersionProvider>.

Expected behavior

Both API references should be on the sidebar.

Current behavior

The files generate from the spec but the moment I add a second API ref to my sidebars.ts the site breaks. When I comment one API ref out of sidebars.ts the error stops and the site works again. Each API reference works individually, just not together.

Possible solution

I'm assuming this is a compatibility issue with Docusaurus 3. I've tried every combination of Docusaurus 3.0.0 and after with every combination of the plugin beta 3.0.0.-beta1 and after and I've gotten the same result every time.

Steps to reproduce

  1. Use a second spec and generate the files in another directory
  2. Add the second API reference to the sidebar file
  3. Site crashes

Screenshots

adding second api ref to sidebar

Hook error

sidebars commented out

If I comment one API ref out, then the site works. This is true regardless of which API ref I comment out.

Context

Need two distinct API references on the same sidebar.

Your Environment

  • Version used: Docusaurus 3.0.0 and docusaurus-plugin-openapi-docs 3.0.0-beta.1; also tried with the latest Docusaurus and the latest plugin beta and get same results
  • Environment name and version:
  • Operating System and version: macOS 14.3
  • Link to your project: not yet public

cdstull avatar Feb 22 '24 13:02 cdstull

Hi @cdstull, thanks for opening the issue. Given the information provided I'm not sure what the issue could be. FWIW, we currently build/deploy a Docusaurus v3 site and plugin with multiple specs referenced in a single sidebar:

Preview: https://docusaurus-openapi-36b86--pr660-knd150qi.web.app/category/petstore-api PR: https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/660

sserrata avatar Mar 12 '24 14:03 sserrata

Same issue here when using the beta.10 version along with core 3.1.1 and using a 2nd docs plugin to host the apis.

johnrengelman avatar Mar 29 '24 01:03 johnrengelman

This error is typically associated with mismatched docusaurus dependency versions. I recommend triple checking to ensure all dep versions are in alignment and reinstalling deps after cleaning node_modules and lock file.

sserrata avatar Jun 28 '24 18:06 sserrata