Class: SwaggerYard::Specification

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller_path = SwaggerYard.config.controller_path, model_path = SwaggerYard.config.model_path) ⇒ Specification

Returns a new instance of Specification.



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

def initialize(controller_path = SwaggerYard.config.controller_path,
               model_path = SwaggerYard.config.model_path)
  @model_paths = [*model_path].compact
  @controller_paths = [*controller_path].compact

  @resource_to_file_path = {}
  @authorizations = []
end

Instance Attribute Details

#authorizationsObject

Returns the value of attribute authorizations.



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

def authorizations
  @authorizations
end

Instance Method Details

#model_objectsObject



25
26
27
# File 'lib/swagger_yard/specification.rb', line 25

def model_objects
  Hash[models.map {|m| [m.id, m]}]
end

#path_objectsObject



14
15
16
17
18
# File 'lib/swagger_yard/specification.rb', line 14

def path_objects
  api_groups.map(&:paths).reduce(Paths.new({}), :merge).tap do |paths|
    warn_duplicate_operations(paths)
  end
end

#security_objectsObject



29
30
31
32
# File 'lib/swagger_yard/specification.rb', line 29

def security_objects
  api_groups # triggers controller parsing in case it did not happen before
  Hash[authorizations.map {|auth| [auth.id, auth]}]
end

#tag_objectsObject

Resources



21
22
23
# File 'lib/swagger_yard/specification.rb', line 21

def tag_objects
  api_groups.map(&:tag)
end