-
Notifications
You must be signed in to change notification settings - Fork 397
Closed
Labels
Description
The following JSON Schema creates an acyclic directed graph, which is basically narrowing an allowed value.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"unit-value": {
"type": "object",
"properties": {
"unit": {
"type": "string"
},
"value": {
"type": "number"
}
}
},
"length-unit-value": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/unit-value"
},
{
"properties": {
"unit": {
"type": "string",
"enum": [
"cm",
"in"
]
}
}
}
]
},
"something-containing-unit-value": {
"type": "object",
"properties": {
"unit-value": {
"$ref": "#/definitions/unit-value"
}
},
"required": [ "unit-value"]
}
},
"type": "object",
"allOf": [
{
"$ref": "#/definitions/something-containing-unit-value"
},
{
"properties": {
"unit-value": {
"$ref": "#/definitions/length-unit-value"
}
}
}
]
}
The validator produces the following error
[ {
"level" : "fatal",
"schema" : {
"loadingURI" : "#",
"pointer" : "/definitions/unit-value/properties/unit"
},
"instance" : {
"pointer" : "/unit-value/unit"
},
"domain" : "validation",
"message" : "validation loop: schema \"#/definitions/unit-value/properties/unit\" visited twice for pointer \"/unit-value/unit\" of validated instance",
"alreadyVisited" : "#/definitions/unit-value/properties/unit",
"instancePointer" : "/unit-value/unit",
"validationPath" : [ "#", "#/allOf/0", "#/definitions/something-containing-unit-value/properties/unit-value", "#/definitions/unit-value/properties/unit", "#/definitions/unit-value/properties/value", "#/allOf/1", "#/allOf/1/properties/unit-value", "#/definitions/length-unit-value/allOf/0" ],
"info" : "other messages follow (if any)"
} ]
Sure, it's already visited, but it's not a loop. If nothing else, it's a different allOF.