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
952 stars 227 forks source link

Fixed a bug introduced by https://github.com/APIDevTools/json-schema-… #284

Closed florinc09 closed 1 year ago

florinc09 commented 1 year ago

…ref-parser/commit/4e0123f146c81f15abb49bac00cd63834c131792

Because of that external schemas are not mapped correctly (re-crawl was not executed) and the $ref was pointing out to a wrong path: "#/paths/~1test~1add-test/post/requestBody/content/application~1json/schema/properties/test2/properties/test3/properties/test5/items/properties/test5A/properties/test6/items" instead of "$ref": "#/components/schemas/Common.Test3/properties/test5/items/properties/test5A/properties/test6/items". (deep-external test contains a main yaml file, a shared yaml file and the expected result)

philsturgeon commented 1 year ago

Thanks for this. Is there a particular issue its fixing or has nobody else noticed this bug yet?

Sorry to say the test is failing.


  1) Schema with deeply-nested external $refs
       should bundle successfully:
     ResolverError: Error opening file "/home/runner/work/json-schema-ref-parser/json-schema-ref-parser/test/specs/deep-external/shared.yaml" 
ENOENT: no such file or directory, open '/home/runner/work/json-schema-ref-parser/json-schema-ref-parser/test/specs/deep-external/shared.yaml'
      at ReadFileContext.callback (lib/resolvers/file.js:23:195)
      at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:282:13)
florinc09 commented 1 year ago

I have noticed that the test is failing. Not sure why is failing since it works when I'm running those tests locally. For some reasons it seems that it does not find shared.yaml file. .... pushed some small changes

philsturgeon commented 1 year ago

Currently getting this error:

  1) Invalid syntax
       in main file
         when continueOnError is true
           should throw a grouped error for an invalid JSON file with YAML disabled:

      AssertionError: expected [ Array(1) ] to contain subset [ Array(1) ]
      + expected - actual

       [
      -  "ParserError: Error parsing /home/runner/work/json-schema-ref-parser/json-schema-ref-parser/test/specs/invalid/invalid.json: Expected property name or '}' in JSON at position 2"
      +  {
      +    "message": [Function]
      +    "name": "ParserError"
      +    "path": []
      +    "source": [Function]
      +  }
       ]

      at Context.<anonymous> (test/specs/invalid/invalid.spec.js:159:33)
florinc09 commented 1 year ago

Currently getting this error:

  1) Invalid syntax
       in main file
         when continueOnError is true
           should throw a grouped error for an invalid JSON file with YAML disabled:

      AssertionError: expected [ Array(1) ] to contain subset [ Array(1) ]
      + expected - actual

       [
      -  "ParserError: Error parsing /home/runner/work/json-schema-ref-parser/json-schema-ref-parser/test/specs/invalid/invalid.json: Expected property name or '}' in JSON at position 2"
      +  {
      +    "message": [Function]
      +    "name": "ParserError"
      +    "path": []
      +    "source": [Function]
      +  }
       ]

      at Context.<anonymous> (test/specs/invalid/invalid.spec.js:159:33)

Hi,

This issue seems to appear when node 19.0.0 version is used and it occurs also if the code does not have my changes. image

philsturgeon commented 1 year ago

@acunniffe this is another mystery I have not been able to delve into, im out in the field slashing bamboo for a few days but this needs to get wrapped up so we can release v10. Any chance you could help?

philsturgeon commented 1 year ago

You're right this error is unrelated so I'll let this one in.