Surnet / swagger-jsdoc

Generates swagger/openapi specification based on jsDoc comments and YAML files.
MIT License
1.66k stars 224 forks source link

TypeError when using swagger-jsdoc with lint-staged installed #395

Closed aruberutochan closed 1 week ago

aruberutochan commented 2 months ago

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:

stale[bot] commented 2 weeks ago

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.