openapi3: implement circular reference backtracking#970
Merged
fenollp merged 6 commits intogetkin:masterfrom Jun 26, 2024
Merged
openapi3: implement circular reference backtracking#970fenollp merged 6 commits intogetkin:masterfrom
fenollp merged 6 commits intogetkin:masterfrom
Conversation
204c38a to
1871e49
Compare
Contributor
Author
|
@fenollp I updated the PR description and its contents :) This should solve circular references resolution for good. Let me know if you have any questions or concerns |
This was referenced Jun 26, 2024
fenollp
requested changes
Jun 26, 2024
Collaborator
fenollp
left a comment
There was a problem hiding this comment.
Hi & thanks for taking the time to look into this!
Mostly LGTM, just: I see you're not using the visitref utils you're introducing in these two places and it feels like this was fogotten?
func (loader *Loader) resolveLinkRef(doc *T, component *LinkRef, documentPath *url.URL) (err error)func (loader *Loader) resolvePathItemRef(doc *T, pathItem *PathItem, documentPath *url.URL) (err error)
Could you comment on or fix that please?
Contributor
Author
|
Thanks for a quick review! I indeed missed a couple of functions. It's ready for re-review |
AnatolyRugalev
added a commit
to AnatolyRugalev/kin-openapi
that referenced
this pull request
Jun 27, 2024
* feat(loader): implement reference back-tracking * update docs * address review comments * update docs and readme * fix inconsistency * adjust readme
This was referenced Jul 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a test scenario that leads to failure of resolving recursive references.
After troubleshooting for a while, I realized that current reference tracking algorithm in not perfect and will always have some edge cases, so I decided to try fixing that for good.
During reference resolution, we keep track of all previous references, and if we find out that the reference is already being resolved, we register a backtracking callback that will assign a pointer to the resolved schema once it's done.
This guarantees that schema will always be resolved regardless of the depth.