feat(ruleset): add v3 channel-parameters validation rule#1175
Closed
q404365631 wants to merge 3 commits into
Closed
feat(ruleset): add v3 channel-parameters validation rule#1175q404365631 wants to merge 3 commits into
q404365631 wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 7567d29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Adds the v3 counterpart of the existing
asyncapi2-channel-parametersrule. The new ruleasyncapi3-channel-parametersflags channels that define aparametersobject while theaddresseither has no placeholders or isnull/empty.Why
The parser currently accepts a v3 document where a channel defines a
parametersobject but theaddresshas no placeholders (or is null). See #875.The AsyncAPI spec requires
parametersto map to placeholders in the address — if the address has no placeholders,parametersis 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
packages/parser/src/ruleset/v3/functions/channelParameters.ts: v3 version of the existingchannelParametersfunction. Readsaddressandparametersfrom the channel object directly.packages/parser/src/ruleset/v3/ruleset.ts: Wired the new rule asasyncapi3-channel-parameters, applied to$.channels.*and$.components.channels.*(mirroring v2'sgiven).Rule behavior
parametersis defined andaddressisnull/empty/has no placeholders → error:"parameters" object is redundant.addresshas placeholders, mirror the v2 behavior: detect missing and redundant parameters.Example
This document (from #875) will now fail validation:
Note
No test file added yet — happy to follow up with a
*.spec.tstest file mirroring the v2 tests if preferred. Wanted to keep the first PR minimal for review.2 files changed, 78 insertions(+), 4 deletions(-).