Class: Swagger::V2::Path

Inherits:
SwaggerObject show all
Extended by:
Forwardable
Defined in:
lib/swagger/v2/path.rb

Overview

Class representing a Swagger “Path Item Object”.

See Also:

Constant Summary collapse

VERBS =
[:get, :put, :post, :delete, :options, :head, :patch]

Instance Attribute Summary

Attributes inherited from SwaggerObject

#parent

Instance Method Summary collapse

Methods inherited from SwaggerObject

field, required_field

Methods included from Attachable

#attach_parent, #attach_to_children, #root

Constructor Details

#initialize(hash) ⇒ Path

Returns a new instance of Path.



18
19
20
21
# File 'lib/swagger/v2/path.rb', line 18

def initialize(hash)
  hash[:parameters] ||= []
  super
end

Instance Method Details

#operationsObject



23
24
25
26
27
28
# File 'lib/swagger/v2/path.rb', line 23

def operations
  VERBS.each_with_object({}) do | v, h |
    operation = send v
    h[v] = operation if operation
  end
end

#pathObject



34
35
36
# File 'lib/swagger/v2/path.rb', line 34

def path
  parent.paths.key self
end

#uri_templateObject



30
31
32
# File 'lib/swagger/v2/path.rb', line 30

def uri_template
  "#{parent.host}#{parent.base_path}#{path}"
end