app/controllers/lina/apidoc_controller.rb in lina-0.0.2 vs app/controllers/lina/apidoc_controller.rb in lina-0.0.3
- old
+ new
@@ -1,6 +1,6 @@
-require_dependency "lina/base_controller"
+require_dependency 'lina/base_controller'
module Lina
class ApidocController < BaseController
def index
all_routes = Rails.application.routes.routes
@@ -13,13 +13,14 @@
api_routes += inspector.send(:filter_routes, controller)
end
@routes = inspector.send(:collect_routes, api_routes)
# add schema info to route
- @routes.each do |route|
+ @routes.select! do |route|
controller, action = route[:reqs].split('#')
- route[:schema] = str2controller(controller).action_schema(action)
route[:path].gsub!('(.:format)', '')
+ route[:schema] = str2controller(controller).action_schema(action)
+ str2controller(controller).action_methods.include?(action)
end
@_tree = Lina::Tree.new(@routes)
@tree = @_tree.to_tree
respond_to do |format|
format.html