One-of and Any-of
Example schema to demonstrate one of and any of
$id | oneof-and-anyof.yml |
$schema | http://json-schema.org/draft-07/schema# |
Properties
Name | Type |
---|
justOne | One of: | Object |
---|
Object |
Example
{
"justOne": {
"propertyA": "With a string value"
}
}
Example
{
"justOne": {
"propertyB": 123,
"propertyC": 456
}
}
justOne
Title |
Just One |
Description |
Property that demonstrates oneOf |
Required |
Yes |
|
Type | One of: | Object |
---|
Object |
justOne.0
Title |
justOne option 0 with a single property |
justOne.0.propertyA
Title |
Property A |
Type | String |
justOne.1
Title |
justOne option 1 with two properties |
justOne.1.propertyB
Title |
Property B |
Type | Integer |
justOne.1.propertyC
Title |
Property C |
Type | Integer |
Schema
{
"$id": "oneof-and-anyof.yml",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "One-of and Any-of",
"description": "Example schema to demonstrate one of and any of",
"type": "object",
"examples": [
{
"justOne": {
"propertyA": "With a string value"
}
},
{
"justOne": {
"propertyB": 123,
"propertyC": 456
}
}
],
"properties": {
"justOne": {
"title": "Just One",
"description": "Property that demonstrates oneOf",
"type": "object",
"oneOf": [
{
"title": "justOne option 0 with a single property",
"properties": {
"propertyA": {
"type": "string",
"title": "Property A"
}
},
"required": [
"propertyA"
]
},
{
"title": "justOne option 1 with two properties",
"properties": {
"propertyB": {
"type": "integer",
"title": "Property B"
},
"propertyC": {
"type": "integer",
"title": "Property C"
}
},
"required": [
"propertyB",
"propertyC"
]
}
],
"isRequired": true
}
},
"additionalProperties": false,
"required": [
"justOne"
]
}