Reputation: 7612
I'd like to use oneOf
schemas which differ only by value of xyType
property. I'd like to have two of them: one where the xyType
is set to "1"
and the second one where xyType
is any other value. Can this be done using json schemas?
"oneOf": [
{
"properties": {
"xyType": "enum": ["1"],
"whatever" : "string"
},
"type": "object"
},
{
"properties": {
"xyType": "enum": [], /// NOT "1"?
"whatever" : "string"
},
"type": "object"
}
]
Upvotes: 5
Views: 4215
Reputation: 12863
There's a not
operator, and the enum
keyword, and you can use them together, like
{
"not": {
"enum": ["1"]
}
}
Upvotes: 14