Skip to content

Instantly share code, notes, and snippets.

@fge
Created February 26, 2013 11:24
Show Gist options
  • Save fge/5037801 to your computer and use it in GitHub Desktop.
Save fge/5037801 to your computer and use it in GitHub Desktop.
animals with additionalProperties allowed
{
"$schema": "http://json-schema.org/draft-04/schema#",
"oneOf": [
{
"description": "a single animal",
"$ref": "#/definitions/animal"
},
{
"description": "a collection of animals",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": { "$ref": "#/definitions/animal" }
}
],
"definitions": {
"common": {
"type": "object",
"required": [ "type", "name" ],
"properties": {
"name": { "type": "string" }
}
},
"cat": {
"allOf": [
{ "$ref": "#/definitions/common" },
{
"required": [ "favoriteToy" ],
"properties": {
"type": { "enum": [ "cat" ] },
"favoriteToy": { "type": "string" }
}
}
]
},
"dog": {
"allOf": [
{ "$ref": "#/definitions/common" },
{
"required": [ "breed", "leashColor" ],
"properties": {
"type": { "enum": [ "cat" ] },
"breed": { "type": "string" },
"leashColor": { "type": "string" }
}
}
]
},
"animal": {
"oneOf": [
{ "$ref": "#/definitions/cat" },
{ "$ref": "#/definitions/dog" }
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment