On Thursday, May 9, 2013 5:49:43 PM UTC+1,
randy...@gmail.com wrote:
Quick Json Schema clarification:
I would like to ensure that this is a valid way to override V4 schema definitions:
{
"id": "sample.json#",
"type": "object",
"properties": {
"ref": {
"$ref": "#/definitions/ref",
"minItems": 4
}
},
"definitions": {
"ref": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
}
}
The override of minItems set to 4 seems to work as expected in Francis' tooling, but I could find no explicit mention of using this approach in the specification. Perhaps I missed it. Of course, this is much simpler than using an allOf or similar approach, so I am hoping this is conforming and sanctioned.
Thanks for the advice,
Randy Watler
I'm afraid that is *not* according to the specification - in fact Francis's tool is behaving incorrectly.
In that situation, schema processors should be ignoring "minItems":4, because that schema should be completely replaced with the referenced one. The correct way is to use "allOf", as you mention:
{
"id": "sample.json#",
"type": "object",
"properties": {
"ref": {
"allOf": [{"$ref": "#/definitions/ref"}],
"minItems": 4
}
},
"definitions": {
"ref": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
}
}