Skip to content

fix: improve built-in decorator validation in config#2781

Merged
tatomyr merged 6 commits into
mainfrom
fix/validate-builtin-decorators-in-config
Apr 28, 2026
Merged

fix: improve built-in decorator validation in config#2781
tatomyr merged 6 commits into
mainfrom
fix/validate-builtin-decorators-in-config

Conversation

@tatomyr
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr commented Apr 27, 2026

What/Why/How?

  • Added built-in decorators/preprocessors list. This should allow detecting wrong decorator names in the config.
  • Differentiated built-in and custom rules when validating the config.
  • Refactored types and e2e tests.

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

Medium Risk
Changes affect config schema/type resolution for rules, decorators, and preprocessors, which could alter validation outcomes for existing configs (especially around key recognition and error reporting). Coverage is improved via unit and e2e tests, reducing but not eliminating regression risk.

Overview
Config validation is enhanced to detect unknown built-in decorator/preprocessor keys by introducing explicit built-in decorator lists and schema node types (BuiltinDecorator/CustomDecorator and BuiltinPreprocessor/CustomPreprocessor) and using additionalProperties resolvers to reject invalid names.

Rule validation is refined to separate built-in vs plugin rules (BuiltinRule vs new CustomRule), and TypeScript types are updated so built-in decorator/preprocessor maps are keyed by known IDs (with preprocessors treated as decorator aliases). Tests and snapshots are updated/added to cover resolver behavior and new e2e config-lint scenarios.

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

@tatomyr tatomyr self-assigned this Apr 27, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 27, 2026

🦋 Changeset detected

Latest commit: 46f6d2b

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

github-actions Bot commented Apr 27, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 80.08% (🎯 80%) 7128 / 8900
🔵 Statements 79.49% (🎯 79%) 7407 / 9317
🔵 Functions 83.47% (🎯 83%) 1430 / 1713
🔵 Branches 71.56% (🎯 71%) 4821 / 6737
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/oas-types.ts 100% 100% 100% 100%
packages/core/src/visitors.ts 92.94% 90.12% 90% 92.5% 557, 594, 597, 618, 650, 664
packages/core/src/decorators/oas2/index.ts 100% 100% 100% 100%
packages/core/src/decorators/oas3/index.ts 100% 100% 100% 100%
packages/core/src/types/redocly-yaml.ts 91.75% 83.01% 100% 91.48% 406, 438, 444, 487-494, 496, 641-646, 649-654, 657-662
Generated in workflow #9655 for commit 46f6d2b by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.215s ± 0.027s ▓ 1.00x (Fastest)
cli-next 3.256s ± 0.015s ▓ 1.01x

@tatomyr tatomyr added snapshot Create experimental release PR labels Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

Install with NPM:

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

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

@@ -1,13 +1,12 @@
[1] redocly.yaml:6:3 at #/rules/asset~1path-item-mutually-required
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 test was incorrect (not testing what it meant to).

@@ -1,7 +1,3 @@
apis:
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.

Redundant and pointing to an unexisting file.

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

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

Install with NPM:

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

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

@tatomyr tatomyr marked this pull request as ready for review April 28, 2026 06:42
@tatomyr tatomyr requested review from a team as code owners April 28, 2026 06:42
Comment thread packages/core/src/types/redocly-yaml.ts Outdated
Comment thread packages/core/src/__tests__/__snapshots__/redocly-yaml.test.ts.snap Outdated
Comment thread packages/core/src/__tests__/__snapshots__/redocly-yaml.test.ts.snap Outdated
Comment thread .changeset/orange-squids-fail.md Outdated
Co-authored-by: Jacek Łękawa <164185257+JLekawa@users.noreply.github.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 and found 2 potential issues.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 6702cb2. Configure here.

Comment thread packages/core/src/types/redocly-yaml.ts
Comment thread packages/core/src/types/redocly-yaml.ts
@tatomyr tatomyr merged commit f6303e0 into main Apr 28, 2026
45 checks passed
@tatomyr tatomyr deleted the fix/validate-builtin-decorators-in-config branch April 28, 2026 12:33
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