fix: allow $defs and fix circular pointers issue with $ref in root#383
fix: allow $defs and fix circular pointers issue with $ref in root#383jonluca merged 1 commit intoAPIDevTools:mainfrom
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. |
…n. (#398) This changes the URL parsing behavior to actually respect RFC 6901. Previously we were URL encoding too often. This will be considered a breaking change, as it will change how previously parsed documents are bundled and dereferenced. This also adds a new mergeKey option. Additionally, the new output will be ESM. Should fix #383, #356, and makes progress on #370 BREAKING CHANGE: Change URL encoding to use strict RFC 6901, add new mergeKeys dereference option
|
🎉 This PR is included in version 15.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #382, #370, #356
I think all of the issues above are caused by the same root cause, that
$refin 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.$defsin addition todefinitions