From 62ea6edb9b8098cf12c7027eb51a35b42306fd87 Mon Sep 17 00:00:00 2001 From: dxyinme Date: Thu, 16 Mar 2023 01:07:44 +0800 Subject: [PATCH] fix go validator in api --- generate/parser.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generate/parser.go b/generate/parser.go index b4af259..3fae186 100644 --- a/generate/parser.go +++ b/generate/parser.go @@ -18,6 +18,7 @@ import ( var strColon = []byte(":") const ( + validateKey = "validate" defaultOption = "default" stringOption = "string" optionalOption = "optional" @@ -491,6 +492,11 @@ func renderReplyAsDefinition(d swaggerDefinitionsObject, m messageMap, p []spec. *schema.Properties = append(*schema.Properties, kv) for _, tag := range member.Tags() { + if tag.Key == validateKey { + // if you want to define a go-validator in + // go-zero api, you should ignore it + continue + } if len(tag.Options) == 0 { if !contains(schema.Required, tag.Name) && tag.Name != "required" { schema.Required = append(schema.Required, tag.Name)