fix: prevent false circular-reference errors on external $ref schemas#179
Open
TristanSpeakEasy wants to merge 2 commits intomainfrom
Open
fix: prevent false circular-reference errors on external $ref schemas#179TristanSpeakEasy wants to merge 2 commits intomainfrom
TristanSpeakEasy wants to merge 2 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📊 Test Coverage ReportCurrent Coverage: Coverage Change: ✅ No change Coverage by Package
📋 Detailed Coverage by Function (click to expand)
Generated by GitHub Actions |
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.
Summary
Fixes false
circular-reference-invaliderrors when OpenAPI specs use external$refs to split schemas across multiple files (OAPI-5684).Root Cause
The pre-population step in
jsonschema/oas3/resolution.gowas unconditionally overwritingreferenceResolutionCacheon nested refs during external file resolution. When the same external file was encountered through different reference paths:AbsoluteReferencevaluesFix
Guard the pre-population with a nil/incomplete check — only populate the cache if it hasn't already been set by a previous (correct) resolution:
Changes
jsonschema/oas3/resolution.go: Conditional cache pre-population to prevent overwriting correct cachesopenapi/index_external_test.go: Three regression tests covering relative target locations, deep nesting, and the component indirection pattern that triggered the bugopenapi/testdata/inline/inline_expected.yaml: Updated expected output to reflect correct inlining behavior