docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
Files get generated but immediately errors saying my sidebar is invalid
Describe the bug
I'm trying to implement an API reference page on my docs. I have multiple yaml files and am trying to bring the all into my docs in the same page.
I have added the plugin the following way:
plugins: [
[
'docusaurus-plugin-openapi-docs',
{
id: "apiDocs",
docsPluginId: "api",
config: {
account: {
specPath: "openapi/openapi/yaml/account.yaml",
outputDir: "api/account",
sidebarOptions: {
groupPathsBy: "tag",
},
},
accounts: {
specPath: "openapi/openapi/yaml/accounts.yaml",
outputDir: "api/accounts",
sidebarOptions: {
groupPathsBy: "tag",
},
}
}
},
],
[
'@docusaurus/plugin-content-docs',
{
id: 'api',
path: 'api',
routeBasePath: 'reference',
sidebarPath: require.resolve('./sidebars.js'),
showLastUpdateTime: true,
showLastUpdateAuthor: true,
sidebarCollapsible: true,
sidebarCollapsed: true,
},
],
],
themes: ["docusaurus-theme-openapi-docs"], // Allows use of @theme/ApiItem and other components
And modified my sidebar to the following:
myapi: [
{
type: "category",
label: "Account API",
link: {
type: "generated-index",
title: "Account API",
slug: "reference/account",
},
items: require("./api/account/sidebar.js"),
},
{
type: "category",
label: "Accounts API",
link: {
type: "generated-index",
title: "Accounts API",
slug: "reference/accounts",
},
items: require("./api/accounts/sidebar.js"),
}
]
Expected behavior
Current behavior
adding the items: require("./api/account/sidebar.js"),
Immediately throws the following into my ide:
Type '({ type: string; id: string; } | { type: string; label: string; link: { type: string; title: string; slug: string; }; items: { type: string; id: string; label: string; className: string; }[]; })[]' is not assignable to type 'SidebarCategoriesShorthand | SidebarItemConfig[]'.
I thought it may be because the files hadn't been generated. So I run yarn gen-all && docusaurus start and the files get generated, but it immediately errors

Context
One of the generated sidebar.js files looks like this:
module.exports = [{"type":"doc","id":"accounts/accounts-api"},{"type":"category","label":"Wallets","link":{"type":"generated-index","title":"Wallets","slug":"/category/accounts/wallets"},"items":[{"type":"doc","id":"accounts/create-wallet","label":"Create a wallet","className":"api-method post"},{"type":"doc","id":"accounts/list-wallets","label":"List all wallets","className":"api-method get"},{"type":"doc","id":"accounts/get-wallet","label":"Get a wallet","className":"api-method get"},{"type":"doc","id":"accounts/generate-address","label":"Create a blockchain address","className":"api-method post"},{"type":"doc","id":"accounts/list-addresses","label":"List all addresses","className":"api-method get"}]},{"type":"category","label":"Transfers","link":{"type":"generated-index","title":"Transfers","slug":"/category/accounts/transfers"},"items":[{"type":"doc","id":"accounts/create-transfer","label":"Create a transfer","className":"api-method post"},{"type":"doc","id":"accounts/list-transfers","label":"List all transfers","className":"api-method get"},{"type":"doc","id":"accounts/get-transfer","label":"Get a transfer","className":"api-method get"}]}];
Your Environment
- Version used: Docusaurus version: 2.2.0, Node version: v18.13.0
- Operating System and version (desktop or mobile): Mac OS
Any help appreciated
:tada: Thanks for opening your first issue here! Welcome to the community!
Hi @mplacona, can you provide a link to a reproduction of the issue you're seeing?
I am having the same issue, but it reproduces only when I add custom template to the docusaurus config
P.S. Resolved. Had a problem with my template