Skip to content
Closed
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
| `sidebarGenerators` | `object` | `null` | Optional: Customize sidebar rendering with callback functions. |

> You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.js` slice with the configured options will be generated within the respective `outputDir`.
> You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.ts` slice with the configured options will be generated within the respective `outputDir`.

`versions` can be configured with the following options:

| Name | Type | Default | Description |
| ------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of micro OpenAPI specification files. |
| `ouputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
| `outputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
| `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
| `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
| `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification for versioned. |
Expand Down
4 changes: 2 additions & 2 deletions demo/docs/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
| `sidebarGenerators` | `object` | `null` | Optional: Customize sidebar rendering with callback functions. |

> You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.js` slice with the configured options will be generated within the respective `outputDir`.
> You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.ts` slice with the configured options will be generated within the respective `outputDir`.

`versions` can be configured with the following options:

| Name | Type | Default | Description |
| ---------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of micro OpenAPI specification files. |
| `ouputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
| `outputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
| `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
| `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |

Expand Down
14 changes: 7 additions & 7 deletions packages/docusaurus-plugin-openapi-docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,16 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
| `sidebarGenerators` | `object` | `null` | Optional: Customize sidebar rendering with callback functions. |

> You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.js` slice with the configured options will be generated within the respective `outputDir`.
> You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.ts` slice with the configured options will be generated within the respective `outputDir`.

`versions` can be configured with the following options:

| Name | Type | Default | Description |
| ---------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of micro OpenAPI specification files. |
| `ouputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
| `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
| `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
| Name | Type | Default | Description |
| ----------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of micro OpenAPI specification files. |
| `outputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
| `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
| `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |

> All versions will automatically inherit `sidebarOptions` from the parent/base config.

Expand Down
14 changes: 10 additions & 4 deletions packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const createDocItem: ApiDocItemGenerator = (
);
return {
type: "doc" as const,
id: basePath === "" || undefined ? `${id}` : `${basePath}/${id}`,
id:
basePath === "" || basePath === undefined ? `${id}` : `${basePath}/${id}`,
label: (sidebar_label as string) ?? title ?? id,
customProps: customProps,
className: className ? className : undefined,
Expand Down Expand Up @@ -142,7 +143,10 @@ function groupByTags(
const id = infoItem.id;
rootIntroDoc = {
type: "doc" as const,
id: basePath === "" || undefined ? `${id}` : `${basePath}/${id}`,
id:
basePath === "" || basePath === undefined
? `${id}`
: `${basePath}/${id}`,
};
}

Expand All @@ -167,7 +171,7 @@ function groupByTags(
linkConfig = {
type: "doc",
id:
basePath === "" || undefined
basePath === "" || basePath === undefined
? `${taggedInfoObject.id}`
: `${basePath}/${taggedInfoObject.id}`,
} as SidebarItemCategoryLinkConfig;
Expand All @@ -179,7 +183,9 @@ function groupByTags(
linkConfig = {
type: "doc",
id:
basePath === "" || undefined ? `${tagId}` : `${basePath}/${tagId}`,
basePath === "" || basePath === undefined
? `${tagId}`
: `${basePath}/${tagId}`,
} as SidebarItemCategoryLinkConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import { guard } from "./utils";
import { guard, create, render } from "./utils";

describe("guard", () => {
it("should guard empty strings", () => {
Expand Down Expand Up @@ -47,3 +47,22 @@ describe("guard", () => {
expect(actual).toBe("true");
});
});

describe("create", () => {
it("should create element with props and children", () => {
const actual = create("div", { className: "x", children: "hello" });
expect(actual).toBe('<div className={"x"}>hello</div>');
});
});

describe("render", () => {
it("should render arrays while filtering undefined", () => {
const actual = render(["a", undefined, "b"]);
expect(actual).toBe("ab");
});

it("should render undefined as empty string", () => {
const actual = render(undefined);
expect(actual).toBe("");
});
});