-
-
Notifications
You must be signed in to change notification settings - Fork 369
Closed
Milestone
Description
As a follow-up to #1610, there has been some discussion in Slack around a proposal I made for a way to allow for extensions to the meta-schema while also disallowing unknown keywords with unevaluatedProperties: false.
After iterating on the idea, we landed on this structure for the meta-schema:
Then an extension meta-schema would need to look like this:
{
"$schema": "https://json-schema.org/1/2025",
"$id": "https://example.com/custom",
"$ref": "https://json-schema.org/1/2025",
"$defs": {
"extension": {
"$dynamicAnchor": "extension",
"properties": {
"foo": true
}
}
}
}Tracing this through:
- Start validation with the custom meta-schema,
https://example.com/custom. This registers the$dynamicAnchor. - The custom meta-schema references the base meta-schema (ours).
- The base meta-schema has a
$dynamicRef: #extensionthat resolves back to the definition in the custom meta-schema, where any additional properties are defined. - Because these extra properties are now defined via the
$dynamicRefapplicator,unevaluatedPropertiescan see them and will know to ignore them. - Lastly, applicators can once again be defined using just
$ref: #(like draft 7 and earlier) because the reference back to the custom meta-schema is handled by the base meta-schema root.
It does feel a bit awkward to put your extension information in a $defs entry, but then you're also making a custom meta-schema, which isn't something I expect many people will do.
Relequestual
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done
{ "$schema": "https://json-schema.org/1/2025", "$id": "https://json-schema.org/1/2025", "type": ["object", "boolean"], "properties": { "$schema": { "type": "string", "format": "iri" }, "additionalProperties": { "$ref": "#" } // showing for self-reference // ... }, "unevaluatedProperties": false, "$dynamicRef": "#extension", "$defs": { "extension": { "$dynamicAnchor": "extension" } } }