docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
Issue when using tag groups
Describe the bug
I have used tagGroup to group paths in the side bar. However instead of grouping specific paths, it is grouping all paths in every group.
[ "docusaurus-plugin-openapi-docs", { id: "openapi", docsPluginId: "classic", config: { saviynt:{ specPath: "static/api-specs/saviynt-eic-api-5.0.yaml", outputDir: "docs/eic/", sidebarOptions: { groupPathsBy: "tagGroup", // categoryLinkSource: "tag", }, version: "5.0.0", // Current version label: "v5.0.0", // Current version label baseUrl: "/developer-portal/eic/rest/5.0", // Leading slash is important versions: { "2.0.0": { specPath: "static/api-specs/saviynt-eic-api-2.0.yaml", outputDir: "docs/eic/2.0", // No trailing slash label: "v2.0.0", baseUrl: "/developer-portal/eic/rest/2.0", // Leading slash is important }, }, } satisfies OpenApiPlugin.Options, } satisfies Plugin.PluginOptions, }, ], ],
Expected behavior
I should only group specific path listed under the tagGroup
Current behavior
It is grouping all paths
Possible solution
Steps to reproduce
-
OpenAPI Spec: https://github.com/saviynt/developer-portal/blob/main/static/api-specs/saviynt-eic-api-5.0.yaml
-
Generated Doc: https://saviynt.github.io/developer-portal/
Screenshots
- Link to project: https://github.com/saviynt/developer-portal
- Version : [email protected]
@bencagri, any idea why this might be occurring?
hi @Kkundan , have you tried to rebuild the docs with clean-api and gen-api commands?
Hi @bencagri : I have tried yarn docusaurus clean-api-docs all and yarn docusaurus clean-api-docs:version saviynt:all. I have also tried manually deleting doc folder contents
this is weird, i reproduced with the given file aviynt-eic-api-5.0.yaml. here how it looks on my local.
but i realized, in your source x-displayName of tags is null. this is not a big deal, but if you put the key, you should also provide the value. I remember, somewhere in the code this value is checked.
on the other hand; this is the config i used if it could be a reference;
savyint: {
specPath: "open-api-specs/savyint.yaml",
outputDir: "docs/savyint",
sidebarOptions: {
groupPathsBy: "tagGroup",
categoryLinkSource: "auto",
}
},
Steps to reproduce; (plugin version 2.1.3)
- download the source yaml
- add values to sidebars.js under
openApiSidebar - add plugin config under
docusaurus-plugin-openapi-docsindocusaurus.config.js - run
clean-api-docsandgen-api-docscommands - run
yarn start
and i can see the results.
thanks @bencagri but I am actually currently using 3.0.0-beta.10 and not 2.1.3 . do you see the same result in that version too ?
The issue might be the yarn docusaurus clean-api-docs all not deleting the sidebar.js (.ts) and for some reason in version 3.0 (not sure what is behivier in versino 2.0) when gen-api-docs it's not regenerated.
@Kkundan can you delete the docs/open-api/sidebar.js/ts
@stakoov I have delete them and regenerated but still the same issue
@stakoov @bencagri would appreciate if you can extend some help , I tried all options but I am unable to make it work
Hello @Kkundan , unfortunately I do have a busy schedule to check this up with 3.0-beta tag. I will take a glance as soon as I can.
Hi @Kkundan I will investigate this one later this week.
@stakoov I see the same issue in your tryingpan app : https://docusaurus-openapi.tryingpan.dev/category/restaurant-api
I poked around a bit in my local node_modules, using the v3.0.0-beta.10 release, I think this bug was introduced in commit 9cc7cf563f098bb4bf17ab6c6bc25b467b1307e7. I don't really have the context about what problem that commit fixed, but I think a solution might be to wrap that particular line in a check like this:
if (sidebarOptions.groupPathsBy !== "tagGroup") {
apiTags = uniq(apiTags.concat(operationTags));
}
@Kkundan @stakoov Maybe that could help with your troubleshooting?
Made some PRs to address this one: #854 and #853