参数解析增加解析标题

This commit is contained in:
白茶清欢 2025-02-07 18:16:34 +08:00
parent 7ddd96bcb7
commit bd01c39fcc
2 changed files with 6 additions and 0 deletions

View File

@ -158,9 +158,14 @@ func (c controller) parseParamConfig(formDataType reflect.Type) []UriParam {
if len(validate) == 0 {
validate = strings.TrimSpace(structField.Tag.Get(TagNameValidate))
}
title := strings.TrimSpace(structField.Tag.Get(TagNameDesc))
if len(title) == 0 {
title = jsonTag
}
res = append(res, UriParam{
Field: structField.Name,
Name: jsonTag,
Title: title,
Type: structField.Type.String(),
Validate: validate,
ErrorMsg: "",

View File

@ -53,6 +53,7 @@ type UriConfig struct {
type UriParam struct {
Field string `json:"field"` // 结构体字段
Name string `json:"name"` // 参数名称
Title string `json:"title"` // 参数标题
Type string `json:"type"` // 参数类型
Validate string `json:"validate"` // 验证规则: validator/v10 库
ErrorMsg string `json:"error_msg"` // 验证失败的错误信息