Skip to content

feat: add spec-ref-targets rule#2958

Open
vadyvas wants to merge 2 commits into
mainfrom
feat/spec-ref-targets-rule
Open

feat: add spec-ref-targets rule#2958
vadyvas wants to merge 2 commits into
mainfrom
feat/spec-ref-targets-rule

Conversation

@vadyvas

@vadyvas vadyvas commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What/Why/How?

Added a new built-in rule spec-ref-targets (AsyncAPI 3 only) that validates the $ref targets the specification restricts:

  • operation and reply channel must reference a channel from the root channels object;
  • operation and reply messages must reference messages of the referenced channel;
  • channel servers must reference servers from the root servers object.

Why. These are MUST/MUST NOT requirements of the AsyncAPI 3 specification (Operation Object, Operation Reply Object, Channel Object). A document that violates them still resolves every $ref, so lint used to accept documents that AsyncAPI tooling and renderers reject

Reference

Testing

Screenshots (optional)

image

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
Additive lint rule and config/docs updates only; no runtime or security-sensitive paths changed.

Overview
Adds the built-in AsyncAPI 3 rule spec-ref-targets, which flags internal $refs that violate AsyncAPI 3.0 placement rules (root operations / channels only, with matching channel message paths and root servers on channels).

The rule is wired into recommended (warn), recommended-strict / all / spec (error), and minimal (off), with docs, sidebar, changeset, unit tests, and an e2e lint fixture.

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

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3ecbfe3

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

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 72.05% (🎯 69%) 8714 / 12093
🔵 Statements 71.73% (🎯 69%) 9067 / 12639
🔵 Functions 76.74% (🎯 73%) 1729 / 2253
🔵 Branches 63.65% (🎯 61%) 5891 / 9254
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/config/all.ts 100% 100% 100% 100%
packages/core/src/config/minimal.ts 100% 100% 100% 100%
packages/core/src/config/recommended-strict.ts 100% 100% 100% 100%
packages/core/src/config/recommended.ts 100% 100% 100% 100%
packages/core/src/config/spec.ts 100% 100% 100% 100%
packages/core/src/rules/async3/index.ts 100% 100% 100% 100%
packages/core/src/rules/async3/spec-ref-targets.ts 97.56% 95.91% 100% 100% 66
packages/core/src/types/redocly-yaml.ts 92.92% 84.9% 100% 92.7% 420, 452, 458, 502-509, 511, 670-675, 678-683
Generated in workflow #10815 for commit 3ecbfe3 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jul 22, 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 (Fastest) ▓ 1.00x (Fastest)
cli-next ▓ 1.00x (Fastest) ▓ 1.00x ± 0.01 ▓ 1.00x ± 0.02

@vadyvas

vadyvas commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3ecbfe3. Configure here.

@vadyvas
vadyvas marked this pull request as ready for review July 23, 2026 08:28
@vadyvas
vadyvas requested review from a team as code owners July 23, 2026 08:28
@vadyvas vadyvas self-assigned this Jul 23, 2026
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