asyncapi-codegen icon indicating copy to clipboard operation
asyncapi-codegen copied to clipboard

validation JSON schema

Open Irvenae opened this issue 1 year ago • 3 comments

Should we add validation for JSON schema core values?

https://json-schema.org/draft/2020-12/json-schema-validation

could be middleware which is automatically added or a defaultValidation middleware which is up to the client to add?

Irvenae avatar Feb 13 '24 15:02 Irvenae

I think that would be a great idea ! If you have any thought about the go lib that we could use, that would be great.

Also, if you want to give it a try, PR are welcome :)

lerenn avatar Feb 14 '24 10:02 lerenn

Seems like validator v10 is the way to go https://dev.to/sanjaysinghrajpoot/adding-json-validation-to-structs-in-go-lang-4mg8.

So I guess it might be already good enough to add the tags to the struct. People could add their own validator in the middleware to check this. We could provide one in the extensions that uses validator v10.

Irvenae avatar Feb 14 '24 19:02 Irvenae

I'm busy on the AsyncAPI V3 support for now, but I'll take look after that :)

lerenn avatar Feb 25 '24 18:02 lerenn