Open reitzig opened 6 years ago
I traced the problem down to Addressable::URI.join
being called on a UUID for references in the top-level schema, but on a real path (that of the top-level schema) for low levels.
cf. JSON::Util::URI.absolutize_ref
Then, the dir-part absolute path of the top-level schema and the relative path to the schema are joined together without considering the overlap.
Not sure what the correct fix here is.
ref
URI (the one of the current schema).Workaround: Call validate
with the filename of the top-level schema instead of its content.
Then, all URIs are treated in the same way (Option 1).
Consider the following folder structure with files as given in this Gist:
Expected: Running
validate.rb
prints0
.Actual:
Clearly, the path is assembled incorrectly:
schemaA.json
toschemaB.json
is correctly interpreted as relative to the working directory.schemaB.json
toschemaC.json
is interpreted as relative toschemaB.json
.This is inconsistent.
Is there a workaround? Changing the
$ref
paths is not an option if schemas are referenced at different depths.