Skip to content

chore: add linting for dataValue in example#2945

Merged
Daryna-del merged 6 commits into
mainfrom
chore/lint-dataValue-examples
Jul 16, 2026
Merged

chore: add linting for dataValue in example#2945
Daryna-del merged 6 commits into
mainfrom
chore/lint-dataValue-examples

Conversation

@Daryna-del

@Daryna-del Daryna-del commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What/Why/How?

OpenAPI 3.2 introduced dataValue as the schema-checked example field, but the linter never validated it, so invalid dataValue examples passed silently. This adds linting for dataValue against its schema, matching how value is linted.

Reference

Comment in the issue #919

Testing

Tests passed successfully on monorepo.

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
Targeted lint extension reusing existing validation; legacy value behavior is preserved and coverage is broad in tests.

Overview
Extends no-invalid-parameter-examples and no-invalid-media-type-examples so OpenAPI 3.2 Example objects are checked on dataValue the same way value already was, closing a gap where invalid structured examples could pass lint.

A shared getExampleValueToValidate helper picks dataValue when present, otherwise value, and both rules route that payload through existing AJV validation. Diagnostics now anchor under the chosen field (e.g. .../examples/foo/dataValue/name), including for $ref-resolved component examples; serializedValue is not used for schema checks.

Docs for both rules add OAS 3.2 dataValue sections; a minor @redocly/openapi-core changeset and new unit/e2e coverage document refs, booleans, binary media, and backward-compatible value on 3.2.

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

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5a2caee

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

@Daryna-del Daryna-del self-assigned this Jul 10, 2026
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 69.48% (🎯 69%) 7648 / 11006
🔵 Statements 69.22% (🎯 69%) 7964 / 11505
🔵 Functions 73.87% (🎯 73%) 1538 / 2082
🔵 Branches 61.27% (🎯 61%) 5163 / 8426
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/rules/utils.ts 92.68% 89.7% 100% 91.78% 67, 101, 111-115, 131, 142-146, 248
packages/core/src/rules/common/no-invalid-parameter-examples.ts 100% 100% 100% 100%
packages/core/src/rules/oas3/no-invalid-media-type-examples.ts 96.29% 91.66% 100% 100% 41
Generated in workflow #10730 for commit 5a2caee by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Performance Benchmark (Lower is Faster)

CLI Version Bundle Lint Check Config
cli-latest ▓ 1.00x ± 0.01 ▓ 1.00x ± 0.01 ▓ 1.00x ± 0.01
cli-next ▓ 1.00x (Fastest) ▓ 1.00x (Fastest) ▓ 1.00x (Fastest)

@Daryna-del Daryna-del added the snapshot Create experimental release PR label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1783680915

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

@Daryna-del
Daryna-del marked this pull request as ready for review July 10, 2026 15:18
@Daryna-del
Daryna-del requested review from a team as code owners July 10, 2026 15:18

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5ba3d83. Configure here.

Comment thread packages/core/src/rules/common/no-invalid-parameter-examples.ts
@Daryna-del
Daryna-del merged commit 697c52f into main Jul 16, 2026
46 of 47 checks passed
@Daryna-del
Daryna-del deleted the chore/lint-dataValue-examples branch July 16, 2026 10:18
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.

3 participants