From 205428abcead96aac3aaf3fa8f8fe8ca5be1eff2 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 22 Sep 2016 22:26:39 +0800 Subject: [PATCH] fix the licence issue --- g_docs.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/g_docs.go b/g_docs.go index cd1b958..8a7f99d 100644 --- a/g_docs.go +++ b/g_docs.go @@ -90,9 +90,17 @@ func generateDocs(curpath string) { } else if strings.HasPrefix(s, "@URL") { rootapi.Infos.Contact.URL = strings.TrimSpace(s[len("@URL"):]) } else if strings.HasPrefix(s, "@License") { - rootapi.Infos.License.Name = strings.TrimSpace(s[len("@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") { - rootapi.Infos.License.URL = strings.TrimSpace(s[len("@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"):]) + } } else if strings.HasPrefix(s, "@Schemes") { rootapi.Schemes = strings.Split(strings.TrimSpace(s[len("@Schemes"):]), ",") } else if strings.HasPrefix(s, "@Host") {