Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router parsing nonsupport multi namespace in swagger(路由注解不支持多个namespace在swagger中) #519

Open
huangyunbo opened this issue Mar 30, 2018 · 3 comments

Comments

@huangyunbo
Copy link

nsv1 := beego.NewNamespace("/v1",
    beego.NSNamespace("/user",
        beego.NSInclude(
            &c_v1.UserController{},
        ),
)

nsv2 := beego.NewNamespace("/v2",
    beego.NSNamespace("/user",
        beego.NSInclude(
            &c_v2.UserController{},
        ),
)

beego.AddNamespace(nsv1, nsv2)

===========english===========
I encountered problems. In bee 1.9.1, the URL address of swagger's request address /v2/user/xxx was changed to /v1/v2/user/xxx, resulting in not found. I found the source code

1, we first discover the "basePath:/v1" in swagger.json.
2, secondly, the first parameter in NewNamespace in bee is "/v1".
3. Source code https://github.com/beego/bee/generate/swaggergen/g_docs.go

version, params := analyseNewNamespace(v)
if rootapi.BasePath == "" && version != "" {
    rootapi.BasePath = version
}

I think the core problem is swagger.json in namespace, or many swagger.json, I look at the official meaning of swagger, it should be more swagger.json to deal with.
http://petstore.swagger.io/v2/swagger.json
---------------------------^---------------

I hope directory structure as follows.
/swagger/namespace/v1/swagger.json (default)
/swagger/namespace/v2/swagger.json

===========中文===========
我遇到问题,在bee1.9.1的里面swagger中的请求地址/v2/user/xxx 的url地址被换成了 /v1/v2/user/xxx,导致not found。我找了下源码

1、首先发现swagger.json中的"basePath:/v1"。
2、其次bee中的NewNamespace中的第一个参数为"/v1"。
3、源码https://github.com/beego/bee/generate/swaggergen/g_docs.go

version, params := analyseNewNamespace(v)
if rootapi.BasePath == "" && version != "" {
    rootapi.BasePath = version
}

我想核心问题还是swagger.json中分namespace,还是多个swagger.json问题,我看swagger官方的意思,应该是多个swagger.json来处理。
http://petstore.swagger.io/v2/swagger.json
---------------------------^---------------

我希望目录结构如下:
/swagger/namespace/v1/swagger.json (default)
/swagger/namespace/v2/swagger.json

@OSMeteor
Copy link

add @basepath in router.go

@wdt1988520
Copy link

这个问题解决了吗?

@lenmx
Copy link
Contributor

lenmx commented Apr 8, 2024

可以看看 #866
https://github.com/beego/bee/pull/866

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants