Conversation
Author
|
One note on the contribution guide: it asks for a The rest of the guide is covered: single atomic commit, Conventional Commits, 65-character imperative subject, no closing keywords in the commit message (only in this PR's body), and tests for the change. |
The allOf plugin generated the patches that absolutify $ref/$$ref values
after pushing the mergeDeep patch, using paths relative to the allOf
member. deepmerge concatenates arrays, so a member's `oneOf/0` ends up at
`oneOf/2` once an earlier member has already contributed to `oneOf`, and
the patch then targets a branch that has no such node:
Resolver error
Cannot read properties of undefined (reading 'items')
Generate these patches up front instead, while every member is still in
place at `allOf/<i>`, so their paths cannot go stale. The refs plugin
strips `allOf/<n>/` from the paths it records, so cycle detection keeps
working exactly as before.
Refs swagger-api/swagger-ui#11018
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
htgylzhq
force-pushed
the
fix/all-of-ref-patches-array-merge
branch
from
September 18, 2026 04:42
15d779b to
bf53c86
Compare
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.
Description
The
allOfplugin absolutifies$ref/$$refvalues viagenerateAbsoluteRefPatches. Those patches were generated after themergeDeeppatch for each member, using paths relative to that member, withallOfdropped from the path.deepmergeconcatenates arrays, so a member's array keyword does not stay where it was: once an earlier member has already contributed tooneOf, the second member'soneOf/0lives atoneOf/2in the merged parent. The patch then targets a branch that has no such node, and applying it throws:This PR generates those patches up front instead, while every member is still in place at
allOf/<i>, so their paths cannot go stale. Nothing about the merge itself changes.Two notes for reviewers:
allOftest still passed, buttest/resolver/specmap/complex.jsthen ran without finishing (~12s before, killed at 180s). Applying these patches also re-runs the refs plugin over each$ref, which is what keeps the cycle detection inrefs.jsfed; without it, recursive schemas expand without bound. There is a comment in the code about this.String(i)is deliberate. A numeric path token throwstoken.replace is not a functioninescapeJsonPointerToken(), since specmap paths are strings everywhere else.helpers.jsis unchanged: the defaultgetBaseUrlForNodePathalready resolves the member-relative base URL correctly.Motivation and Context
Fixes swagger-api/swagger-ui#11018
The reproduction in that issue uses an external Path Item pointing at an external schema, but the external files are not required — a single-document spec with local
$refs insideallOfmembers reproduces it just as well. The added unit tests cover both.How Has This Been Tested?
npm run test:unit: 91 suites / 1072 tests pass in ~27s (1070 before, +2 new tests).npm run lintclean.test/resolver/specmap/all-of.js: a minimal local-$refcase, and one mirroring the issue's external Path Item to external schema chain, mocked withundici.MockAgent.mainwith exactly the error from the issue.es/, dropped it into a Swagger UI checkout, and ran a new Cypress spec with the issue's three documents. It fails on swagger-client 3.38.2 and passes with this change; 14 other specs coveringallOf, circular refs and external file refs stay green.Screenshots (if appropriate):
n/a
Types of changes
package.json)Checklist:
🤖 Generated with Claude Code