Is it possible to use alternatives in JSON Schema? In XSD this is doable using xs:alternative
element.
For example see: How to use alternatives in XML Schema 1.1
UPDATE 1:
This is a sample JSON I would like to describe using JSON schema:
{
"actions": [
{
"type": "basic",
"param1": "value"
},
{
"type": "extended",
"param1": "value",
"param2": "blah"
}
]
}
Requirements:
actions
may have any number of itemsbasic
actions must containparam1
propertyextended
actions must containparam1
andparam2
properties
There is a similar mechanism since Draft04 with nicer semantics: oneOf, anyOf, allOf and not, keywords.
Assuming you are looking for an exclusive "alternative", this would be an example of json-schema using oneOf: