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

Add infoPath to apiItem

Open omonk opened this issue 1 year ago • 2 comments

Description

To be really honest I'm finding it very hard to follow a lot of the inner workings of this plugin.

I am attempting to replicate the authorization section in my local schema. There is only one security schema in my schema but the plugin choses not to render anything in the ApiItem component but it does in the ApiExplorer

This line is the offending culprit https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/markdown/index.ts#L84

I've seen for some reason the API item doesn't have an infoPath so this change adds the info path and renders the auth item appropriately in my project.

Perhaps you could help explain why?

This line picks out info_path of MDX frontmatter and passes it to the ApiExplorer. Unfortunately at that point the MDX for the main ApiItem has been compiled.

Motivation and Context

How Has This Been Tested?

Locally

Screenshots (if appropriate)

image

Types of changes

  • Bug fix?

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.

omonk avatar Sep 16 '24 11:09 omonk

Hi @omonk, thanks for reporting this issue. Definitely seems like some cleanup is in order here, at least the component names are not intuitive.

If I'm understanding correctly, you want the "authorization" component to render both inside the ApiItem and ApiExplorer components? I think we used to render it under ApiItem, before our last major redesign.

  • I don't think infoId and infoPath are the same values but I'll double check. It matters because the infoPath is what's used to generate the links to the correct security scheme tab under the generated info doc.
  • It looks like we may have forgotten to clean up the createAuthorization under createApiPageMD but I'll double check.

Either way, it should be possible to achieve what you're asking for, i.e. with a custom markdownGenerators function. I'll look through to see what if anything we can clean up.

sserrata avatar Sep 16 '24 14:09 sserrata

If I'm understanding correctly, you want the "authorization" component to render both inside the ApiItem and ApiExplorer components?

Yep exactly, it looks as though this was the case previously as the main API template has this template condition as I mentioned.

I don't think there needs to be a custom markdown generator, just passing the infoPath to the API item that i passed around to the markdown generators is enough.

Lots of as any make things quite tricky to parse 😬

omonk avatar Sep 16 '24 15:09 omonk