LoginSignup
6
4

More than 5 years have passed since last update.

Grapeのroutesを表示するRakeタスク

Posted at
lib/tasks/application.rake
namespace :routes do
  task :api => :environment do
    Grape::API.subclasses.each do |subclass|
      subclass.routes.each do |e|
        puts "%-10s %-6s %-24s %s" % [subclass, e.route_method, e.route_path, e.route_description]
      end
      puts
    end
  end
end
$ rake routes:api
MyApi  GET    /api/action1             コメント1
MyApi  PUT    /api/action2             コメント2
MyApi  DELETE /api/action3             コメント3
(snip)

・サブクラスすべてを表示する必要はないかも
・参照 https://github.com/search?type=Code&ref=searchresults&q=routes%20task%20grape
・Grape側でタスクが用意されてないので各自自作しているようです

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4