Validate JSON data with schemas, types, required fields, formats, composition, and API contracts.
Lessons
Split schemas into reusable definitions and references.
$ref, $defs and Reuse is easiest to learn by reading the example, changing it, and observing the result.
{
"type": "object",
"properties": {
"billing": { "$ref": "#/$defs/address" },
"shipping": { "$ref": "#/$defs/address" }
},
"$defs": {
"address": {
"type": "object",
"required": ["street", "city"],
"properties": {
"street": { "type": "string" },
"city": { "type": "string" }
}
}
}
}Practice the $ref, $defs and Reuse example in a small scratch file, then explain what changed and why.