cloud-annotations / docusaurus-openapi

🦕 OpenAPI plugin for generating API reference docs in Docusaurus v2.
https://docusaurus-openapi.netlify.app
MIT License
505 stars 82 forks source link

Navigation does not work in 'api' only mode #162

Open olufotebig opened 2 years ago

olufotebig commented 2 years ago

Summary

I want to use docusaurus-openapi to generate a docs only website from a swagger file, but navigation does not work.

Steps to reproduce

Bootstrap a new project with npx create-docusaurus-openapi my-website Remove the src/pages/index.js file. Change the preset block in docusaurus.config.js to the code below:

presets: [
    [
        "docusaurus-preset-openapi",
        /** @type {import('docusaurus-preset-openapi').Options} */
        ({
            api: {
                routeBasePath: '/',
            },
            blog: false,
            pages: false,
            docs: false,
            debug: false,
            theme: {
                customCss: require.resolve("./src/css/custom.css"),
            },
        }),
    ],
]

Observation

Clicking on links in the sidebar changes the url routes in the browser address bar but not the content on the page.

Root cause

I noticed that in .docusaurus/routes,js, we have the code below:

routes: [
      {
        path: '',
        component: ComponentCreator('','1f6'),
        exact: true,
        'sidebar': "openapi-sidebar-default"
      },

If the above is changed to

routes: [
      {
        path: '/',
        component: ComponentCreator('','1f6'),
        exact: true,
        'sidebar': "openapi-sidebar-default"
      },

Then the navigation works again.

From my short investigation the root cause seems to be here.

Thanks.

bourdakos1 commented 2 years ago

Thanks @olufotebig, I will try to reproduce