Skip to content

Comments

feat: add target to the filter-in and filter-out decorators#2570

Open
tatomyr wants to merge 13 commits intomainfrom
feat/modify-filter-in-decorator
Open

feat: add target to the filter-in and filter-out decorators#2570
tatomyr wants to merge 13 commits intomainfrom
feat/modify-filter-in-decorator

Conversation

@tatomyr
Copy link
Collaborator

@tatomyr tatomyr commented Feb 17, 2026

What/Why/How?

Added new options to the filter-in and filter-out decorators, allowing to filter through a specific target nodes (PathItem or Operation).

This solves an issue where users want to filter in/out specific nodes (i.e. Operations) and leave other nodes that might contain the property untouched (for instance, in Schemas). However, with the current implementation of filter-in/out we cannot scope where to look by nodes, only by specifying the property, so the decorator walks through all nodes looking for the specified property.

A note for reviewers: I'm still not convinced that we need noPropertyStrategy option in filter-in. For me it seems natural that we don't keep a node that doesn't match the specified property when filtering in.

Reference

Resolves #2464

Related contribution: #2536

Alters #2555.

Testing

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 Feb 17, 2026

🦋 Changeset detected

Latest commit: 649abfd

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 Minor
@redocly/cli Minor
@redocly/respect-core Minor

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 Feb 17, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.71% (🎯 79%) 6413 / 8045
🔵 Statements 79.15% (🎯 78%) 6626 / 8371
🔵 Functions 83.57% (🎯 83%) 1313 / 1571
🔵 Branches 71.4% (🎯 71%) 4382 / 6137
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/decorators/common/filters/filter-in.ts 96.96% 96.66% 100% 96.87% 82
packages/core/src/decorators/common/filters/filter-out.ts 96.55% 90% 100% 96.42% 73
packages/core/src/decorators/oas2/index.ts 100% 100% 100% 100%
packages/core/src/decorators/oas3/index.ts 100% 100% 100% 100%
Generated in workflow #8733 for commit 649abfd by the Vitest Coverage Report Action

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.493s ± 0.042s ▓ 1.00x
cli-next 3.488s ± 0.023s ▓ 1.00x (Fastest)

@tatomyr tatomyr force-pushed the feat/modify-filter-in-decorator branch from b80cdea to e44a257 Compare February 18, 2026 17:10
| value | [string] | **REQUIRED.** List of values used for the matching. |
| matchStrategy | string | Possible values: `all`, `any`. If `all` it needs to match all of the values supplied. If `any` it needs to match only one of the values supplied. Default value: `any`. |
| target | string | Possible values: `PathItem`, `Operation`. When set, filtering is scoped to the specified target. |
| noPropertyStrategy | string | Possible values: `keep`, `remove` (default value: `keep`). Decides whether to keep nodes without the specified property when `target` is set. |
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The default still looks wrong to me.

Copy link
Collaborator Author

@tatomyr tatomyr Feb 18, 2026

Choose a reason for hiding this comment

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

I'd rather suggest removing this and line 22, and always remove target nodes with no property that we're filtering-in by. (It even sounds much more logical to filter-in only nodes with the matching propery+value.)

To me, this aligns better with the filter-out logic. What do you think?

@tatomyr tatomyr requested a review from RomanHotsiy February 19, 2026 16:02
@tatomyr tatomyr changed the title Feat/modify filter in decorator feat: add target to the filter-in decorator Feb 19, 2026
@tatomyr tatomyr force-pushed the feat/modify-filter-in-decorator branch from bddb2b6 to 83012a6 Compare February 19, 2026 16:49
@tatomyr tatomyr marked this pull request as ready for review February 19, 2026 17:29
@tatomyr tatomyr requested review from a team as code owners February 19, 2026 17:29
@tatomyr tatomyr marked this pull request as draft February 19, 2026 20:00
@tatomyr tatomyr changed the title feat: add target to the filter-in decorator feat: add target to the filter-in and filter-out decorators Feb 20, 2026
@tatomyr tatomyr force-pushed the feat/modify-filter-in-decorator branch from 62d94a1 to d309a86 Compare February 20, 2026 12:20
@tatomyr tatomyr marked this pull request as ready for review February 20, 2026 12:43
@tatomyr tatomyr requested a review from adamaltman February 20, 2026 12:44
@tatomyr tatomyr requested a review from JLekawa February 20, 2026 13:04
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.

Decorator to include only public items

2 participants