Skip to content

Instantly share code, notes, and snippets.

@Sequoia
Last active June 30, 2016 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sequoia/d86032bff4413759c2f27e9cf852817b to your computer and use it in GitHub Desktop.
Save Sequoia/d86032bff4413759c2f27e9cf852817b to your computer and use it in GitHub Desktop.
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"id": "https://gist.githubusercontent.com/Sequoia/d86032bff4413759c2f27e9cf852817b/raw/demo-schema.json",
"title": "More than one type",
"description": "This schema has a single property with multiple types",
"definitions" : {
"specialString" : {
"type" : "string",
"description": "(3) The String One!",
"enum" : ["yes", "no", "maybe"]
}
},
"properties" :{
"test" : {
"description": "a property that can be null, a string, or an object",
"anyOf" : [
{
"type" : "null",
"description": "(1) The Null One!"
},
{
"type" : "object",
"description": "(2) The Object One!",
"properties": {
"name" : {
"type": "string"
}
},
"additionalProperties": false
},
{ "$ref" : "#/definitions/specialString" }
]
}
}
}
{
"$schema" : "https://gist.githubusercontent.com/Sequoia/d86032bff4413759c2f27e9cf852817b/raw/demo-schema.json",
"test": {
"badProperty" : "foo",
"should say 'bad property!' not prompt me to make type null"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment