Class: SwaggerYard::ResourceListing

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger_yard/resource_listing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller_path, model_path) ⇒ ResourceListing

Returns a new instance of ResourceListing.



6
7
8
9
10
11
12
# File 'lib/swagger_yard/resource_listing.rb', line 6

def initialize(controller_path, model_path)
  @model_path = model_path
  @controller_path = controller_path

  @resource_to_file_path = {}
  @authorizations = []
end

Instance Attribute Details

#api_declarationsObject (readonly)

Returns the value of attribute api_declarations.



3
4
5
# File 'lib/swagger_yard/resource_listing.rb', line 3

def api_declarations
  @api_declarations
end

#authorizationsObject

Returns the value of attribute authorizations.



4
5
6
# File 'lib/swagger_yard/resource_listing.rb', line 4

def authorizations
  @authorizations
end

#resource_to_file_pathObject (readonly)

Returns the value of attribute resource_to_file_path.



3
4
5
# File 'lib/swagger_yard/resource_listing.rb', line 3

def resource_to_file_path
  @resource_to_file_path
end

Instance Method Details

#controllersObject



18
19
20
# File 'lib/swagger_yard/resource_listing.rb', line 18

def controllers
  @controllers ||= parse_controllers
end

#declaration_for(resource_name) ⇒ Object



22
23
24
# File 'lib/swagger_yard/resource_listing.rb', line 22

def declaration_for(resource_name)
  controllers[resource_name]
end

#modelsObject



14
15
16
# File 'lib/swagger_yard/resource_listing.rb', line 14

def models
  @models ||= parse_models
end

#to_hObject



26
27
28
29
30
31
32
33
34
# File 'lib/swagger_yard/resource_listing.rb', line 26

def to_h
  {
    "apiVersion"      => SwaggerYard.config.api_version,
    "swaggerVersion"  => SwaggerYard.config.swagger_version,
    "basePath"        => SwaggerYard.config.swagger_spec_base_path,
    "apis"            => list_api_declarations,
    "authorizations"  => authorizations_hash
  }
end