$ref to definitions in another file not working?
See original GitHub issueI cannot make references to external definitions to work, when running a copy of https://json-editor.github.io/json-editor/ on localhost (using python’s http.server and with AJAX switched on).
To explain, let’s say I have common.schema.json
with
{
"$schema": "http://json-schema.org/draft-04/schema",
"definitions": {
"known-product": {
"title": "product",
"type": "string",
"enum": [ "power", "hydrogen", "heat" ]
}
},
"title": "test",
"properties": {
"customer": { "type": "string" },
"product": { "$ref": "#/definitions/known-product" }
}
}
and test.schema.json
with
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Ref. tests",
"properties": {
"test-1": { "$ref": "common.schema.json#" },
"test-2": { "$ref": "common.schema.json#/definitions/known-product" },
"test-3": {
"type": "object",
"properties": {
"Product": { "$ref": "./common.schema.json#/definitions/known-product" }
}
}
}
}
Then, I put both schemas to the same folder as index.html
, activate AJAX, and use test.schema.json
in the editor.
In the generated editor, I would expect test-1
to ignore definitions
and show customers
and product
, while both test-2
and test-3
should read only definitions/known-product
and therefore show only the product selection.
However, all three test show the same (customer and product), suggesting that that $ref
ignores everything after #
and simply includes the whole file.
Is this a bug, a missing feature, or am I just doing it wrong?
Note: it could be related to this pull request, but it is marked as “merged” and the examples all use internal references, despite the title mentioning “nonlocal definitions”…
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (7 by maintainers)
Top GitHub Comments
Yeah, when I dumped the refs, I found the key was malformed which is why the schemaloader couldn’t resolve the JSON pointer path, eg “animals.json#/definitions/cat#/definitions/cat”.
p.s. I have a fix; I’ll submit a PR as soon as I have time to write the tests for it