APIDevTools / json-schema-ref-parser

Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
https://apitools.dev/json-schema-ref-parser
MIT License
942 stars 226 forks source link

Absolute and some relative paths broken in 10.0.1 #303

Closed leeleahulkcs closed 5 months ago

leeleahulkcs commented 1 year ago

Version 9.1.0 = OK Version 10.0.1 = BROKEN

This is broken on Windows only.

In our code, we call this module like this:

This worked in version 9.1.0. In version 10.0.1, it returns the error:

In file node_modules\@apidevtools\json-schema-ref-parser\cjs\util\projectDir.cjs:

So to get our code to work, we have to do one of two things:

  1. Change $RefParser.dereference(path.resolve('swagger/index.yaml'), ... to $RefParser.dereference('../../../swagger/index.yaml', ...
  2. In the file node_modules\@apidevtools\json-schema-ref-parser\cjs\util\projectDir.cjs, change const projectDir = nodePath.resolve(__dirname, "..", ".."); to const projectDir = nodePath.resolve(__dirname, "..", "..", "..", "..", "..");
typhonrt commented 1 year ago

I can confirm. v9.1.1 and 10.0.1 are affected on Windows; I just temporarily will stay on v9.0.9. Just want to say thanks to Phil for past efforts!

KonkretneKosteczki commented 1 year ago

I still experience the issue on windows for version @11.0.4

FloErwerth commented 1 year ago

We also experience this issue still on windows.

NordengenT commented 1 year ago

This is still not fixed and makes the library unusable on windows

Bartel-C8 commented 1 year ago

Same on macOS here!

jonluca commented 5 months ago

I believe this is fixed by setting projectDir to cwd instead of referencing the file location itself - not sure why it was like that in the first place. Should be fixed in v11.2.3