fix: error `can't resolve $ref` when `components.parameters` has a ref to the `components.schemas`
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
🦋 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
| 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 |
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 |
Please also test this change in Realm/Redoc before merging as it affects the bundler.
Tested changes in Realm/Redoc.
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.
@jeremyfiel Great point, i implemented new fix for this case and tested for all type of components, provided in remove-unused-components decorator.
