fix: error can't resolve $ref when components.parameters has a ref to the components.schemas #2407
fix: error can't resolve $ref when components.parameters has a ref to the components.schemas #2407AlbinaBlazhko17 wants to merge 29 commits intomainfrom
can't resolve $ref when components.parameters has a ref to the components.schemas #2407Conversation
🦋 Changeset detectedLatest commit: 01f0066 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
4631f22 to
ec8a31c
Compare
Co-authored-by: Jacek Łękawa <164185257+JLekawa@users.noreply.github.com>
7c12980 to
06df369
Compare
|
did you check if this works for other components? headers, pathItems in 3.1.x, examples, requestBodies, responses |
|
@jeremyfiel Yeah, you are right, need to test with all cases, i will test it tomorrow. At the first glance, everything looks good and all users, that reported this bug faced it in parameters. I thought, that we covered a lot of cases in test and if all tests passes the fixes work correctly. |
This reverts commit 3a43128.
|
@jeremyfiel Great point, i implemented new fix for this case and tested for all type of components, provided in |
Co-authored-by: Andrew Tatomyr <andrew.tatomyr@redocly.com>
| resolveBundledComponent(node, resolved, ctx.location.source.absoluteRef); | ||
| // Also register from root document location if this is an external ref | ||
| // This ensures refs inside bundled components can be resolved when visited later | ||
| if (ctx.location.source !== rootDocument.source) { |
There was a problem hiding this comment.
Could you add a test to demonstrate how would such cases look like?
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ec11e38. Configure here.





What/Why/How?
The issue happens when
parameterhas a reference toschemasandremove-unused-componentsdecorator provided inredocly.yaml.This PR contains the global fix, nothing changes inside
remove-unused-componentsdecorator, because the issue happens in all decorators/rules, which are usingParametersvisitor.Reference
Resolves #2350
Testing
Ran tests and created new for this specific case.
Screenshots (optional)
Check yourself
Security
Note
Medium Risk
Touches core bundling
$reftracking (resolvedRefMap) which can affect how decorators/rules resolve references across bundled outputs; regression risk is limited by small, targeted logic plus new E2E coverage.Overview
Fixes a bundling edge case where decorators (notably
remove-unused-components) could fail withcan't resolve $refwhen a bundledcomponents.parametersentry referencedcomponents.schemas.bundle-visitornow records resolved bundled component refs inresolvedRefMapfor both the original source context and the root bundled document, andremove-unused-componentsregisters named components usingrawLocationto align with the bundled document pointers. Adds E2E fixtures covering parameter -> schema refs and removal of an unused schema$refalias, plus a smallbundledocs clarification and a patch changeset.Reviewed by Cursor Bugbot for commit 01f0066. Bugbot is set up for automated code reviews on this repo. Configure here.