One-of
Example schema to demonstrate the use of the oneOf keyword
$id | oneof.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 |
|
Type | One of: | Object |
Object |
Required |
Yes |
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.yml",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "One-of",
"description": "Example schema to demonstrate the use of the oneOf keyword",
"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"
]
}
]
}
},
"additionalProperties": false,
"required": [
"justOne"
]
}