Created
February 26, 2013 11:24
-
-
Save fge/5037801 to your computer and use it in GitHub Desktop.
animals with additionalProperties allowed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$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