-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Spectral rules to validate required operation channe and channel servers field #913
feat: add Spectral rules to validate required operation channe and channel servers field #913
Conversation
field: 'channel.$ref', | ||
function: pattern, | ||
functionOptions: { | ||
match: '#\\/channels\\/', // If doesn't match, rule fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmvilas @jonaslagoni I simplified this by using this pattern
function Spectral gives us. It allows to match by a regex applied to a field, in this case channel.$ref
.
In consequence, I removed the function I created in favor of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄
@jonaslagoni @fmvilas FYI I've added to this PR also another rule that checks that the servers field of a required channel (under root) points to a subset of required (under root) servers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just this typo.
src/ruleset/v3/ruleset.ts
Outdated
* Channel Object rules | ||
*/ | ||
'asyncapi3-required-channel-servers-unambiguity': { | ||
description: 'The "servers" field of a channel under the root "channels" object must always reference to a subset of the servers under the root "servers" object.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: 'The "servers" field of a channel under the root "channels" object must always reference to a subset of the servers under the root "servers" object.', | |
description: 'The "servers" field of a channel under the root "channels" object must always reference a subset of the servers under the root "servers" object.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed (didnt apply the suggestion because changes in the expected error msg in tests were needed)
Kudos, SonarCloud Quality Gate passed! |
/rtm |
🎉 This PR is included in version 3.0.0-next-major-spec.14 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
Part of asyncapi/spec#991
Despite the name of the branch, this PR adds two new Spectral rules (packed all together to minimize review efforts and to release asap).
This PR adds the last two new Spectral rules related with asyncapi/spec#991.
channel
field of a required operation (under root) points to a required (under root) channel and not to an optional (under components) channel, no matter if from the same document or from an external.servers
field of a required channel (under root) points to a subset of required (under root) servers.Related issue(s)
asyncapi/spec#991