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

Add the friendlyPath argument to $Refs::_resolve

Open realityking opened this issue 7 years ago • 8 comments

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.

realityking avatar Apr 11 '18 20:04 realityking

Coverage Status

Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.

coveralls avatar Apr 11 '18 20:04 coveralls

Coverage Status

Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.

coveralls avatar Apr 11 '18 20:04 coveralls

Coverage Status

Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.

coveralls avatar Apr 11 '18 20:04 coveralls

Coverage Status

Coverage remained the same at 95.026% when pulling cc4d361d9c415b2d37dc5e5622b133ff7fd13c47 on realityking:friendly-path into 1891b061c57bfe635cce0d74a4a9f642515561b3 on BigstickCarpet:master.

coveralls avatar Apr 11 '18 20:04 coveralls

@BigstickCarpet Could you have a look at this one? Thanks!

realityking avatar Jun 07 '18 00:06 realityking

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 avatar Jul 31 '18 11:07 JamesMessinger

@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.

kylef avatar Nov 05 '18 21:11 kylef

To note, we're also using the options to disable external references:

const swaggerOptions = {
  dereference: {
    circular: 'ignore',
  },
  resolve: {
    external: false,
  },
};

kylef avatar Nov 05 '18 21:11 kylef

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

jonluca avatar Feb 03 '23 20:02 jonluca