سؤال

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

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top