trim omitempty

pull/517/head
wuxingzhong 5 years ago
parent f18a1b713f
commit d86ba7b230
  1. 14
      tool/protobuf/protoc-gen-bswagger/generator.go

@ -327,7 +327,15 @@ func getValidateComment(field *descriptor.FieldDescriptorProto) string {
tags = []reflect.StructTag{reflect.StructTag(*moretags)} tags = []reflect.StructTag{reflect.StructTag(*moretags)}
} }
validateTag := tag.GetTagValue("validate", tags) validateTag := tag.GetTagValue("validate", tags)
re, _ := regexp.Compile("required *,*")
comment := re.ReplaceAllString(validateTag, "") // trim
return comment regStr := []string{
"required *,*",
"omitempty *,*",
}
for _, v := range regStr {
re, _ := regexp.Compile(v)
validateTag = re.ReplaceAllString(validateTag, "")
}
return validateTag
} }

Loading…
Cancel
Save