Surnet / swagger-jsdoc

Generates swagger/openapi specification based on jsDoc comments and YAML files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError when using swagger-jsdoc with lint-staged installed

aruberutochan opened this issue · comments

Describe the bug
Encountering a TypeError when trying to use the swagger-jsdoc library in a project where lint-staged is also installed. The error occurs during the execution of the project, specifically when building the Swagger specification files. The error does not appear when lint-staged is uninstalled.
This is the error that i see:

/home/aruberuto/projects/comuncity/code/swagger-jsdoc-lint-staged/node_modules/swagger-jsdoc/src/specification.js:187
YAML.defaultOptions.keepCstNodes = true;
^
TypeError: Cannot set properties of undefined (setting 'keepCstNodes')
at build (/home/aruberuto/projects/comuncity/code/swagger-jsdoc-lint-staged/node_modules/swagger-jsdoc/src/specification.js:187:36)
at module.exports (/home/aruberuto/projects/comuncity/code/swagger-jsdoc-lint-staged/node_modules/swagger-jsdoc/src/lib.js:32:10)
at Object.<anonymous> (/home/aruberuto/projects/comuncity/code/swagger-jsdoc-lint-staged/src/index.ts:14:26)

To Reproduce the error with lint-staged

  1. Clone the repository from this link.
  2. Install dependencies using npm install.
  3. Run the project with npm start.
  4. You should see the error in the terminal.

No error after removing lint-staged

  1. Clone the repository from this link.
  2. Install dependencies using npm install.
  3. Remove lint-staged using npm remove lint-staged
  4. Run the project with npm start.
  5. You should see the log in the terminal with the generated documentation in json.

Expected behavior
The project should start without errors when using the lint-staged library, and the Swagger documentation should be built successfully.

Desktop:

  • OS: Pop!_OS 22.04 LTS
  • Node version: v20.9.0
  • npm version: 10.2.24

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.