Skip to content

Getting TypeError: Cannot read properties of undefined (reading 'endsWith') for all yaml and json files #1085

@lavs9

Description

@lavs9

I have 4-5 yaml/json files which I have been trying to import into docusaurus using the plugin but every time I get this issue when I run gen-api-docs command.

Error

[ERROR] TypeError: Cannot read properties of undefined (reading 'endsWith')
    at createItems (/Users/mayanklavania/projects/sample-docu-setup/node_modules/docusaurus-plugin-openapi-docs/lib/openapi/openapi.js:155:41)
    at processOpenapiFile (/Users/mayanklavania/projects/sample-docu-setup/node_modules/docusaurus-plugin-openapi-docs/lib/openapi/openapi.js:514:19)
    at async /Users/mayanklavania/projects/sample-docu-setup/node_modules/docusaurus-plugin-openapi-docs/lib/openapi/openapi.js:468:35
    at async Promise.all (index 0)
    at async processOpenapiFiles (/Users/mayanklavania/projects/sample-docu-setup/node_modules/docusaurus-plugin-openapi-docs/lib/openapi/openapi.js:479:22)
    at async generateApiDocs (/Users/mayanklavania/projects/sample-docu-setup/node_modules/docusaurus-plugin-openapi-docs/lib/index.js:95:44)
    at async Command.<anonymous> (/Users/mayanklavania/projects/sample-docu-setup/node_modules/docusaurus-plugin-openapi-docs/lib/index.js:511:11)
    at async Promise.all (index 0)
    at async runCLI (/Users/mayanklavania/projects/sample-docu-setup/node_modules/@docusaurus/core/lib/commands/cli.js:56:5)
    at async file:///Users/mayanklavania/projects/sample-docu-setup/node_modules/@docusaurus/core/bin/docusaurus.mjs:44:3
[INFO] Docusaurus version: 3.7.0
Node version: v23.6.0

Sample JSON file attached.

Please note that this JSON and other YAML files import absolutely fine into redocly plugin and I also see no issues in swagger editor.

when I try to import the pet store yaml it works fine with no issues so I do not see an issue in integration as such.

If someone can guide me how to resolve this issue it will be of great help as I want to use the plugin and not redocly extension.

Here is the snippet of plugin version
"docusaurus-plugin-openapi-docs": "^4.3.4",
"docusaurus-theme-openapi-docs": "^4.3.4",

The snippet of config file

plugins: [
    [
      'docusaurus-plugin-openapi-docs',
      {
        id: 'omex',
        docsPluginId: 'classic',
        config: {
          omex: {
            specPath: 'static/api-specs/odinconnector.json',
            outputDir: 'docs/omex/api-reference',
            sidebarOptions: {
              groupPathsBy: 'tag',
            },
          } satisfies OpenApiPlugin.Options,
        },
      },
    ],
  ],

  themes: 
    [
      'docusaurus-theme-openapi-docs',
    ],

odinconnector.json

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions