I googled a little bit to find a proper and easy to implement way to generate Swagger documentation for an existing Rails API app. To be short, there are 2 ways of implementation: either via controllers, models or via Rspec controller/request specs. The list is not too long and the choice is not so easy to make:
- swagger-docs gem, - the oldest one. Pros: implementation is to be done in controllers. Cons: does not support Swagger V2 version and limited to 1.2 only.
- swagger-blocks gem, - improved version of swagger-docs, supports Swagger V2 version, implementation is to be done in controllers, models. But I couldn't make it work, Swagger Editor could not parse the generated json file.
- rswag gem: extends rspec-rails "request specs" with a Swagger-based DSL. Personally, I found it really difficult to implement in an existing Rails app for 2 reasons:
- you will have to modify existing request specs
- request specs look really weird and the syntax is not RSpec-ish.
- rspec-rails-swagger gem: implementation via request specs. The same cons as above.
Does anybody know other gems to generate Swagger documentation for an existing Rails API app ? Any suggestions are welcome ! Thank you.