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(rulesets): validate channel servers, server securities and operation securities #2122

Merged
merged 6 commits into from
Jun 29, 2022

Conversation

magicmatatjahu
Copy link
Contributor

@magicmatatjahu magicmatatjahu commented Apr 12, 2022

Fixes #2124
Fixes #2123
Fixes #2162

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Additional context

Part of #2100

This PR adds three rules:

  • one validates that channel-level servers exist (we compare names in servers with those defined in channels.*.servers).
  • second rule checks if defined security schemas in servers.*.security exist in components.securitySchemes.
  • third rule checks if defined security schemas in channels.*.[publish,subscribe].security exist in components.securitySchemes.

@magicmatatjahu magicmatatjahu added enhancement New feature or request AsyncAPI Issues related to the AsyncAPI ruleset labels Apr 12, 2022
Copy link
Collaborator

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Only had one comment.

docs/reference/asyncapi-rules.md Show resolved Hide resolved
@magicmatatjahu magicmatatjahu changed the title feat(rulesets): add rules to validate channels.*.servers and servers.*.security feat(rulesets): add rules to validate channels.*.servers, servers.*.security, channels.*.[publish/subscribe].security.* May 19, 2022
@magicmatatjahu magicmatatjahu changed the title feat(rulesets): add rules to validate channels.*.servers, servers.*.security, channels.*.[publish/subscribe].security.* feat(rulesets): add rules to validate channels.*.servers, servers.*.security and operations.*.security May 19, 2022
@magicmatatjahu magicmatatjahu changed the title feat(rulesets): add rules to validate channels.*.servers, servers.*.security and operations.*.security feat(rulesets): add rules to channel servers, server securities and operation securities May 19, 2022
@magicmatatjahu magicmatatjahu changed the title feat(rulesets): add rules to channel servers, server securities and operation securities feat(rulesets): validate channel servers, server securities and operation securities May 19, 2022
@magicmatatjahu magicmatatjahu changed the title feat(rulesets): validate channel servers, server securities and operation securities feat(rulesets): validate channel servers, server securities and operation securities now May 19, 2022
@magicmatatjahu magicmatatjahu changed the title feat(rulesets): validate channel servers, server securities and operation securities now feat(rulesets): validate channel servers, server securities and operation securities May 19, 2022
@magicmatatjahu
Copy link
Contributor Author

@jonaslagoni Could you check that PR? Thanks!

Copy link
Collaborator

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

LGTM 👍

function asyncApi2ChannelServers(targetVal, _) {
const results: IFunctionResult[] = [];
if (!targetVal.channels) return results;
const serverNames = Object.keys(targetVal.servers ?? {});
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if there are no servers declared but the channels declares a value under servers channel field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@magicmatatjahu
Copy link
Contributor Author

@P0lip Hello! @jonaslagoni just accepted that PR. I guess we need your accept, because I changed also docs. Thanks!

Copy link
Contributor

@P0lip P0lip left a comment

Choose a reason for hiding this comment

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

🚀

@P0lip P0lip enabled auto-merge (squash) June 29, 2022 18:04
@P0lip P0lip merged commit 9accd31 into stoplightio:develop Jun 29, 2022
@magicmatatjahu magicmatatjahu deleted the asyncapi/channel-servers branch June 30, 2022 07:23
stoplight-bot pushed a commit that referenced this pull request Jun 30, 2022
# [@stoplight/spectral-rulesets-v1.11.0](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-rulesets-v1.10.0...@stoplight/spectral-rulesets-v1.11.0) (2022-06-30)

### Features

* **rulesets:** validate channel servers, server securities and operation securities ([#2122](#2122)) ([9accd31](9accd31))
@stoplight-bot
Copy link
Collaborator

🎉 This PR is included in version @stoplight/spectral-rulesets-v1.11.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AsyncAPI Issues related to the AsyncAPI ruleset enhancement New feature or request released
Projects
None yet
5 participants