fix: Fix relative references inside external path items (#1948, #2066) - #2393
Open
ewaostrowska wants to merge 2 commits into
Open
fix: Fix relative references inside external path items (#1948, #2066)#2393ewaostrowska wants to merge 2 commits into
ewaostrowska wants to merge 2 commits into
Conversation
ewaostrowska
force-pushed
the
issues-1948-2066
branch
from
August 27, 2026 07:36
8689cea to
638fe84
Compare
ewaostrowska
force-pushed
the
issues-1948-2066
branch
from
August 27, 2026 08:07
638fe84 to
c07a071
Compare
djankows
approved these changes
Aug 28, 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 a path item is defined in an external file, that file can contain references to other files. Those nested references are relative paths, so they should be resolved relative to the external file's own location.
The parser was resolving them relative to the root document instead. If your external file lived in
product/product-api.yamland referenced a siblingproduct-components.yaml, the parser went looking forproduct-components.yamlat the root level, failed, and either threw an error or silently dropped the component.Root causes
1.
isAbsoluteRefmisclassified bare filenames as absoluteproduct-components.yamldoes not start with a dot, so the old code treated it as absolute and skipped rebasing entirely. A URI is only absolute when it has a scheme (https://,file://, etc.).2.
computeRelativeRefbailed out immediately for./refsThe fix uses
URI.resolve(), which is how browsers resolve relative links. Given a base and a relative reference, it produces the correct result including normalizing dot segments:Example — issue #2066:
./sub-dir/params.json./sub-dir2/pagination_params_1.json./sub-dir/sub-dir2/pagination_params_1.jsonExample — issue #1948:
product/product-api.yamlproduct-components.yaml#/components/parameters/param1product/product-components.yaml#/components/parameters/param13. Schemas and examples need a guard against double-rebasing
ExternalRefProcessoralready rebases schema and example refs when it loads an external path item. IfPathsProcessorthen ran the fullcomputeRefon those refs a second time,./-prefixed schemas would get rebased twice and end up wrong.The new
computePreprocessedRefmethod is used for schemas and examples. It handles../refs and fragment-only refs, but leaves./refs and bare names alone (already handled upstream). Parameter$refs do not go throughExternalRefProcessor, so they still use the fullcomputeRef.What is not covered
The separate response-header behaviors reported in #2060 are outside the scope of this PR.
Fixes: #2066 and #1948
Type of Change
Checklist
Screenshots / Additional Context