Hi,
I'm new to json schema but really liking it. For the life of me I can't work out if this is possible or not so hopefully someone can help out! It's related to
https://groups.google.com/forum/#!topic/json-schema/86GSgHSQ0VI but not quite the same: is it possible to override one of the properties of a definition included in another definition via allOf? In my example below I want to have "c" set a maxItems on a's "errors" array. However, I can't follow the trick in that other post as whatever I try and do I get an error message "message" : "value has incorrect type (found object, expected one of [string])" (using the excellent
https://json-schema-validator.herokuapp.com/syntax.jsp). I have tried lots of variations which all fail, so haven't included any of them here as the post would be very lengthy.
I have realised that having many small definitions is very flexible, so I have lots of allOf definitions such as "c" - this is a simplified example when c only has 2 in its allOf. As I'm writing this I have just thought perhaps I need to split out 'errors' from a and perhaps that would help in this case, tho I am not sure how?
Thanks in advance, and I hope the question is clear enough!
Cheers,
Ben
{
"type": "object",
"required": [
"a",
"b",
"c"
],
"definitions": {
"a": {
"type": "object",
"properties": {
"errors": {
"type": "array",
"uniqueItems": true,
"additionalItems": false,
"items": {
"type": "string"
}
}
},
"required": [
"errors"
]
},
"b": {
"type": "object",
"properties": {
"blah": {
"type": "string"
}
},
"required": [
"blah"
]
},
"c": {
"type": "object",
"allOf": [
{ "$ref": "#/definitions/a" },
{ "$ref": "#/definitions/b" }
]
}
}
}