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

Fix language check

Open browniefed opened this issue 1 year ago • 4 comments

Description

This seemed to be breaking on docusaurus v3.2.0

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • [ ] I have updated the documentation accordingly.
  • [ ] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes if appropriate.
  • [ ] All new and existing tests passed.

browniefed avatar Apr 03 '24 20:04 browniefed

Hi @browniefed, I just tried upgrading to Docusaurus 3.2.0 using a test site and was not able to reproduce the error you described - it worked as expected the first time. Can you provide steps to reproduce the error along with additional context?

sserrata avatar Apr 04 '24 11:04 sserrata

Hi @browniefed, I just tried upgrading to Docusaurus 3.2.0 using a test site and was not able to reproduce the error you described - it worked as expected the first time. Can you provide steps to reproduce the error along with additional context?

I'm not certain exactly what the setup is, but I would assume some of our code samples aren't getting annotated and thus a language isn't being chosen?

If you look here https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/794/files#diff-d540d718a2f059832b0aa4da83589d1c6ec8110b6758874abed3da6ab8747943R333

Literally after my language && check there is a check for if the language is null, so it clearly has a possibility of being null.

Same with other useEffects in the file.

https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/575c6a7c11660427001591609135e266723bb132/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx#L208

So I am happy to take a moment to spin up a repro, it would be nice to have this just matching all of the other code in the file.

The other option is just move the null check on language above the thing I did and I think that would then solve the problem.

browniefed avatar Apr 04 '24 14:04 browniefed

Adding a safety check is low risk but I would prefer to reproduce the error so I can validate the fix. Can you provide a copy of the OpenAPI spec or a snippet?

sserrata avatar Apr 04 '24 14:04 sserrata

@sserrata here is the swagger.json file we use to generate https://gist.github.com/browniefed/4dd6cb7f6fbfe295ad6be59506f3cc5d

If you can't repro then I can attempt to set something up later.

When I was running v3.1.1 of docusaurus I got a useDoc hook issue for non-openapi created pages seemingly. Then on v3.2.0 everything was working, minus this language.sampels thing.

browniefed avatar Apr 04 '24 18:04 browniefed

Hi @browniefed, I've been unable to reproduce, even with the provided spec on Docusaurus 3.3.2. I'm moving to close this PR but if you're able to provide updated repro instructions feel free to reopen as an issue. Thanks!

sserrata avatar May 14 '24 14:05 sserrata