Closed rijenkii closed 10 months ago
That's expected behavior at least for the moment given the URL implementation we use is Python's standard library.
You're defining some custom scheme of yours (schema:
), there's not really a way for Python to know whether you intend for that custom scheme to support relative paths or not.
There are workarounds you can google which effectively involve touching global state in the urllib
module, but really the "right" solution is to use either some scheme with well-defined semantics or else to use absolute references.
(But this behavior may change if/when referencing uses some other URL library as it may make different assumptions about custom schemes.)
Yeah, checked -- using http(s)
works:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.example.org/main",
"$ref": "./child",
"$defs": {
"child": {
"$id": "https://schemas.example.org/child",
"type": "string"
}
}
}
>>> print(jsonschema.validate("123", schema))
None
Feel free to close this issue or move it to referencing repo as a feature request then.
Schema in question:
Exception:
Package versions: