Schema used JSON Schema Draft 2020-12 to check the data
before the resource is saved.
Commonly used structure
type defines the data type.
properties declares the fields.
required lists required fields.
additionalProperties: false rejects fields outside the schema.
System rules
- The root schema must be an object or a boolean.
- Only local references are supported through
$ref, for example #/$defs/address.
- References to external schemas are not supported.
- Maximum 64 KiB, depth 20 and 2,000 nodes.
For example
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": { "type": "string", "minLength": 1 },
"price": { "type": "number", "minimum": 0 },
"status": { "enum": ["draft", "published"] }
},
"required": ["name"],
"additionalProperties": false
}