Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Use basePath in place of slug to avoid duplicate routes #173

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/docs/cos/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = [
link: {
type: "generated-index",
title: "Authentication",
slug: "/category/authentication",
slug: "/category/cos/authentication",
},
items: [
{
Expand All @@ -22,7 +22,7 @@ module.exports = [
link: {
type: "generated-index",
title: "Bucket operations",
slug: "/category/bucket-operations",
slug: "/category/cos/bucket-operations",
},
items: [
{
Expand Down
10 changes: 9 additions & 1 deletion demo/docs/petstore/login-user.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ import TabItem from "@theme/TabItem";

successful operation

</div><div><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><li><div><strong>string</strong></div></li></ul></details></div></TabItem><TabItem label={"400"} value={"400"}><div>
</div><details style={{"textAlign":"left"}} data-collaposed={false} open={true}><summary style={{}}><strong>Response Headers</strong></summary><ul style={{"marginLeft":"1rem"}}><li class={"schemaItem"}><summary style={{}}><strong>X-Rate-Limit</strong><span style={{"opacity":"0.6"}}> integer</span></summary><div><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>

calls per hour allowed by the user

</div></div></li><li class={"schemaItem"}><summary style={{}}><strong>X-Expires-After</strong><span style={{"opacity":"0.6"}}> string</span></summary><div><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>

date in UTC when token expires

</div></div></li></ul></details><div><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><li><div><strong>string</strong></div></li></ul></details></div></TabItem><TabItem label={"400"} value={"400"}><div>

Invalid username/password supplied

Expand Down
10 changes: 9 additions & 1 deletion demo/docs/petstore_versioned/login-user.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ import TabItem from "@theme/TabItem";

successful operation

</div><div><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><li><div><strong>string</strong></div></li></ul></details></div></TabItem><TabItem label={"400"} value={"400"}><div>
</div><details style={{"textAlign":"left"}} data-collaposed={false} open={true}><summary style={{}}><strong>Response Headers</strong></summary><ul style={{"marginLeft":"1rem"}}><li class={"schemaItem"}><summary style={{}}><strong>X-Rate-Limit</strong><span style={{"opacity":"0.6"}}> integer</span></summary><div><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>

calls per hour allowed by the user

</div></div></li><li class={"schemaItem"}><summary style={{}}><strong>X-Expires-After</strong><span style={{"opacity":"0.6"}}> string</span></summary><div><div style={{"marginTop":".5rem","marginBottom":".5rem"}}>

date in UTC when token expires

</div></div></li></ul></details><div><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><li><div><strong>string</strong></div></li></ul></details></div></TabItem><TabItem label={"400"} value={"400"}><div>

Invalid username/password supplied

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function createItems(
unversionedId: tagId,
title: description ?? "",
description: description ?? "",
slug: "/" + tagId,
frontMatter: {},
tag: {
...tag,
Expand All @@ -120,7 +119,6 @@ function createItems(
unversionedId: infoId,
title: openapiData.info.title,
description: openapiData.info.description,
slug: "/" + infoId,
frontMatter: {},
securitySchemes: openapiData.components?.securitySchemes,
info: {
Expand Down Expand Up @@ -184,7 +182,6 @@ function createItems(
unversionedId: baseId,
title: title,
description: description ?? "",
slug: "/" + baseId,
frontMatter: {},
api: {
...defaults,
Expand Down
6 changes: 4 additions & 2 deletions packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import path from "path";

import {
ProcessedSidebar,
SidebarItemCategory,
Expand Down Expand Up @@ -139,8 +141,8 @@ function groupByTags(
type: "generated-index" as "generated-index",
title: tag,
slug: label
? "/category/" + kebabCase(label) + "/" + kebabCase(tag)
: "/category/" + kebabCase(tag),
? path.join("/category", basePath, kebabCase(label), kebabCase(tag))
: path.join("/category", basePath, kebabCase(tag)),
} as SidebarItemCategoryLinkConfig;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-openapi-docs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface ApiMetadataBase {
description: string;
source: string; // @site aliased source => "@site/docs/folder/subFolder/subSubFolder/myDoc.md"
sourceDirName: string; // relative to the versioned docs folder (can be ".") => "folder/subFolder/subSubFolder"
slug: string;
slug?: string;
permalink: string;
sidebarPosition?: number;
frontMatter: Record<string, unknown>;
Expand Down