Reputation: 437
Situation is following:
1.) In an object, I can have a "string", "array" or another "object".
2.) The "array" can contain only "string".
3.) The "object" can contain 1.) which means that I can have an object in a object which only can have a string or array though (or even more nested objects)
Problem is now that 1.) and 2.) work but as soon as I add "$ref" to the "object" to get 3.) my validation server crashes with a stack overflow.
{
"$schema": "http://json-schema.org/draft-04/schema",
"type": "object",
"properties": {
"value": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/properties/value"
}
}
}
]
}
}
}
The line "$ref": "#/properties/value"
breaks my code.
How do I get this to work ?
Upvotes: 0
Views: 1126
Reputation: 437
Fixed it myself. The line "$ref": "#/properties/value"
has to be changed to "$ref": "#/properties"
I thought that #/properties would mean only the property "value" is allowed inside these objects which is not what I wanted. I wanted to have the contents of "value" so I went one step deeper.
Looks like "$ref": "#/properties"
doesn't mean that only "value" is allowed instead it means only the properties of "value".
Upvotes: 1