Class: Swagger::Grape::Routes
- Inherits:
-
Object
- Object
- Swagger::Grape::Routes
- Defined in:
- lib/ruby-swagger/grape/routes.rb
Instance Attribute Summary collapse
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(routes) ⇒ Routes
constructor
A new instance of Routes.
- #to_swagger ⇒ Object
Constructor Details
#initialize(routes) ⇒ Routes
Returns a new instance of Routes.
9 10 11 12 13 |
# File 'lib/ruby-swagger/grape/routes.rb', line 9 def initialize(routes) @routes = routes @types = [] @scopes = [] end |
Instance Attribute Details
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
7 8 9 |
# File 'lib/ruby-swagger/grape/routes.rb', line 7 def scopes @scopes end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
7 8 9 |
# File 'lib/ruby-swagger/grape/routes.rb', line 7 def types @types end |
Instance Method Details
#to_swagger ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby-swagger/grape/routes.rb', line 15 def to_swagger swagger = Swagger::Data::Paths.new paths = {} @routes.each do |route| next if route.route_hidden == true # implement custom "hidden" extension swagger_path_name = swagger_path_name(route) paths[swagger_path_name] ||= Swagger::Grape::RoutePath.new(swagger_path_name) paths[swagger_path_name].add_operation(route) end paths.each do |path_name, path| swagger.add_path(path_name, path.to_swagger) @types = (@types | path.types).uniq @scopes = (@scopes | path.scopes).uniq end swagger end |