Skip to content

feat: add contains assertion function for lists of strings#2794

Open
Daryna-del wants to merge 4 commits intomainfrom
feat/contains-assertion
Open

feat: add contains assertion function for lists of strings#2794
Daryna-del wants to merge 4 commits intomainfrom
feat/contains-assertion

Conversation

@Daryna-del
Copy link
Copy Markdown
Contributor

@Daryna-del Daryna-del commented Apr 30, 2026

What/Why/How?

Adds a new contains assertion for configurable rules. Previously there was no way to verify that a string array property (e.g. the required field of a schema) includes specific values, since the existing required assertion only checks object keys.

Reference

Closes #1406

Testing

Functionality covered by tests.
Tested on monorepo with snapshot version.

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

Note

Low Risk
Low risk: adds a new, opt-in assertion and associated schema/docs/test updates, with minimal impact on existing rule evaluation paths.

Overview
Adds a new configurable-rule assertion, contains, to validate that a string-array property includes all specified entries (e.g., Schema.required).

Updates the assertion registry and YAML config schema to expose contains, adds unit coverage for pass/fail cases, refreshes the related snapshot, and documents usage with a new example; includes a patch changeset for @redocly/openapi-core.

Reviewed by Cursor Bugbot for commit a403f5e. Bugbot is set up for automated code reviews on this repo. Configure here.

@Daryna-del Daryna-del self-assigned this Apr 30, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: a403f5e

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

@Daryna-del Daryna-del added the snapshot Create experimental release PR label Apr 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1777564281 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1777564281
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1777564281
# or
npm install @redocly/respect-core@0.0.0-snapshot.1777564281

⚠️ Note: This is a development build and may contain unstable features.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 1.550s ± 0.017s ▓ 1.00x (Fastest)
cli-next 1.585s ± 0.037s ▓ 1.02x

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 80.09% (🎯 80%) 7134 / 8907
🔵 Statements 79.49% (🎯 79%) 7412 / 9324
🔵 Functions 83.49% (🎯 83%) 1432 / 1715
🔵 Branches 71.68% (🎯 71%) 4835 / 6745
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/rules/common/assertions/asserts.ts 78.75% 77.62% 85.18% 86.76% 72, 95, 114, 154, 171-208, 250, 343
packages/core/src/types/redocly-yaml.ts 91.75% 83.01% 100% 91.48% 406, 438, 444, 487-494, 496, 647-652, 655-660, 663-668
Generated in workflow #9715 for commit a403f5e by the Vitest Coverage Report Action

@Daryna-del Daryna-del added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1777566516 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1777566516
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1777566516
# or
npm install @redocly/respect-core@0.0.0-snapshot.1777566516

⚠️ Note: This is a development build and may contain unstable features.

@Daryna-del Daryna-del marked this pull request as ready for review May 1, 2026 05:46
@Daryna-del Daryna-del requested review from a team as code owners May 1, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot Create experimental release PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Required assertion function for lists of strings

2 participants