生成和发布基于 Ruby 的 REST API 文档 [英] Generate and publish Ruby based REST APIs documentation

查看:53
本文介绍了生成和发布基于 Ruby 的 REST API 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在很酷的孩子使用什么来轻松解析/生成/发布 REST API?我查看了 Swagger ,它看起来不错,但从我的角度来看,它不适合 Ruby.也许我只是错了,我错过了一些东西,将不胜感激.

What are cool kids using nowadays to easily parse/generate/publish REST APIs? I took a look on Swagger and It looks nice but from my point of view it doesn't fit ok with Ruby. Maybe I'm just wrong and I'm missing something, help would be appreciated.

推荐答案

听起来您还没有 API?如果是这种情况,这就是我推荐的方法.

Sounds like you don't have an API yet? If that's the case, this is the approach that I recommend.

使用 swagger-ui 验证接口.这允许您查看您定义的所有端点(仍然没有编码,除了 json 文件!)

Verify the interface by using swagger-ui. This allows you to see all the endpoints that you've defined (still, no coding, except for the json files!)

拥有想要的界面后,使用 swagger-codegen 构建一个您的服务器的存根版本.目前有 nodejs 的模板href="https://github.com/wordnik/swagger-codegen/tree/master/samples/server-generator/scalatra" rel="noreferrer">scalatra 还有更多内容.制作新的服务器生成器只是创建/修改一些 mustache 模板的问题.

Once you have an interface you want, use swagger-codegen to build a stubbed-out version of your server. There are currently templates for nodejs and scalatra with more on the way. Making a new server generator is simply a matter of creating/modifying some mustache templates.

您还可以使用 swagger-codegen 生成客户端.

You can also generate your client with swagger-codegen.

这样做的好处在于您可以对 API 进行接口驱动的开发.构建接口并填空.管道已为您完成.

The beauty of this is that you can do interface-driven development of your API. Build the interfaces and fill in the blanks. The plumbing is done for you.

这篇关于生成和发布基于 Ruby 的 REST API 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆