Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fragment references using $anchor #500

Merged
merged 2 commits into from
Jan 26, 2022
Merged

Support fragment references using $anchor #500

merged 2 commits into from
Jan 26, 2022

Conversation

Whathecode
Copy link
Contributor

As is, this PR already resolves the first test case in V201909JsonSchemaTest.testAnchorValidator(), but not the latter two which include absolute URIs.

It causes java.io.FileNotFoundException: http://localhost:1234/bar due to "$ref": "http://localhost:1234/bar#foo" pointing to a local $id.

I suspect this fails for the same reason some of the other V2019_09 currently fail, e.g. testRefValidator().

It seems like this PR may already resolve the original issue I ran into (the first test case). It's less obvious how to resolve these next two errors, and whether they are related at all. Could this PR be released, as is, already? Perhaps by splitting up the test cases?

Closes #227

@Whathecode Whathecode marked this pull request as ready for review January 25, 2022 00:13
@Whathecode
Copy link
Contributor Author

Whathecode commented Jan 25, 2022

I attempted to resolve the remaining failing tests, but am too unfamiliar with the codebase to make this work. Furthermore, the deeper I dig into fixing this, the more I notice this is an unrelated bug. The tests still fail even if the anchors are removed.

I will therefore consider this out of scope for this PR.

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 $id set and storing it in ValidationContext. This was then retrieved in RefValidator.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.

@Whathecode
Copy link
Contributor Author

I filed a new bug report for the $ref issue. This issue is not specific to $anchor, so I suggest to consider it out of scope for this PR.

@stevehu stevehu merged commit 8fce164 into networknt:master Jan 26, 2022
@Whathecode Whathecode deleted the anchor-ref-2019 branch January 26, 2022 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add anchor validator for v2019-09
2 participants