internal reference in schema
See original GitHub issueI am trying to dereference resolved schema object. But it is throwing error as “Error resolving $ref pointer “#/definitions/ApiCallList”. Token “definitions” does not exist.”
Is this a bug or What is the correct way to define $ref to refer internal definition within the schema object.
$RefParser = require('json-schema-ref-parser') $RefParser.dereference(schema, { $refs: { circular: "ignore" } }) .then(function(resolvedSchema) { res.send(resolvedSchema); })
Sample Schema
{ "definitions":{ "ApiCallList":{ "description":"A list of Api Call Resources", "id":"ApiCallList" }, "MaskCallList":{ "description":"A list of Mask Call Resources", "id":"MaskCallList" } }, "resources":{ "api-call":{ "methods":{ "request":{ "$ref":"#/definitions/ApiCallList }, "response":{ "$ref":"#/definitions/MaskCallList } } } } }
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (4 by maintainers)
Top GitHub Comments
Hi, @dave-irvine. Sorry, I somehow missed your comment from two weeks ago; otherwise, I would have responded sooner.
The behavior you’re seeing is by design and per the JSON Pointer spec. JSON pointers are relative to the root of the document they’re in. So, in
paths.yaml
, the$ref
to#/definitions/User
is invalid. You should replace it withswagger.yaml#/definitions/User
instead.As far as I can tell, everything is behaving as expected and according to the spec. Perhaps I don’t understand something. Can somebody please provide a reproduction of the issue, preferably on RunKit?
Here are reproductions of other issues, as examples:
https://runkit.com/bigstickcarpet/json-schema-ref-parser-issue-93
https://runkit.com/bigstickcarpet/swagger-cli-issue-19
https://runkit.com/bigstickcarpet/swagger-parser-issue-90