feature: support JSON-Schema validation
Adding support for basic json-schema validations. Related to #131
A few notes:
- The list of validations supported by asyncapi can be found here
- All validations that were straightforward to implement should be here. Most non-implemented validations are because they rely on nested schema (Contains, AllOf, Items...) or are simply not supported by validator/v10
- I didn't implement anything for asyncapi v2, since currently, the schema does not contain the fields necessary for the validation. I would advise having a common struct for both v2/v3 schema to simplify reusing the GenerateValidateTags code for both
- We only generate the required
validatetag in the struct, and no effort is made to include the actual validation in the middleware or anything (not required for my use case, and it would probably let the user configure the validation; felt more complicated that necessary)
Please let me know if you need any change or information
Thanks TheSadlig
Hello @TheSadlig ! Thanks for the PR ! It is really valuable ☺️ I'll review it in the next days !
@lerenn Actually, my use-case requires asyncapi v2, so I updated the PR to include this, moving the fields related to validations to a struct that is embedded in both V2 and V3. It avoids having to duplicate the Validation field generation for both versions.
Whenever you have the time ;)
Just fixed the linting to avoid another ping-pong, so we're good to go !