rohit-gohri / redocusaurus

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

Error: Docusaurus server-side rendering could not render static page with path /api/ because of error: slugify: string argument expected #325

Closed pcboy closed 9 months ago

pcboy commented 10 months ago

I have a strange compilation issue when redocusaurus is set up in my project.

A docusaurus build gives me:

[INFO] [en] Creating an optimized production build...

✔ Client

✖ Server
  Compiled with some errors in 50.56s

Error: Docusaurus server-side rendering could not render static page with path /api/ because of error: slugify: string argument expected
    at serverEntry_render (main:44556:358)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at process.processImmediate (node:internal/timers:449:9)
    at async /home/pcboy/company/docs/project/node_modules/p-map/index.js:57:22 {
  [cause]: Error: slugify: string argument expected
      at replace (main:200408:13)
      at w (main:182415:102221)
      at new Mo (main:182454:81653)
      at Zo.getTagsItems (main:182454:83889)
      at Zo.buildStructure (main:182454:83130)
      at new Do (main:182454:81080)
      at new uc (main:183733:3247)
      at main:47927:409
      at Object.Ic [as useMemo] (main:178353:240)
      at exports.useMemo (main:182379:208)
}

Error: Unable to build website for locale en.
    at tryToBuildLocale (/home/pcboy/company/project/docs/project/node_modules/@docusaurus/core/lib/commands/build.js:55:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async mapAsyncSequential (/home/pcboy/company/project/docs/project/node_modules/@docusaurus/utils/lib/jsUtils.js:44:24)
    at async Command.build (/home/pcboy/company/project/docs/project/node_modules/@docusaurus/core/lib/commands/build.js:82:21) {
  [cause]: Error: Failed to compile due to Webpack errors.
  Error: Docusaurus server-side rendering could not render static page with path /api/ because of error: slugify: string argument expected
      at /home/pcboy/company/project/docs/project/node_modules/@docusaurus/core/lib/webpack/utils.js:207:24
      at /home/pcboy/company/project/docs/project/node_modules/webpack/lib/MultiCompiler.js:554:14
      at processQueueWorker (/home/pcboy/company/project/docs/project/node_modules/webpack/lib/MultiCompiler.js:491:6)
      at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
}

[INFO] Docusaurus version: 3.1.0
Node version: v20.10.0

Versions:

[INFO] Docusaurus version: 3.1.0  
Node version: v20.10.0  
Redocusaurus: 2.0.0

package.json deps

{
  "dependencies": {
    "@cmfcmf/docusaurus-search-local": "^0.6.7",
    "@docusaurus/core": "^3.0.0",
    "@docusaurus/preset-classic": "^3.0.0",
    "@docusaurus/theme-common": "^3.0.0",
    "@docusaurus/utils": "^3.0.0",
    "@mdx-js/react": "^3.0",
    "@svgr/webpack": "^5.5.0",
    "clsx": "^1.1.1",
    "file-loader": "^6.2.0",
    "mermaid": "^9.3.0",
    "prism-react-renderer": "^1.2.1",
    "raw-loader": "^4.0.2",
    "react": "^18.0.1",
    "react-dom": "^18.0.1",
    "react-icons": "^4.3.1",
    "redocusaurus": "^2.0.0",
    "url-loader": "^4.1.1"
  },
  "devDependencies": {
    "@docusaurus/module-type-aliases": "^3.1.0",
    "@docusaurus/types": "^3.1.0",
    "@quobix/vacuum": "^0.7.0",
    "@tsconfig/docusaurus": "^2.0",
    "@types/react": ">=16",
    "typescript": "^5.2.2",
    "webpack": "^5.0.0"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "pnpm": {
    "packageExtensions": {
      "docusaurus-theme-redoc": {
        "peerDependencies": {
          "webpack": "^5.89.0"
        }
      }
    }
  }
}

redocusaurus config:

    [
      "redocusaurus",
      {
        specs: [
          {
            spec: "./static/openapi.yml",
            route: "/api/",
          },
        ],
      },
    ],

If I completely remove redocusaurus from the presets array of my config, then it compiles. Any idea?

rohit-gohri commented 9 months ago

Could you try with the default petstore openapi yaml? Or share your spec that causes the errors?

pcboy commented 9 months ago

@rohit-gohri Indeed, it seems to be building fine with the OpenAPI petstore yaml.

After more investigation in my openapi.yml, I found one duplicate key in the paths. After removing it, it compiles fine.

Thanks for the help. :+1: