blog icon indicating copy to clipboard operation
blog copied to clipboard

posts/go/gin/2018-03-18-swagger/

Open utterances-bot opened this issue 4 years ago • 10 comments

「连载八」为它加上Swagger

https://eddycjy.com/posts/go/gin/2018-03-18-swagger/

utterances-bot avatar May 06 '20 06:05 utterances-bot

煎鱼大佬,我们这边的POST请求都是application/json,然后在body中自定义了一些snTime,token之类的字段。所以现在需要自定义请求格式。 但我有看到 gin-swagger使用的是压缩后的swagger-ui.js 。所以我现在该怎样改动实现我的需求呢?

bluntdel avatar May 06 '20 06:05 bluntdel

注解@Success 200 {string} json "{"code":200,"data":{},"msg":"ok"}"应该要改为=>@Success 200 {object} gin.H才能生成成功了

gh372029002 avatar Jun 07 '20 18:06 gh372029002

请教大佬,swag文档怎么发不到apache服务器上,我把go项目部署到服务器上,用apache做反向代理,访问swag在线文档的时候报错误:Uncaught ReferenceError: SwaggerUIBundle is not defined at window.onload,求解

abnereel avatar Sep 07 '20 10:09 abnereel

已解决,是代码中的url地址设置错误:ginSwagger.WrapHandler(swaggerFiles.Handler, url)

abnereel avatar Sep 07 '20 11:09 abnereel

访问页面的时候 404 page not found

github.com/EDDYCJY/go-gin-example/routers

routers/router.go:23:25: undefined: ginSwagger routers/router.go:23:48: undefined: swaggerFiles

liiqii avatar Apr 21 '21 08:04 liiqii

IDE不能自动补全import的话需要在routers/router.go文件import需要添加: ginSwagger "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles"

samael0119 avatar May 25 '21 09:05 samael0119

swagger 的端口跟应用端口有冲突么,我设置了跟应用端口一样的,咋是 404 呢,请教各位大佬求解,拜谢

wkai666 avatar Jul 07 '21 10:07 wkai666

swagger 的端口跟应用端口有冲突么,我设置了跟应用端口一样的,咋是 404 呢,请教各位大佬求解,拜谢

需要重启服务

zlking02 avatar Sep 06 '21 08:09 zlking02

// @Success 200 {string} json"{"code":200,"data":{},"msg":"ok"}" 这个报错:ParseComment error in file routersapiv1tag.go :can not find schema type: "v1.json" 改成下面的可以 // @Success 200 {string} string "{"code":200,"data":{},"msg":"ok"}"

gjwphper avatar Sep 23 '21 17:09 gjwphper

windows环境,访问一直提示Failed to load API definition.,可能是什么原因呢

zhukangs avatar Dec 29 '21 08:12 zhukangs