Skip to content
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 rule to validate operation messages #911

Merged

Conversation

smoya
Copy link
Member

@smoya smoya commented Nov 27, 2023

Description

Part of asyncapi/spec#991

This PR adds all the scaffolding for adding Spectral rules to v3 plus the first of three new rules related with asyncapi/spec#991.
This rule, in particular, checks that operation messages, no matter where they are located, need to point to messages from the channel specified in its channel field.

Related issue(s)
asyncapi/spec#991

const channelPointer = targetVal.channel?.$ref as string; // required

targetVal.messages?.forEach((message, index) => {
if (!message.$ref.startsWith(`${channelPointer}/messages`)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it that simple, or am I'm missing any edge case here? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's right yeah 👍

Copy link

sonarcloud bot commented Nov 27, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

const channelPointer = targetVal.channel?.$ref as string; // required

targetVal.messages?.forEach((message, index) => {
if (!message.$ref.startsWith(`${channelPointer}/messages`)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's right yeah 👍

@jonaslagoni jonaslagoni merged commit fe51a04 into asyncapi:next-major-spec Nov 27, 2023
13 checks passed
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 3.0.0-next-major-spec.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants