-
-
Notifications
You must be signed in to change notification settings - Fork 98
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 payload validation against asyncapi schema format #104
Conversation
@fmvilas ready for another round of review. I applied your suggestions and also added much smarter errors that point where the error is in the AsyncAPI document and not just the payload |
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 a suggestion. It's great you took the time to have the error point to the full path. I'm wondering now if it wouldn't be great to have both informations: fullPath
and path
🤔 What do you think?
lib/asyncapiSchemaFormatParser.js
Outdated
errors.forEach((val) => { | ||
val.dataPath = path + val.dataPath; | ||
}); | ||
return errors; |
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.
I have a preference for not mutating the input parameters when possible. I know it's not a problem in this case but consider using map
instead of forEach
:
return errors.map((err) => ({
...err,
...{
dataPath: `${path}${err.dataPath}`
}
}));
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.
sure thing, changed, I do not use spread operators quite often so do not consider them much during dev, but they make a lot of sense
This reverts commit 7023686.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@fmvilas what would it be useful for? I added full path as it is super useful for editors, to highlight the exact line that has error. What would |
Can't think of a use case right now but thought it's cheap to add and maybe someone would find it useful. |
@fmvilas adding is cheap, but as you said, no use case, and tbh I think at the moment that this information is completely useless, and that is why I took the effort to provide a full path |
🎉 This PR is included in version 0.24.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
Related issue(s)
Fixes #75