json-schema-ref-parser icon indicating copy to clipboard operation
json-schema-ref-parser copied to clipboard

Absolute and some relative paths broken in 10.0.1

Open leeleahulkcs opened this issue 1 year ago • 5 comments

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:

  • $RefParser.dereference(path.resolve('swagger/index.yaml'), ...

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

  • ResolverError: Error opening file "__path_to_root__\\node_modules\\@apidevtools\\json-schema-ref-parser\\__path_to_root__\\swagger\\index.yaml"

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

  • projectDir is returned as __path_to_root__\\node_modules\\@apidevtools\\json-schema-ref-parser

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, "..", "..", "..", "..", "..");

leeleahulkcs avatar Jan 24 '23 01:01 leeleahulkcs

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!

typhonrt avatar Jan 24 '23 02:01 typhonrt

I still experience the issue on windows for version @11.0.4

KonkretneKosteczki avatar Feb 21 '23 10:02 KonkretneKosteczki

We also experience this issue still on windows.

FloErwerth avatar Feb 23 '23 14:02 FloErwerth

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

NordengenT avatar Jun 05 '23 11:06 NordengenT

Same on macOS here!

Bartel-C8 avatar Jun 08 '23 09:06 Bartel-C8

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

jonluca avatar Mar 06 '24 02:03 jonluca