Use $ref instead of allOf for Extending Closed Schemas #65
Open
Description
Lesson Link: https://tour.json-schema.org/content/07-Miscellaneous/01-Extending-Closed-Schemas-with-unevaluatedProperties
The "Extending Closed Schemas" lesson uses allOf
for the example, which is fine, but it's not a normal case. In a previous lesson, you specify that you've make available a schema with a certain URI that you want the user to reference. This would be a great time to employ that technique. You provide an address schema at https://example.com/address
and then have then extend it by adding the type
property.
{
"$ref": "https://example.com/address",
"properties": {
"type": { "enum": [ "residential", "business" ] }
},
"unevaluatedProperties": false,
"required": ["type"]
}
This is a much more realistic way to show what this keyword is good for.
(Also, I think the unevaluatedItems
should look a lot like this lesson except for arrays instead of objects.)