Question

I'm using Grape (on Rails 4), Swagger and Swagger-UI to document my Grape API. Now I wonder how to group routes like the Swagger example: http://petstore.swagger.wordnik.com/

Thats how my Swagger-UI currently looks:

enter image description here

Was it helpful?

Solution

If you define your endpoint within a resource block, for example:

module MyApiModule
  class MyApiClass < Grape::API

    resource :foo do
      get :time do
        {epoch_time: Time.now.to_i.to_s}
      end
    end

    resource :bar do
      get :bar_time do
        {epoch_bar_time: Time.now.to_i.to_s}
      end
    end
  end
end

... you will see this nice separators:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top