Merge pull request #245 from tnextday/develop

Use first NewNamespace prefix as swagger `BasePath`
This commit is contained in:
astaxie 2016-08-19 00:13:23 +08:00 committed by GitHub
commit 55fc8e535c
1 changed files with 6 additions and 1 deletions

View File

@ -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: