From 6181668e0aec2d307b7d72db45fc055f55d27513 Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 23 Jun 2014 22:21:13 +0800 Subject: [PATCH] required description --- g_docs.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/g_docs.go b/g_docs.go index 1814abe..f3b6be3 100644 --- a/g_docs.go +++ b/g_docs.go @@ -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 }