Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSON Schema example
// example JSON
{
"name": "Mona Lisa",
"artist": "Leonardo da Vinci",
"description": null,
"dimension": {
"height": 53.0,
"width": 77.0
},
"tags": ["oil", "famous"]
}
// example JSON Schema
{
"$schema": "https://json-schema.org/draft/2019-09/schema#",
"$id": "http://my-paintings-api.com/schemas/painting-schema.json",
"type": "object",
"title": "Painting",
"description": "Painting information",
"additionalProperties": true,
"required": ["name", "artist", "dimension", "description", "tags"],
"properties": {
"name": {
"type": "string",
"description": "Painting name"
},
"artist": {
"type": "string",
"maxLength": 50,
"description": "Name of the artist"
},
"description": {
"type": ["string", "null"],
"description": "Painting description"
},
"dimension": { "$ref": "#/$defs/dimension" },
"tags": {
"type": "array",
"items": { "$ref": "#/$defs/tag" }
}
},
"$defs": {
"tag": {
"type": "string",
"enum": ["oil", "watercolor", "digital", "famous"]
},
"dimension": {
"type": "object",
"title": "Painting dimension",
"description": "Describes the dimension of a painting in cm",
"additionalProperties": true,
"required": ["width", "height"],
"properties": {
"width": { "type": "number", "description": "Width of the product", "minimum": 1 },
"height": { "type": "number", "description": "Height of the product", "minimum": 1 }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.