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

/auth 在路由中已经写成了 POST 方法,但是 swagger 中显示的是 GET #118

Open
RussellCao824 opened this issue Jul 30, 2020 · 8 comments

Comments

@RussellCao824
Copy link

刚下载了代码,发现在swagger页面中调用/auth一直显示 404 page not found
查看代码发现,在routers/router.go中,/auth路由定义的是POST方法,而swagger页面中显示的是GET方法。
image
image
之后,我在postman中使用post方法,带参数请求/auth,还是显示 404 page not found
image
请问一下,是我使用的姿势不对吗?感谢。

@woodyxiong
Copy link

woodyxiong commented Aug 6, 2020

swagger的页面能打开,但是没有一个接口能用的,不知道是不是我操作的问题
所有接口都是参数请求错误

@woodyxiong
Copy link

woodyxiong commented Aug 6, 2020

后面仔细看代码,发现是要这样访问的,后续的url都可以这样访问试试

curl --location --request POST 'http://127.0.0.1:8000/auth' \
--form 'username=test' \
--form 'password=test123456'

image

@bjk543
Copy link

bjk543 commented Aug 9, 2021

同樣的問題,謝謝

@caipeishen
Copy link

这个项目标注的swag有点问题

@caipeishen
Copy link

刚下载了代码,发现在swagger页面中调用/auth一直显示 404 page not found
查看代码发现,在routers/router.go中,/auth路由定义的是POST方法,而swagger页面中显示的是GET方法。
image
image
之后,我在postman中使用post方法,带参数请求/auth,还是显示 404 page not found
image
请问一下,是我使用的姿势不对吗?感谢。

post请求,路径是【/auth】

@alwaysbetter1314
Copy link

改下注释,执行swag init
现在的auth.go注释确实是get

// @Summary Get Auth
// @Produce  json
// @Param username query string true "userName"
// @Param password query string true "password"
// @Success 200 {object} app.Response
// @Failure 500 {object} app.Response
// @Router /auth [get]

@dufeng-code
Copy link

修改 swag请求方式 并且如果请求为application/json方式 要修改GetAuth api中参数获取方法c.PostForm改为c.Query

@code4happylife
Copy link

request url: http://127.0.0.1:8000/auth
with POST body:
username:test
password:test123
can successfully get token.

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

7 participants