json-schema-validator
json-schema-validator copied to clipboard
$ref does not consider schema resources in v2019-09
Schema resources are schema documents included in compound schema documents.
Each schema with an $id in a Compound Schema Document is called a Schema Resource.
Several tests for v2019-09 are currently failing because these schema resources are not considered while resolving $ref.
For example, the second and third test in V2019JsonSchemaTest.testAnchorValidator() fails since http://localhost:1234/bar and http://localhost:1234/nested.json is not retrieved through the schema resource, but is attempted to be retrieved through normal URI retrieval.
Sidenote: the first test case in that unit test is fixed considering this open PR that makes $anchor work. I'm opening this bug report since it's not specific to anchor.
Another example is V2019JsonSchemaTest.testRefValidator(). This fails since http://localhost:1234/tree can't be retrieved.
Note that I already managed to make the second test of V2019JsonSchemaTest.testAnchorValidator() and all of testRefValidator() pass by the changes described in the PR. But, this wasn't exactly production-ready code so didn't commit it.
While playing around (not committed), I did manage to make the second
"$ref": "http://localhost:1234/bar#foo"test pass, by doing a recursive lookup of all containing JsonNodes with$idset and storing it inValidationContext. This was then retrieved inRefValidator.getRefSchema(). However, this fails for the last test which has a nested non-absolute"$id": "nested.json". Trying to resolve that as a full id was resulting in stack overflows, etc., and made me reach the limit of how much time I want to invest in this, so I won't add anything else to this PR.
It may offer a first suggested approach on how to tackle this.