-
-
Notifications
You must be signed in to change notification settings - Fork 236
fix: allow $defs and fix circular pointers issue with $ref in root #383
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Hey-hey! Thanks for this. I was facing the same issue in my code and I ended up using https://www.npmjs.com/package/patch-package to incorporate your changes and they worked out great! |
Edit: I read your description 🤦♂️ I'll take a look at the behavior changes in the next few days, but otherwise looks good |
Can you expand on the test case not being valid? If it's actually invalid we should remove the test case altogether |
The test case was like this:
And after I fixed the original issue, this was throwing an error like "property foo can't be found". The error is right because if you break it down:
But This test was passing before because since What I mean when I said "There is no test case for failing circular refs"This fix surfaced one more issue that isn't handled. Imagine a case like:
In this repo I guess this is not called circular ref. It's another kind of circular ref I call "self-referencing" ref. I am not sure how this should be handled, or even if it could be handled. But the error could be graceful at least. Right now this case causes infinite recursion. So I guess there can be a mechanism to at least prevent that. That's why I was saying the |
That makes sense. This looks good. I think the null logic that was removed comes from |
Pull Request Test Coverage Report for Build 14691060465Details
💛 - Coveralls |
Sorry for the delay on getting to this @jonluca and @KurtGokhan but I think the change makes sense! |
🎉 This PR is included in version 12.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks all. Feel free to ping me if there are any issues related to this. |
Fixes #382, #370, #356
I think all of the issues above are caused by the same root cause, that
$ref
in root object isn't correctly resolved.Changes in this PR:
Pointer.resolve
. As I see, it was there to prevent a circular reference. But it causes incorrect behavior. The root of the problem that should be fixed is that Pointer doesn't have a mechanism to detect circular (self-referencing) refs.circular-external-direct
. At first it seems like a legit test-case but it's actually not. Changed the test case to be more meaningful.$defs
in addition todefinitions