docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
Error: => Bad Docusaurus theme value themes[0]
Describe the bug
When i am using docusaurus-search-local plugin with theme i am getting this error.i am not able to implement any search with this plugin. Local search pulgin - https://github.com/easyops-cn/docusaurus-search-local#readme
Expected behavior
The search plugin should work without any error when we are adding in theme.
Current behavior
Steps to reproduce
// @ts-check // Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
const { startTransition } = require("react");
/** @type {import('@docusaurus/types').Config} */
const config = {
title: "My Site",
tagline: "Dinosaurs are cool",
url: "https://your-docusaurus-test-site.com",
baseUrl: "/",
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.ico",
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: "facebook", // Usually your GitHub org/user name.
projectName: "docusaurus", // Usually your repo name.
presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve("./sidebars.js"),
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
docLayoutComponent: "@theme/DocPage",
docItemComponent: "@theme/ApiItem", // Derived from docusaurus-theme-openapi
},
blog: {
showReadingTime: true,
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
},
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
docs: {
sidebar: {
hideable: true,
},
},
navbar: {
title: "My Site",
logo: {
alt: "My Site Logo",
src: "img/logo.svg",
},
items: [
{
type: "doc",
docId: "intro",
position: "left",
label: "Tutorial",
},
{ to: "/blog", label: "Blog", position: "left" },
{
label: "Petstore API",
position: "left",
to: "/docs/category/petstore-api",
},
{
href: "https://github.com/facebook/docusaurus",
label: "GitHub",
position: "right",
},
],
},
footer: {
style: "dark",
links: [
{
title: "Docs",
items: [
{
label: "Tutorial",
to: "/docs/intro",
},
],
},
{
title: "Community",
items: [
{
label: "Stack Overflow",
href: "https://stackoverflow.com/questions/tagged/docusaurus",
},
{
label: "Discord",
href: "https://discordapp.com/invite/docusaurus",
},
{
label: "Twitter",
href: "https://twitter.com/docusaurus",
},
],
},
{
title: "More",
items: [
{
label: "Blog",
to: "/blog",
},
{
label: "GitHub",
href: "https://github.com/facebook/docusaurus",
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ["ruby", "csharp", "php"],
},
}),
plugins: [
[
"docusaurus-plugin-openapi-docs",
{
id: "openapi",
docsPluginId: "classic",
config: {
petstore: {
specPath: "examples/petstore.yaml",
outputDir: "docs/petstore",
downloadUrl:
"https://raw.githubusercontent.com/PaloAltoNetworks/docusaurus-template-openapi-docs/main/examples/petstore.yaml",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "tag",
},
},
},
},
],
],
themes: [
["docusaurus-theme-openapi-docs"],
[
"@easyops-cn/docusaurus-search-local",
{
hashed: true,
language: ["en"],
highlightSearchTermsOnTargetPage: true,
explicitSearchResultPath: true,
},
],
],
};
module.exports = config;
Package.json
{
"name": "dev-hub-v-3",
"version": "0.0.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"gen-api-docs": "docusaurus gen-api-docs",
"clean-api-docs": "docusaurus clean-api-docs",
"gen-api-docs:version": "docusaurus gen-api-docs:version",
"clean-api-docs:version": "docusaurus clean-api-docs:version"
},
"dependencies": {
"@docusaurus/core": ">=2.4.1 <=2.4.3",
"@docusaurus/preset-classic": ">=2.4.1 <=2.4.3",
"@mdx-js/react": "^1.6.22",
"clsx": "^1.1.1",
"docusaurus-plugin-openapi-docs": "2.0.0",
"docusaurus-theme-openapi-docs": "2.0.0",
"prism-react-renderer": "^1.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@easyops-cn/docusaurus-search-local": ">= 0.16.0"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Screenshots
Context
Your Environment
- Version used:
- Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3):
- Operating System and version (desktop or mobile):
- Link to your project:
@gauravverma029 Where you able to resolve it? Facing the same issue.
same here
FWIW this is a docusaurus restriction on the expected format for multiple themes. To address it I simply followed the guidance provided by the error and included some empty options:
themes: [["docusaurus-theme-openapi-docs", {}]],