Open
Description
Hello, some help needed with this ...
When validating the following msg.json with schema hierarchy1 works fine:
msg.json:
{
"msg": "Hello World"
}
Schema hierarchy1:
/root.json
{
"$schema": "http://json-schema.org/schema#",
"$id": "http://acme.com/schemas/root.json",
"properties": {
"msg": {
"anyOf": [
{ "$ref": "v1/v1.json#/definitions/msg" },
{ "$ref": "v2.json#/definitions/msg" }
]
}
},
"required": ["msg"]
}
/common.json
{
"$schema": "http://json-schema.org/schema#",
"$id": "http://acme.com/schemas/common.json",
"definitions": {
"attr": {"type": "string"}
}
}
/v2.json
{
"$schema": "http://json-schema.org/schema#",
"$id": "http://acme.com/schemas/v2.json",
"definitions": {
"msg": { "$ref": "v1/v1.json#/definitions/msg"}
}
}
/v1/v1.json
{
"$schema": "http://json-schema.org/schema#",
"$id": "http://acme.com/schemas/v1/v1.json",
"definitions": {
"msg": { "$ref": "../common.json#/definitions/attr"}
}
}
When changing to hierarchy2 it validates the doc but also complains inserting the root schema:
$json-schema-validate schemas/root.json < msg.json
setting root schema failed
schema with http://acme.com/schemas/v1/v1.json # /definitions/msg already inserted
document is valid
Schema hierarchy2 with same docs except:
/root.json
{
"$schema": "http://json-schema.org/schema#",
"$id": "http://acme.com/schemas/root.json",
"properties": {
"msg": {
"anyOf": [
{ "$ref": "v1/v1.json#/definitions/msg" },
{ "$ref": "v2/v2.json#/definitions/msg" }
]
}
},
"required": ["msg"]
}
/v2/v2.json
{
"$schema": "http://json-schema.org/schema#",
"$id": "http://acme.com/schemas/v2/v2.json",
"definitions": {
"msg": { "$ref": "./../v1/v1.json#/definitions/msg"}
}
}
I am using tag 2.1.0 and nlohmann/json v3.8.0.
Thanks in advance,