-
-
Notifications
You must be signed in to change notification settings - Fork 375
Description
When I'm writing some json schema and try to organize them, I notice current we cannot override the reference of external references, resulting limitation in extending the schema.
For example, I have define this little functional programming language just-func: https://github.com/justland/just-func-json/blob/main/json-schema/just-func.jsonc
In the schema, one of the definition looks like this:
Notice I have a "$ref": "#/definitions/JustFunc" here.
When using this language, I would extend it by defining additional functions, e.g.:
// my-app.jsonc
{
"$schema": "http://json-schema.org/draft-07/schema",
"description": "Validation schema for my-app written in just-func",
"definitions": {
"MyJustFunc": {
"oneOf": [{
"$ref": "just-func.jsonc/#/definitions/JustFunc"
}, {
"$ref": "#/definitions/MyExtensions"
}]
},
"MyExtensions": {
// ... snip ...
}
}
}The problem is, if I use one of the default definition provided in just-func.jsonc,
they does not recognize the functions I defined in MyExtensions because their reference is (just-func.jsonc)#/definitions/JustFunc instead of (my-app.jsonc)#/definitions/MyJustFunc.
To solve this, we need a way to override the reference something akin to:
{
"$override": {
"just-junc.jsonc": {
"#/definitions/JustFunc": "/#/definitions/MyJustFunc" // using `/#` to indicate it is a local reference
}
}
}🌷