Fix: resolution of external refs inside path items with templated fragments (#2033) - #2394
Open
ewaostrowska wants to merge 2 commits into
Open
Fix: resolution of external refs inside path items with templated fragments (#2033)#2394ewaostrowska wants to merge 2 commits into
ewaostrowska wants to merge 2 commits into
Conversation
djankows
approved these changes
Aug 27, 2026
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.
Pull Request
Description
When an external path item is referenced with a URL whose fragment contains an OpenAPI path template (e.g.
traceability/nodes.yaml#/paths/~1nodes~1{uuid}~1rights), any response headers, links, or examples inside that path item that point to further external files fail to resolve. Instead of the correct component, the reference ends up pointing at the parent path item, which is the wrong type.What was broken
processRefHeaders,processRefLinks, andprocessRefExampleseach computed the external file path correctly,but then passed the full
$ref(fragment included) down to the nested processor. InsideprocessRefHeader, thejoincall constructednew URI(source)with that string. The raw{character is not valid in a URI, so the constructor throwed, the catch block silently returns the original source string, and the header ends up pointing at the parent path item rather thancommon-spec-openapi.yaml#/components/headers/Content-Range.The same bug affected links and examples in the same code path.
What changed
ExternalRefProcessor.processRefHeaders(~line 920): passesfileinstead of$reftoprocessRefHeader, so the join operation never sees the raw-brace fragment.ExternalRefProcessor.processRefExamples(~line 870): same fix for examples.ExternalRefProcessor.processRefLinks(~line 931): same fix for links.Also refactores
processRefinto a separate method to avoid duplicating code.fThis mirrors a fix applied to the schema code path which had the same problem.
Fixes: #2033
Type of Change
Checklist
Screenshots / Additional Context