Reputation: 51
Please help me with this: I try to write a json schema to validate the following object:
json object:
{"param":value}
Possible values: 'all', [array of any integers]
So it is a simple json object which contain one variable that could be string 'all', or array of any integers [].
I tried this but it doesn't work in json schema validator:
{
"type": ["string","array"],
"items": { "oneOf": [
"all",
{ "type": "integer" }
]
}
}
Thank you.
Upvotes: 5
Views: 4799
Reputation: 111
For draft4 this schema should work
{
"type": "object",
"properties": {
"param": {
"oneOf": [
{
"enum": ["all"]
},
{
"type": "array",
"items": {"type": "integer"}
}
]
}
},
"additionalProperties": false,
"required": ["param"]
}
Value of oneOf
should be list of objects and keyword enum
allows to compare with the value.
Upvotes: 5