Validate JSON data with schemas, types, required fields, formats, composition, and API contracts.
Lessons
Define and reuse subschemas in one document.
Local Definitions with $defs 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 Local Definitions with $defs example in a small scratch file, then explain what changed and why.