Skip to content

feat(ruleset): add v3 channel-parameters validation rule#1175

Closed
q404365631 wants to merge 3 commits into
asyncapi:masterfrom
q404365631:fix/v3-channel-parameters
Closed

feat(ruleset): add v3 channel-parameters validation rule#1175
q404365631 wants to merge 3 commits into
asyncapi:masterfrom
q404365631:fix/v3-channel-parameters

Conversation

@q404365631

Copy link
Copy Markdown

What

Adds the v3 counterpart of the existing asyncapi2-channel-parameters rule. The new rule asyncapi3-channel-parameters flags channels that define a parameters object while the address either has no placeholders or is null/empty.

Why

The parser currently accepts a v3 document where a channel defines a parameters object but the address has no placeholders (or is null). See #875.

The AsyncAPI spec requires parameters to map to placeholders in the address — if the address has no placeholders, parameters is redundant and the document is malformed.

The maintainer's hint in #875 was to follow the v2 rule's pattern and adjust the lookup for v3 (where the address is in value.address, not the channel key). This PR does exactly that.

Fixes #875

Changes

  • New file packages/parser/src/ruleset/v3/functions/channelParameters.ts: v3 version of the existing channelParameters function. Reads address and parameters from the channel object directly.
  • packages/parser/src/ruleset/v3/ruleset.ts: Wired the new rule as asyncapi3-channel-parameters, applied to $.channels.* and $.components.channels.* (mirroring v2's given).

Rule behavior

  • If parameters is defined and address is null/empty/has no placeholders → error: "parameters" object is redundant.
  • If address has placeholders, mirror the v2 behavior: detect missing and redundant parameters.

Example

This document (from #875) will now fail validation:

channels:
  userSignedup:
    address: user/signedup
    parameters:
      test:
        description: I should get an error...

Note

No test file added yet — happy to follow up with a *.spec.ts test file mirroring the v2 tests if preferred. Wanted to keep the first PR minimal for review.

2 files changed, 78 insertions(+), 4 deletions(-).

@changeset-bot

changeset-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7567d29

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/parser 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

@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

@princerajpoot20

Copy link
Copy Markdown
Member

the underline issue is part of microgrant program. please read the program guidlines https://github.com/asyncapi/community/blob/master/docs/010-contribution-guidelines/microgrant-program.md. thanks

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.

Parser do not validate and throw error when parameters are provided but address is null

2 participants