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

Error resolving references within extended objects

Open JamesMessinger opened this issue 7 years ago • 4 comments

Glossary

An "extended object" is a JSON object that has other properties in addition to $ref. For example:

{
    "name": "additional name property",
    "$ref": "#/some/reference"
}

Note: that extended objects are not allowed by the JSON Schema or JSON Reference specs. The json-schema-ref-parser library only supports them for backward-compatibility, and it's possible that this support will be removed at some point in the future to bring this library inline with the official spec.

Issue Description

There is currently a bug in the dereference() method when an extended object contains both an external file reference and an internal reference. The internal reference gets broken, because the dereference() method attempts to resolve it in the external file instead.

Issue Reproduction

Here is sample code that reproduces this issue: https://runkit.com/bigstickcarpet/swagger-cli-issue-19

JamesMessinger avatar Jul 23 '18 11:07 JamesMessinger

Any updates on this? Im having the same issue ... I tried using a custom resolver, but this error occurs before my custom resolver can intercept and handle the #/some/reference

gaviniflix avatar Aug 06 '18 11:08 gaviniflix

No update on this yet. It's lower on my priority list than other issues, since it only occurs for schemas that are technically invalid (see my note above)

JamesMessinger avatar Aug 06 '18 14:08 JamesMessinger

Thanks ... will keep eyes on this issue to see what is done going forward ... Hoping it gets in, but understand the bring this library inline with the official spec statement .... any chance of a fork?

gaviniflix avatar Aug 07 '18 10:08 gaviniflix

My plan is for the core library to be spec-compliant and to move the non-spec-compliant functionality to a companion library or a plugin.

JamesMessinger avatar Aug 07 '18 12:08 JamesMessinger