redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

fix: error `can't resolve $ref` when `components.parameters` has a ref to the `components.schemas`

Open AlbinaBlazhko17 opened this issue 2 months ago • 7 comments

What/Why/How?

The issue happens when parameter has a reference to schemas and remove-unused-components decorator provided in redocly.yaml. This PR contains the global fix, nothing changes inside remove-unused-components decorator, because the issue happens in all decorators/rules, which are using Parameters visitor.

Reference

Resolves #2350

Testing

Ran tests and created new for this specific case.

Screenshots (optional)

Check yourself

  • [x] Code changed? - Tested with Redoc/Realm/Reunite (internal)
  • [x] All new/updated code is covered by tests
  • [ ] New package installed? - Tested in different environments (browser/node)
  • [x] Documentation update considered

Security

  • [x] The security impact of the change has been considered
  • [x] Code follows company security practices and guidelines

AlbinaBlazhko17 avatar Nov 04 '25 15:11 AlbinaBlazhko17

🦋 Changeset detected

Latest commit: 7b0d7303bf3b9ac952463ec3109d8e9fed5f3a9d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/openapi-core Patch
@redocly/cli Patch
@redocly/respect-core Patch

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

changeset-bot[bot] avatar Nov 04 '25 15:11 changeset-bot[bot]

Command Mean [s] Min [s] Max [s] Relative
redocly lint resources/rebilly.yaml 1.446 ± 0.017 1.417 1.476 1.01 ± 0.02
redocly-next lint resources/rebilly.yaml 1.425 ± 0.019 1.395 1.457 1.00

github-actions[bot] avatar Nov 04 '25 15:11 github-actions[bot]

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 78.73% (🎯 78%) 5854 / 7435
🟢 Statements 78.17% (🎯 78%) 6049 / 7738
🟢 Functions 81.89% (🎯 81%) 1203 / 1469
🟢 Branches 70.94% (🎯 70%) 4053 / 5713
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/walk.ts 99.32% 97.01% 100% 99.28% 149-152
packages/core/src/bundle/bundle-visitor.ts 75.22% 71.05% 100% 75.22% 24, 28-36, 41-49, 56, 65, 73, 78-80, 138-150, 179-180, 212
Generated in workflow #8002 for commit 7b0d730 by the Vitest Coverage Report Action

github-actions[bot] avatar Nov 04 '25 15:11 github-actions[bot]

Please also test this change in Realm/Redoc before merging as it affects the bundler. image

Tested changes in Realm/Redoc.

Screenshot 2025-11-05 at 18 40 02 Screenshot 2025-11-05 at 18 40 19

AlbinaBlazhko17 avatar Nov 05 '25 16:11 AlbinaBlazhko17

did you check if this works for other components? headers, pathItems in 3.1.x, examples, requestBodies, responses

jeremyfiel avatar Nov 05 '25 20:11 jeremyfiel

@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.

AlbinaBlazhko17 avatar Nov 05 '25 21:11 AlbinaBlazhko17

@jeremyfiel Great point, i implemented new fix for this case and tested for all type of components, provided in remove-unused-components decorator.

AlbinaBlazhko17 avatar Nov 06 '25 16:11 AlbinaBlazhko17