swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.65k stars 1.19k forks source link

[BUG] incompatibe with validate from github.com/go-playground/validator #1886

Open Dexus opened 1 month ago

Dexus commented 1 month ago

This Tool is incompatible with github.com/go-playground/validator

XiXiangFiles commented 3 weeks ago

Hi, can you provide some examples? My project also uses validators, but I haven't encountered your issue

Dexus commented 3 weeks ago

@XiXiangFiles

go-playground/validator is using the struct tag validate

and your tools use it also, so it breaks on validations.

I will check that I provide a examlpe once I got an ok for it.

ubogdan commented 4 days ago

@Dexus Don't be lazy. You can decorate func (m *ModelName) Validate() errror for every model that requires validation and control validation from code. Overwhelming the struct with tags may get very frustrating when you will need to have different validation behaviors for update and create operations. Also, struct tags are evaluated at runtime using reflection which is not the most performant thing in Golang.