douan2907 2017-03-13 14:45
浏览 131

如何在go gin-gonic中创建swagger.json

I am trying to add documentation to my golang project which has been created using gin-gonic. The problem I am facing currently is that gin-gonic's stable version does not support swagger.

Issue in gin-gonic

Currently when I try to generate the swagger.json its paths are empty. Is there a way in golang to tell it to add end points manually?

go generate
cat swagger.json 
{
  "swagger": "2.0",
  "paths": {},
  "definitions": {}
}

If this is not an option, should I look into a different framework for the same?

  • 写回答

1条回答 默认 最新

  • douna4762 2017-03-13 15:56
    关注

    Gin uses goswagger as a base. You could try using goswagger directly

    Follow the instructions and the prescribed godoc commenting rules and you should get similar behavior to gin.

    FYI, I have not used goswagger myself.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值