json-schema-ref-parser
json-schema-ref-parser copied to clipboard
Add the friendlyPath argument to $Refs::_resolve
Unfortunately #75 wasn't enough to get everything back to how it worked in 3.x 😢 With this change the tests for apiaryio/fury-adapter-swagger#158 finally pass.
I don't know this library well enough to write a test for this change. Any pointer would be appreciated.
Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.
Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.
Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.
Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.
@BigstickCarpet Could you have a look at this one? Thanks!
Hi @realityking. Sorry for taking so long to get to this.
Would you mind adding a test for this? I just want to make sure that I fully understand the issue, and a test will help with that. Plus, a test will ensure that I don't accidentally break it again in the future.
@JamesMessinger The issue is that in swagger-parser@4 the error message:
throw ono('Error resolving $ref pointer "%s". \n"%s" not found.', path, withoutHash);
Contains the incorrect path for "root" (#/) references. In 3.x the following error was presented:
Error resolving $ref pointer "#/definitions/Whoops". \nToken "Whoops" does not exist.
Whereas in 4.0 this contains the full path to the "current working directory":
Error resolving $ref pointer "/Users/kyle/Projects/apiaryio/fury-adapter-swagger/#/definitions/Whoops". \nToken "Whoops" does not exist.
To note, we're also using the options to disable external references:
const swaggerOptions = {
dereference: {
circular: 'ignore',
},
resolve: {
external: false,
},
};
AFAICT a refactor in the past changed this behavior. You'll get a MissingPointerException if the dereferencing hits a missing reference, and a manual call to .get on the reference will just reply with the path the user provided it. Closing for now