Skip to content

fix: no-required-schema-properties rule to report when required properties are not defined in all branches#2705

Open
tatomyr wants to merge 1 commit intomainfrom
fix/no-required-schema-properties-undefined
Open

fix: no-required-schema-properties rule to report when required properties are not defined in all branches#2705
tatomyr wants to merge 1 commit intomainfrom
fix/no-required-schema-properties-undefined

Conversation

@tatomyr
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr commented Mar 31, 2026

What/Why/How?

  • Fixed the no-required-schema-properties-undefined rule to report when a required property is not defined in every oneOf/anyOf branch.
  • Refactored the no-required-schema-properties rule code to avoid the 'grandparents' concept
  • Refactored tests: make the descriptions clearer and removed duplications.

Discovered internally.

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

…rties are not defined in all branches

chore: refactor the no-required-schema-properties rule
@tatomyr tatomyr self-assigned this Mar 31, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

🦋 Changeset detected

Latest commit: c0cb033

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

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.65% (🎯 79%) 6586 / 8268
🔵 Statements 79.14% (🎯 78%) 6814 / 8610
🔵 Functions 83.03% (🎯 82%) 1346 / 1621
🔵 Branches 71.5% (🎯 71%) 4490 / 6279
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/rules/common/no-required-schema-properties-undefined.ts 100% 100% 100% 100%
Generated in workflow #9232 for commit c0cb033 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

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

});

it('should NOT report if one or more of the required properties are defined when used in schema with anyOf keyword', async () => {
it('should report when required properties are not declared in all anyOf branches', async () => {
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.

This is the actual test case added.

`);
});

it('should not report required properties are present after resolving $refs when used in schema with allOf keyword', async () => {
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.

Removed as duplicated.

return {};
}
visitedSchemas.add(schema);
const hasProperty = (
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.

Refactored similarly to the spec-discriminator-defaultMapping rule.

@tatomyr tatomyr marked this pull request as ready for review March 31, 2026 07:50
@tatomyr tatomyr requested review from a team as code owners March 31, 2026 07:50
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.

2 participants