openapistack / openapi-backend

Build, Validate, Route, Authenticate and Mock using OpenAPI
https://openapistack.co
MIT License
614 stars 83 forks source link

definition parse errors on windows machines #640

Closed jej2003 closed 1 year ago

jej2003 commented 1 year ago

On windows machines the underlying json-schema-ref-parser fails to correctly resolve resources but has been addressed in https://github.com/APIDevTools/json-schema-ref-parser/pull/315. Updating the json-schema-ref-parser to version 11.1.0 corrects this issue. #639 resolves this.

with a file named "api.json" 2 directories up the following code throws the below error on windows but works as expected on MacOS and Linux

   api = new OpenAPIBackend({
      definition: `file://${path.resolve(__dirname, '..', '..', 'api.json')}`, quick: true, handlers: {}
   })
   api.init()
ENOENT: no such file or directory, open 'C:\dev\project\project-maa-s\lambda\dataset\node_modules\@apidevtools\json-schema-ref-parser\dist\C:\dev\project\project-maa-s\lambda\dataset\api.json'
    at Object.<anonymous> (C:\dev\project\project-maa-s\lambda\dataset\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers\file.js:72:23)
    at Generator.throw (<anonymous>)
    at rejected (C:\dev\project\project-maa-s\lambda\dataset\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers\file.js:29:65) {
  code: 'ERESOLVER',
  name: 'ResolverError',
  source: 'C:\\dev\\project\\project-maa-s\\lambda\\dataset\\node_modules\\@apidevtools\\json-schema-ref-parser\\dist\\C:\\dev\\project\\project-maa-s\\lambda\\dataset\\api.json',    
  path: null,
  toJSON: [Function: toJSON],
  ioErrorCode: 'ENOENT',
  [Symbol(nodejs.util.inspect.custom)]: [Function: inspect]
}
jej2003 commented 1 year ago

Good morning! I'm trying to understand the process to have this looked at. I believe it's fairly straight forward but any help in moving this along would be appreciated.

anttiviljami commented 1 year ago

Hi @jej2003! Thanks for the PR. The latest version of @apidevtools/json-schema-ref-parser is now shipped as a dependency of openapi-backend@5.10.0