Skip to content

fix: do not assume schemas containing allOf are being used in discriminator#2817

Draft
tatomyr wants to merge 1 commit into
mainfrom
fix/unused-components
Draft

fix: do not assume schemas containing allOf are being used in discriminator#2817
tatomyr wants to merge 1 commit into
mainfrom
fix/unused-components

Conversation

@tatomyr
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr commented May 14, 2026

What/Why/How?

Fixed the no-unused-components rule to highlight unused schemas containing allOf keyword.

Reference

Related: #1209 (comment).

Testing

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

🦋 Changeset detected

Latest commit: cafc910

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


beforeEach(() => {
releaseAjvInstance();
vi.clearAllMocks();
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unrelated. Just cleaning up.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 1.989s ± 0.025s ▓ 1.00x (Fastest)
cli-next 2.011s ± 0.037s ▓ 1.01x

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 80.7% (🎯 80%) 7192 / 8912
🔵 Statements 80.08% (🎯 80%) 7471 / 9329
🔵 Functions 83.68% (🎯 83%) 1436 / 1716
🔵 Branches 72.4% (🎯 72%) 4885 / 6747
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/rules/oas3/no-unused-components.ts 94.73% 75% 100% 100% 29
packages/core/src/rules/openrpc/no-unused-components.ts 63.15% 75% 50% 66.66% 29, 56-81
Generated in workflow #9826 for commit cafc910 by the Vitest Coverage Report Action

NamedSchemas: {
Schema(schema, { location, key }) {
if (!schema.allOf) {
// FIXME: find a better way to detect possible discriminator
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is getting resolved by discriminator mapping, which is being treated as $refs, so the components are properly recognized as used when they are referenced in discriminator mapping.

@tatomyr tatomyr force-pushed the fix/unused-components branch from 62c8dba to cafc910 Compare May 14, 2026 14:51
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.

1 participant