Skip to content

Conversation

@AlbinaBlazhko17
Copy link
Contributor

@AlbinaBlazhko17 AlbinaBlazhko17 commented Nov 4, 2025

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

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

Security

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

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

🦋 Changeset detected

Latest commit: 7b0d730

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

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
Copy link
Contributor

github-actions bot commented Nov 4, 2025

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

@AlbinaBlazhko17 AlbinaBlazhko17 force-pushed the fix/cant-resolve-error-in-remove-unused-components branch from 4631f22 to ec8a31c Compare November 4, 2025 15:10
@AlbinaBlazhko17 AlbinaBlazhko17 marked this pull request as ready for review November 4, 2025 15:48
@AlbinaBlazhko17 AlbinaBlazhko17 requested review from a team as code owners November 4, 2025 15:48
@AlbinaBlazhko17 AlbinaBlazhko17 self-assigned this Nov 5, 2025
Copy link
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@AlbinaBlazhko17
Copy link
Contributor Author

AlbinaBlazhko17 commented Nov 5, 2025

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 AlbinaBlazhko17 force-pushed the fix/cant-resolve-error-in-remove-unused-components branch from 7c12980 to 06df369 Compare November 5, 2025 16:42
@jeremyfiel
Copy link
Contributor

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

@AlbinaBlazhko17
Copy link
Contributor Author

@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
Copy link
Contributor Author

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

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to demonstrate how would such cases look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove-unused-components removes parameters that are in use

5 participants