From f57ebdcfba7b0ac60afff4dd2900d348fc10f294 Mon Sep 17 00:00:00 2001 From: nearyip Date: Mon, 2 Sep 2019 15:54:44 +0800 Subject: [PATCH] =?UTF-8?q?apidoc=20body=E7=9A=84example=20value=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=98=AF=E7=BB=93=E6=9E=84=E4=BD=93=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D=EF=BC=8C=E5=A6=82UserName=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E5=AE=9E=E9=99=85=E5=BC=80=E5=8F=91=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E4=B8=AD=EF=BC=8C=E4=BC=9A=E5=AD=98=E5=9C=A8=E5=A4=A7?= =?UTF-8?q?=E5=AE=B6=E4=BD=BF=E7=94=A8json=E6=B3=A8=E9=87=8A=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=EF=BC=8C=E5=8D=B3user=5Fname=EF=BC=8C?= =?UTF-8?q?=E7=9B=AE=E5=89=8Dbody=E9=87=8C=E9=9D=A2=E7=9A=84example=20valu?= =?UTF-8?q?e=E5=8D=B3=E4=BD=BF=E5=8A=A0=E4=BA=86json=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E4=B9=9F=E4=BB=8D=E7=84=B6=E6=98=AF=E4=BD=BF=E7=94=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BD=93=E7=9A=84=E5=AD=97=E6=AE=B5=E5=90=8D=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E8=B0=83=E8=AF=95=E8=B5=B7=E6=9D=A5=E8=BF=98?= =?UTF-8?q?=E8=A6=81=E5=AF=B9example=20value=E8=BF=9B=E8=A1=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E9=9D=9E=E5=B8=B8=E4=B8=8D=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=EF=BC=8C=E6=89=80=E4=BB=A5=E8=BF=99=E9=87=8C=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=88=A4=E6=96=AD=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=AD=98=E5=9C=A8json?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E7=9A=84=E8=AF=9D=EF=BC=8Cproperty=E7=9A=84k?= =?UTF-8?q?ey=E6=94=B9=E4=B8=BAjson=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + swagger/swagger.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fbb70e1..77bb4c1 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ samples/demo/demo ext/services .DS_Store +.idea diff --git a/swagger/swagger.go b/swagger/swagger.go index 6256d64..ac88f66 100644 --- a/swagger/swagger.go +++ b/swagger/swagger.go @@ -302,7 +302,12 @@ func CreateProperties(obj interface{}) map[string]*Property { fv = reflect.New(ft).Elem() } p.Default = fv.Interface() - ps[field.Name] = p + n := field.Tag.Get("json") + if n == "" { + ps[field.Name] = p + } else { + ps[n] = p + } } return ps