1
0
mirror of https://github.com/beego/bee.git synced 2024-12-22 15:10:49 +00:00

Merge pull request #122 from simpleton/bug/docs

make docs works when EnableDocs = false
This commit is contained in:
astaxie 2015-07-02 21:37:19 +08:00
commit f74078b69f

View File

@ -55,22 +55,24 @@ var rootapi swagger.ResourceListing
var apilist map[string]*swagger.ApiDeclaration
func init() {
err := json.Unmarshal([]byte(Rootinfo), &rootapi)
if err != nil {
beego.Error(err)
}
err = json.Unmarshal([]byte(Subapi), &apilist)
if err != nil {
beego.Error(err)
}
beego.GlobalDocApi["Root"] = rootapi
for k, v := range apilist {
for i, a := range v.Apis {
a.Path = urlReplace(k + a.Path)
v.Apis[i] = a
if beego.EnableDocs {
err := json.Unmarshal([]byte(Rootinfo), &rootapi)
if err != nil {
beego.Error(err)
}
err = json.Unmarshal([]byte(Subapi), &apilist)
if err != nil {
beego.Error(err)
}
beego.GlobalDocApi["Root"] = rootapi
for k, v := range apilist {
for i, a := range v.Apis {
a.Path = urlReplace(k + a.Path)
v.Apis[i] = a
}
v.BasePath = BasePath
beego.GlobalDocApi[strings.Trim(k, "/")] = v
}
v.BasePath = BasePath
beego.GlobalDocApi[strings.Trim(k, "/")] = v
}
}