1
0
mirror of https://github.com/beego/bee.git synced 2024-11-24 23:30:55 +00:00

required description

This commit is contained in:
astaxie 2014-06-23 22:21:13 +08:00
parent b13c2068a9
commit 6181668e0a

View File

@ -535,14 +535,22 @@ func getModel(str string) (pkgpath, objectname string, m swagger.Model, realType
// if the tag contains json tag, set the name to the left most json tag
var name = field.Names[0].Name
if field.Tag != nil {
mp.Description = strings.Trim(field.Tag.Value, "`")
stag := reflect.StructTag(mp.Description)
stag := reflect.StructTag(strings.Trim(field.Tag.Value, "`"))
if tag := stag.Get("json"); tag != "" {
name = tag
}
if beedoc := stag.Get("beedoc"); beedoc == "required" {
if thrifttag := stag.Get("thrift"); thrifttag != "" {
ts := strings.Split(thrifttag, ",")
if ts[0] != "" {
name = ts[0]
}
}
if required := stag.Get("required"); required != "" {
m.Required = append(m.Required, name)
}
if desc := stag.Get("description"); desc != "" {
mp.Description = desc
}
}
m.Properties[name] = mp
}