Class: Grape::API
- Inherits:
-
Object
- Object
- Grape::API
- Defined in:
- lib/grape-swagger.rb
Class Attribute Summary collapse
-
.combined_routes ⇒ Object
readonly
Returns the value of attribute combined_routes.
Class Method Summary collapse
Class Attribute Details
.combined_routes ⇒ Object (readonly)
Returns the value of attribute combined_routes.
6 7 8 |
# File 'lib/grape-swagger.rb', line 6 def combined_routes @combined_routes end |
Class Method Details
.add_swagger_documentation(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/grape-swagger.rb', line 8 def add_swagger_documentation(={}) documentation_class = create_documentation_class documentation_class.setup({:target_class => self}.merge()) mount(documentation_class) @combined_routes = {} routes.each do |route| route_match = route.route_path.split(route.route_prefix).last.match('\/([\w|-]*?)[\.\/\(]') next if route_match.nil? resource = route_match.captures.first next if resource.empty? resource.downcase! @combined_routes[resource] ||= [] unless @@hide_documentation_path and route.route_path.include?(@@mount_path) @combined_routes[resource] << route end end end |