Surnet / swagger-jsdoc

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Globbing a directory that looks like a file causes crash.

Lomilar opened this issue · comments

Describe the bug
Globbing a directory in the apis causes a crash in the swagger module.

To Reproduce

swaggerJsdoc({
    apis: ['./src/**/*.js'],
})

When the above code is used and comes across a node_modules that includes asn1.js (https://www.npmjs.com/package/asn1.js), a crash occurs.

Error: EISDIR: illegal operation on a directory, read
  at Object.readFileUtf8 (node:internal/fs/sync:25:18)
  at Object.readFileSync (node:fs:441:19)
  at extractAnnotations (/app/node_modules/swagger-jsdoc/src/utils.js:54:26)
  at build (/app/node_modules/swagger-jsdoc/src/specification.js:200:9)

To repro, create a directory called src/foo/asn1.js in the above path and run the above swagger method.

Expected behavior
No crash, presumably through detecting whether something is not a directory before opening it.

Screenshots
See error.

Desktop (please complete the following information):
In node:20 docker container.

Additional context
None.

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.

Just had this occur to me - swagger-jsdoc worked locally but then upon building with esbuild, the server crashes silently, took some time debugging only to find the same thing @Lomilar found.