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

fix(rulesets): handle empty payload and headers in AsyncAPI message's examples validation #2284

Merged

Conversation

magicmatatjahu
Copy link
Contributor

@magicmatatjahu magicmatatjahu commented Sep 19, 2022

Checklist

  • Tests added / updated
  • Docs added / updated - not needed

Does this PR introduce a breaking change?

  • Yes
  • No

The current rule for AsyncAPI message's examples not support use cases where payloads or headers may be empty. Also it does not merge traits in first row and then validate. That PR fix these two "bugs".

@magicmatatjahu magicmatatjahu added enhancement New feature or request AsyncAPI Issues related to the AsyncAPI ruleset labels Sep 19, 2022
@P0lip P0lip force-pushed the develop branch 2 times, most recently from 29d2c52 to a7f9fa7 Compare October 3, 2022 15:02
@P0lip P0lip requested a review from a team as a code owner October 3, 2022 15:02
@magicmatatjahu magicmatatjahu force-pushed the asyncapi/fix-message-examples-rule branch 2 times, most recently from c180dc3 to dd647d6 Compare October 5, 2022 11:50
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.

Just one comment in terms of traits, as this makes it easier for developers that stumble upon the code to follow it.

Otherwise it looks good 👍


type HaveTraits = { traits?: any[] } & Record<string, any>;

export function mergeTraits<T extends HaveTraits>(data: T): T {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably add some more docs here and specifically stating that this is JSON Merge Patch.

https://www.rfc-editor.org/rfc/rfc7386

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks! :)

jonaslagoni
jonaslagoni previously approved these changes Oct 5, 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.

👍

jonaslagoni
jonaslagoni previously approved these changes Oct 5, 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.

🐆

@magicmatatjahu
Copy link
Contributor Author

@P0lip Could you review and merge PR? 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.

Other than the yarn.lock, everything looks good to me

yarn.lock Outdated
@@ -2444,6 +2444,25 @@ __metadata:
languageName: node
Copy link
Contributor

Choose a reason for hiding this comment

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

could you revert this yarn.lock change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@P0lip I reverted, but it was very strange, because without execution of yarn tests were failing. Let's see if it passes this time.

@P0lip P0lip merged commit 4068221 into stoplightio:develop Oct 5, 2022
@magicmatatjahu magicmatatjahu deleted the asyncapi/fix-message-examples-rule branch October 5, 2022 15:25
stoplight-bot pushed a commit that referenced this pull request Oct 6, 2022
# [@stoplight/spectral-rulesets-v1.14.1](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-rulesets-v1.14.0...@stoplight/spectral-rulesets-v1.14.1) (2022-10-06)

### Bug Fixes

* **rulesets:** handle empty payload and headers in AsyncAPI message's examples validation ([#2284](#2284)) ([4068221](4068221))
@stoplight-bot
Copy link
Collaborator

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

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
Development

Successfully merging this pull request may close these issues.

None yet

4 participants