From 4f8931242092b437d3d76d3e40c89672c4ab8c9b Mon Sep 17 00:00:00 2001 From: hcrgm Date: Sun, 6 Nov 2016 17:13:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E6=90=9E=E5=8F=8D=E5=AF=BC=E8=87=B4=E7=9A=84=E5=BC=80?= =?UTF-8?q?=E6=BA=90=E5=8D=8F=E8=AE=AE=E5=B1=95=E7=8E=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 具体表现:当`@License`和`@LicenseUrl`在一块时 1.`@License`在前`@LicenseUrl`在后时,协议名变成了 Url xxxx 2.`@LicenseUrl`在前`@License`在后时,协议名正常,但链接指向有误(指向本地) --- g_docs.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/g_docs.go b/g_docs.go index a92c917..c09be72 100644 --- a/g_docs.go +++ b/g_docs.go @@ -70,6 +70,7 @@ func generateDocs(curpath string) { } rootapi.Infos = swagger.Information{} + rootapi.Infos.License = &swagger.License{} rootapi.SwaggerVersion = "2.0" //analysis API comments if f.Comments != nil { @@ -89,18 +90,10 @@ func generateDocs(curpath string) { rootapi.Infos.Contact.Name = strings.TrimSpace(s[len("@Name"):]) } else if strings.HasPrefix(s, "@URL") { rootapi.Infos.Contact.URL = strings.TrimSpace(s[len("@URL"):]) - } else if strings.HasPrefix(s, "@License") { - if rootapi.Infos.License == nil { - rootapi.Infos.License = &swagger.License{Name: strings.TrimSpace(s[len("@License"):])} - } else { - rootapi.Infos.License.Name = strings.TrimSpace(s[len("@License"):]) - } } else if strings.HasPrefix(s, "@LicenseUrl") { - if rootapi.Infos.License == nil { - rootapi.Infos.License = &swagger.License{URL: strings.TrimSpace(s[len("@LicenseUrl"):])} - } else { - rootapi.Infos.License.URL = strings.TrimSpace(s[len("@LicenseUrl"):]) - } + rootapi.Infos.License.URL = strings.TrimSpace(s[len("@LicenseUrl"):]) + } else if strings.HasPrefix(s, "@License") { + rootapi.Infos.License.Name = strings.TrimSpace(s[len("@License"):]) } else if strings.HasPrefix(s, "@Schemes") { rootapi.Schemes = strings.Split(strings.TrimSpace(s[len("@Schemes"):]), ",") } else if strings.HasPrefix(s, "@Host") {