Define reusable schemas with the $defs keyword
masterTo keep schemas organized and maintainable, you can define common structures in a single location under a $defs object. Other parts of the schema can then reference these definitions using $ref (e.g., #/ $defs/definition_name).
{
'type': 'object',
'properties': {
'billing_address': {
'$ref': '#/$defs/address'
},
'shipping_address': {
'$ref': '#/$defs/address'
}
},
'$defs': {
'address': {
'type': 'object',
'properties': {
'street': { 'type': 'string' },
'city': { 'type': 'string' },
'state': { 'type': 'string' }
}
}
}
}