From b160eb35b50b5bbfd7018bcb245c79628dffb2ed Mon Sep 17 00:00:00 2001 From: tnextday Date: Thu, 18 Aug 2016 23:31:09 +0800 Subject: [PATCH] Use first NewNamespace prefix as swagger `BasePath` --- g_docs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/g_docs.go b/g_docs.go index 5a0a047..45ad67a 100644 --- a/g_docs.go +++ b/g_docs.go @@ -108,8 +108,13 @@ func generateDocs(curpath string) { for _, l := range stmt.Rhs { if v, ok := l.(*ast.CallExpr); ok { // analisys NewNamespace, it will return version and the subfunction + if selName := v.Fun.(*ast.SelectorExpr).Sel.String(); selName != "NewNamespace" { + continue + } version, params := analisysNewNamespace(v) - rootapi.BasePath = version + if rootapi.BasePath == "" && version != "" { + rootapi.BasePath = version + } for _, p := range params { switch pp := p.(type) { case *ast.CallExpr: