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)}
}
validateTag := tag.GetTagValue("validate", tags)
re, _ := regexp.Compile("required *,*")
comment := re.ReplaceAllString(validateTag, "")
return comment
// trim
regStr := []string{
"required *,*",
"omitempty *,*",
}
for _, v := range regStr {
re, _ := regexp.Compile(v)
validateTag = re.ReplaceAllString(validateTag, "")
}
return validateTag
}

Loading…
Cancel
Save