Search code examples
ruby-on-railsdocumentationswagger-ui

RoR: Swagger does not update api-docs


I have swagger-ui_rails integrated in my existing Rails app. I have added a new model "Book" in my application and now want to update my api-docs. How can I do that ?

I am trying rake swagger:docs but that does not change anything. Also there is no books_controller in app/controller/api/v1/ direcotry, where other controller exists already.

I am new to Rails and Swagger, so please ignore if I am missing something basic.


Solution

  • Since you mention you define your controllers for the API, I presume you have a home-brewn API. This is ok, but then you will have to generate the swagger documentation by hand. That is ok, but not something I can help you with.

    However if you use grape for your api, you can then use the grape-swagger gem. Grape will replace your controllers for the API for you. It is more like a DSL describing your API, which includes the code to be executed. The grape-swagger gem will automatically parse the grape definition and convert it to swagger documentation.

    It offers extra options too, like write descriptions in Markdown. The grape-swagger gem is awesome :)

    I like this approach, I build a normal rails app, and use grape to serve the API part. My controllers for the UI and API would be different anyway.