rohit-gohri / redocusaurus

OpenAPI for Docusaurus with Redoc
https://redocusaurus.vercel.app/
MIT License
629 stars 114 forks source link

Error: "presets[0]" does not match any of the allowed types #297

Closed clarkmcc closed 1 year ago

clarkmcc commented 1 year ago

I'm not able to get this working in my documentation site. It's weird that it says that presets[0] is the problem even though it works if I remove the redocusaurus one. Also I get the same error if I remove the existing presets.

I have Docusaurus 2.4.0 and my documentation site is available here: https://github.com/printtracker/docs

{
    presets: [
    [
      // Existing presets
      "classic",
      /** @type {import('@docusaurus/preset-classic').Options} */
      ({
        docs: {
          sidebarPath: require.resolve("./sidebars.js"),
          sidebarCollapsible: false,
        },
        blog: {
          showReadingTime: true,
        },
        theme: {
          customCss: require.resolve("./src/css/custom.css"),
        },
      }),

      // New presets
      "@docusaurus/preset-classic",
      [
        "redocusaurus",
        {
          specs: [
            {
              spec: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml",
              route: "/api/",
            },
          ],
          theme: {
            primaryColor: "#1890ff",
          },
        },
      ],
    ],
  ],
}
GlenMasters commented 1 year ago

I had a similar issue. Had another look at the layout and realised my redocusaurus was one tier too deep. (I also had to comment out the 'classic' to get the '@docusaurus/preset-classic', to be accepted.) Hope that helps

rohit-gohri commented 1 year ago

I think you can remove this part, if you already have classic in there

      // New presets
      "@docusaurus/preset-classic",`