5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/lina/apidoc_controller.rb', line 5
def index
all_routes = Rails.application.routes.routes
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
api_routes = []
@user_api_controllers = user_api_controllers
@user_api_controllers.each do |controller|
api_routes += inspector.send(:filter_routes, controller)
end
@routes = inspector.send(:collect_routes, api_routes)
@routes.select! do |route|
controller, action = route[:reqs].split('#')
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
format.json { render json: @tree }
end
end
|