Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate and publish Ruby based REST APIs documentation

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.

like image 724
jpemberthy Avatar asked Apr 23 '12 22:04

jpemberthy


People also ask

Can you build an API with Ruby?

February 02, 2022. In this blog, we will teach you to step by step how to create an API using Ruby on Rails, even without having a greater knowledge of this framework that works with the Ruby language.

What is RESTful API in Ruby?

Shorthand for Application Programming Interface, it provides developers programmatic access to the service. There are different types of APIs, but most boil down to RESTful, JSON APIs. If you're planning on building an app, adding an API should definitely be in your roadmap.


1 Answers

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

  • Create an interface for the API by using the swagger-specification. You can do this without using a server, see here.

  • 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!)

  • 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.

  • You can also generate your client with swagger-codegen.

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.

like image 67
fehguy Avatar answered Sep 27 '22 21:09

fehguy