Closed y5wang closed 6 years ago
The JSON reference documents say that a JSON reference should be an object with only the $ref
key. All other keys will be ignored.
A JSON Reference is a JSON object, which contains a member named "$ref", which has a JSON string value. Example:
{ "$ref": "http://example.com/example.json#/foo/bar" }
If a JSON value does not have these characteristics, then it SHOULD NOT be interpreted as a JSON Reference.
The "$ref" string value contains a URI [RFC3986], which identifies the location of the JSON value being referenced. It is an error condition if the string value does not conform to URI syntax rules. Any members other than "$ref" in a JSON Reference object SHALL be ignored.
The may be ignored by validators but it would be good if jsonref didn't overwrite any properties that happened to be there, it isn't invalid JSON schema. We use some custom keywords that are currently getting overwritten so it would be great if you could support this.
@simonjupp I'm a bit hesitant on that, for one, because the reference might be replaced by another type that isn't a dictionary. e.g.
example = {
"key1": {"$ref": "#/key2", "extra": "key"},
"key2": "some text"
}
It is possible now to access your extra keys if you want, it just isn't very clean. Like so, example["key1"].__reference__["extra"]
With a schema similar to this: