Any-of
Example schema to demonstrate the use of the anyOf keyword
$id | anyof.yml |
$schema | http://json-schema.org/draft-07/schema# |
Properties
Name | Type |
---|
anyOfExample | Any of: | Object |
Object |
Object |
Example
{
"anyOfExample": {
"propertyA": "With a string value"
}
}
Example
{
"anyOfExample": {
"propertyA": "With another string value",
"propertyB": 456,
"propertyC": 789
}
}
anyOfExample
Title |
Any Of Example |
Description |
Property that demonstrates anyOf |
|
Type | Any of: | Object |
Object |
Object |
Required |
Yes |
anyOfExample.0
Title |
anyOfExample option 0 with a single property |
anyOfExample.0.propertyA
Title |
Property A |
Type | String |
anyOfExample.1
Title |
anyOfExample option 1 with a two property |
anyOfExample.1.propertyA
Title |
Property A |
Type | String |
anyOfExample.1.propertyB
Title |
Property B |
Type | Integer |
anyOfExample.2
Title |
anyOfExample option 2 with three properties |
anyOfExample.2.propertyA
Title |
Property A |
Type | String |
anyOfExample.2.propertyB
Title |
Property B |
Type | Integer |
anyOfExample.2.propertyC
Title |
Property C |
Type | Integer |
Schema
{
"$id": "anyof.yml",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Any-of",
"description": "Example schema to demonstrate the use of the anyOf keyword",
"type": "object",
"examples": [
{
"anyOfExample": {
"propertyA": "With a string value"
}
},
{
"anyOfExample": {
"propertyA": "With another string value",
"propertyB": 456,
"propertyC": 789
}
}
],
"properties": {
"anyOfExample": {
"title": "Any Of Example",
"description": "Property that demonstrates anyOf",
"type": "object",
"anyOf": [
{
"title": "anyOfExample option 0 with a single property",
"properties": {
"propertyA": {
"type": "string",
"title": "Property A"
}
},
"additionalProperties": false,
"required": [
"propertyA"
]
},
{
"title": "anyOfExample option 1 with a two property",
"properties": {
"propertyA": {
"type": "string",
"title": "Property A"
},
"propertyB": {
"type": "integer",
"title": "Property B"
}
},
"additionalProperties": false,
"required": [
"propertyA"
]
},
{
"title": "anyOfExample option 2 with three properties",
"properties": {
"propertyA": {
"type": "string",
"title": "Property A"
},
"propertyB": {
"type": "integer",
"title": "Property B"
},
"propertyC": {
"type": "integer",
"title": "Property C"
}
},
"additionalProperties": false,
"required": [
"propertyA",
"propertyB",
"propertyC"
]
}
]
}
},
"additionalProperties": false,
"required": [
"anyOfExample"
]
}