Class: SwaggerYard::ResourceListing
- Inherits:
-
Object
- Object
- SwaggerYard::ResourceListing
- Defined in:
- lib/swagger_yard/resource_listing.rb
Instance Attribute Summary collapse
-
#authorizations ⇒ Object
Returns the value of attribute authorizations.
Class Method Summary collapse
Instance Method Summary collapse
- #controllers ⇒ Object
-
#initialize(controller_path, model_path) ⇒ ResourceListing
constructor
A new instance of ResourceListing.
- #model_objects ⇒ Object
- #models ⇒ Object
- #path_objects ⇒ Object
- #security_objects ⇒ Object
-
#tag_objects ⇒ Object
Resources.
- #to_h ⇒ Object
Constructor Details
#initialize(controller_path, model_path) ⇒ ResourceListing
Returns a new instance of ResourceListing.
9 10 11 12 13 14 15 |
# File 'lib/swagger_yard/resource_listing.rb', line 9 def initialize(controller_path, model_path) @model_paths = [*model_path].compact @controller_paths = [*controller_path].compact @resource_to_file_path = {} @authorizations = [] end |
Instance Attribute Details
#authorizations ⇒ Object
Returns the value of attribute authorizations.
3 4 5 |
# File 'lib/swagger_yard/resource_listing.rb', line 3 def @authorizations end |
Class Method Details
.all ⇒ Object
5 6 7 |
# File 'lib/swagger_yard/resource_listing.rb', line 5 def self.all new(SwaggerYard.config.controller_path, SwaggerYard.config.model_path) end |
Instance Method Details
#controllers ⇒ Object
21 22 23 |
# File 'lib/swagger_yard/resource_listing.rb', line 21 def controllers @controllers ||= parse_controllers end |
#model_objects ⇒ Object
41 42 43 |
# File 'lib/swagger_yard/resource_listing.rb', line 41 def model_objects Hash[models.map {|m| [m.id, m.to_h]}] end |
#models ⇒ Object
17 18 19 |
# File 'lib/swagger_yard/resource_listing.rb', line 17 def models @models ||= parse_models end |
#path_objects ⇒ Object
32 33 34 |
# File 'lib/swagger_yard/resource_listing.rb', line 32 def path_objects controllers.map(&:apis_hash).reduce({}, :merge) end |
#security_objects ⇒ Object
45 46 47 48 49 50 |
# File 'lib/swagger_yard/resource_listing.rb', line 45 def security_objects controllers # triggers controller parsing in case it did not happen before SwaggerYard.config.security_definitions.merge( Hash[.map {|auth| [auth.name, auth.to_h]}] ) end |
#tag_objects ⇒ Object
Resources
37 38 39 |
# File 'lib/swagger_yard/resource_listing.rb', line 37 def tag_objects controllers.map(&:to_tag) end |
#to_h ⇒ Object
25 26 27 28 29 30 |
# File 'lib/swagger_yard/resource_listing.rb', line 25 def to_h { "paths" => path_objects, "definitions" => model_objects, "tags" => tag_objects, "securityDefinitions" => security_objects } end |