Relative paths between definition files are not resolved
See original GitHub issueDear all,
first: thanks a lot for this great library, which enables me to use JSON schema validation during QM procedures in data management for JSON-based metadata!
I am struggling with an java.net.MalformedURLException: no protocol
exception for a complex schema, which I am unable to resolve.
Given the following example root schema to reproduce my findings:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://myexample.org/example/example.schema.json",
"type": "object",
"properties": {
"house": { "$ref": "definitions/buildings.json#/house" }
}
}
Let’s say that the definitions are in a separate file in a subdir of the root schema’s location definitions
.
{
"house": {
"type": "object",
"properties": {
"rooms": {
"type": "array",
"items": { "$ref": "#/room" }
}
}
},
"room": {
"type": "object",
"properties": {
"door" : { "$ref": "stuff.json#/door" }
}
}
}
And for the sake of modularity and structuring, the door
property is defined in another json file:
{
"door": {
"type": "object",
"properties": {
"material": { "type": "string" }
}
}
}
Validating an example object (which should throw a validation error because material is not a String)
{
"house": {
"rooms": [ {
"door": { "material": 1 }
}]
}
}
throws: Caused by: java.net.MalformedURLException: no protocol: stuff.json
(Stack-trace: https://pastebin.com/rQip3Gmn).
I tried to set the default resolutions scope explicitly as well with the schema builder, but the issue remains.
So my question is: why is the relative path of buildings.json#/house
resolved properly, but not stuff.json
? Am I violating the JSON schema specification?
I am thankfully looking forward to any remarks/help!
Best, Sven
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top GitHub Comments
Hello both,
I fixed the bug during the weekend and it will be included in the next release.
Hello, version
1.11.0
is out, including the fix. Thanks for the bugreport.