Skip to content

Instantly share code, notes, and snippets.

@bcardiff
Last active September 21, 2018 18:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bcardiff/c0191a33d7ad05dd3f74b2591aa38708 to your computer and use it in GitHub Desktop.
JSON schema sample
{
"id": 2,
"names": ["sdf","sdfs"],
"some_values": ["asda", 34],
"owner": {"first": "John", "last": "Doe"},
"people": [{"first": "John", "last": "Doe"}],
"colors": {
"blue": { "hex": "#0000ff", "rgb": [0,0,255] },
"red": { "hex": "#ff0000", "rgb": [255,0,0] }
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"person": {
"type": "object",
"properties": {
"first": {
"type": "string"
},
// this is the last name of the person
"last": {
"type": "string"
}
},
"required": [
"first",
"last"
],
"additionalProperties": false
},
"colors_by_name": {
"type":"object",
"additionalProperties": { "$ref": "#/definitions/color" }
},
"color": {
"type": "object",
"properties": {
"hex": { "type": "string" },
"rgb": {
"type": "array",
"items": {"type": "number"},
"minItems": 3,
"maxItems": 3,
},
},
"additionalProperties": false,
"required": ["hex","rgb"]
}
},
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"names": {
"type": "array",
"items": {
"type": "string"
}
},
"some_values": {
"type": "array",
"items": {
"oneOf": [
{"type": "string"},
{"type": "integer"}
]
}
},
"people": {
"type": "array",
"items": { "$ref": "#/definitions/person" }
},
"owner": { "$ref": "#/definitions/person" },
"colors": { "$ref": "#/definitions/colors_by_name" }
},
"required": [
"id",
"names",
"people",
"colors",
"some_values"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment