Skip to content

fix: allow $defs and fix circular pointers issue with $ref in root #383

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KurtGokhan
Copy link

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:

  • Removed the short-circuit in 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.
    • There is no test case for failing circular refs. But it's a configuration error and cannot be dereferenced anyway. I think it's an advanced use case that doesn't need to be handled.
    • The change in Pointer caused one test to break, which is 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.
  • Added handling for $defs in addition to definitions
  • Used Vitest snapshots for tests. Let me know if there is a reason to keep using the utils other tests are using.
  • Ran prettier format

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.

Resolving top-level $ref fails with TypeError: Converting circular structure to JSON
1 participant