scalar / openapi-parser

Modern OpenAPI parser written in TypeScript
MIT License
34 stars 1 forks source link

fix: Unable to load files in Node #94

Closed x-delfino closed 3 months ago

x-delfino commented 3 months ago

Problem Currently, when using loadFiles(), an error is raised

loadFiles(path.resolve('/path/to/openapi.yaml'))

causes the following error:

Yt.existsSync is not a function

Explanation

*.existsSync is called here: https://github.com/scalar/openapi-parser/blob/main/packages/openapi-parser/src/utils/loadFiles.ts#L16

Checking through the bundled module, it looks like Yt is just defined as Yt={}.

Solution This PR adds node:fs and node:path to rollupOptions.external in vite.config.ts which results in successfully reading specs from disk.

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 37dfac59e72fd9d9a213c88fa22d98e3cac0e3fd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---------------------- | ----- | | @scalar/openapi-parser | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR