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

Issue when using tag groups

Open Kkundan opened this issue 1 year ago • 11 comments

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

image

  • Link to project: https://github.com/saviynt/developer-portal
  • Version : [email protected]

Kkundan avatar Apr 02 '24 18:04 Kkundan

@bencagri, any idea why this might be occurring?

sserrata avatar Apr 04 '24 11:04 sserrata

hi @Kkundan , have you tried to rebuild the docs with clean-api and gen-api commands?

bencagri avatar Apr 04 '24 11:04 bencagri

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

Kkundan avatar Apr 04 '24 16:04 Kkundan

this is weird, i reproduced with the given file aviynt-eic-api-5.0.yaml. here how it looks on my local.

Screenshot 2024-04-05 at 11 43 07

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-docs in docusaurus.config.js
  • run clean-api-docs and gen-api-docs commands
  • run yarn start

and i can see the results.

bencagri avatar Apr 05 '24 08:04 bencagri

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 ?

Kkundan avatar Apr 05 '24 19:04 Kkundan

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 avatar Apr 10 '24 07:04 stakoov

@stakoov I have delete them and regenerated but still the same issue

Kkundan avatar Apr 10 '24 14:04 Kkundan

@stakoov @bencagri would appreciate if you can extend some help , I tried all options but I am unable to make it work

Kkundan avatar Apr 15 '24 04:04 Kkundan

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.

bencagri avatar Apr 15 '24 16:04 bencagri

Hi @Kkundan I will investigate this one later this week.

stakoov avatar Apr 16 '24 13:04 stakoov

@stakoov I see the same issue in your tryingpan app : https://docusaurus-openapi.tryingpan.dev/category/restaurant-api

docusaurus-openapi-docs-issue

Kkundan avatar Apr 22 '24 14:04 Kkundan

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?

ElliotFriend avatar Jun 08 '24 01:06 ElliotFriend

Made some PRs to address this one: #854 and #853

ElliotFriend avatar Jun 26 '24 22:06 ElliotFriend