Golang:Swagger REST API文档生成器

huangapple go评论103阅读模式
英文:

golang: swagger REST api documents generator

问题

我在互联网上搜索了一下,但没有找到一个好的解决方案。我正在寻找一个非常具体的东西 - 一个Go语言版本的aiohttp_swagger

aiohttp_swagger是一个Python包,可以做一些神奇的事情。在端点处理方法中,你可以编写一些注释代码,它会自动解析并生成Swagger文档。当服务器启动并运行时,会在服务器中插入一个特殊的URL /api/doc,用户可以在该URL上实时查看文档。

我知道这与aiohttp框架的实现有关,而Go语言的使用方式可能不太流行(我自己也没有使用过),但我仍然非常喜欢这个解决方案,并希望在Go语言领域找到类似的东西。

所以我的问题可能有点开放性:在Go语言中是否有与aiohttp_swagger包等效(或类似)的解决方案?

英文:

I've searched internet but couldn't find a good solution. I'm looking for something that pretty specific - a golang copy of aiohttp_swagger.

That is a Python package which does magical things. In the endpoint handler method, one write some comment code and it'll be automatically parsed and generates swagger documentation. When the server is up and running, a special URL /api/doc handler will be inserted into the server where people can see it live.

I understand it's tied into the implementation of aiohttp framework and the way Go is used, web framework is not as popular (not using one myself), but I still like that solution very much and would like to find something in the Go land.

So my question is a bit open I guess: is there an equivalent (or rough) of aiohttp_swagger package in Go?

答案1

得分: 1

go-swagger是基于文档注释来实现的:https://goswagger.io/generate/spec.html

go-restful有一个用于创建Swagger 2.0文档的构建器:https://github.com/emicklei/go-restful-openapi

英文:

go-swagger does it based on doc comments: https://goswagger.io/generate/spec.html

go-restful has a builder for creating swagger 2.0 documents: https://github.com/emicklei/go-restful-openapi

huangapple
  • 本文由 发表于 2017年2月27日 12:14:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/42477734.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定