Class: Swagger::V2::Operation

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

Overview

Class representing a Swagger “Operation Object”.

See Also:

Instance Attribute Summary

Attributes inherited from SwaggerObject

#parent

Instance Method Summary collapse

Methods inherited from SwaggerObject

field, #initialize, required_field

Methods included from Attachable

#attach_parent, #attach_to_children, #root

Constructor Details

This class inherits a constructor from Swagger::SwaggerObject

Instance Method Details

#api_titleObject



27
28
29
# File 'lib/swagger/v2/operation.rb', line 27

def api_title
  root.info.title
end

#default_responseObject



44
45
46
47
48
49
50
# File 'lib/swagger/v2/operation.rb', line 44

def default_response
  return nil if responses.values.nil?

  # FIXME: Swagger isn't very clear on "normal response codes"
  # In the examples, default is actually an error
  responses['200'] || responses['201'] || responses['default'] || responses.values.first
end

#each_parameterObject

Iterates over each parameter defined directly on the operation, excluding parameters defined at the API level.



54
55
56
57
58
59
# File 'lib/swagger/v2/operation.rb', line 54

def each_parameter
  return if parameters.nil?
  parameters.each do | parameter |
    yield parameter
  end
end

#full_nameObject



31
32
33
# File 'lib/swagger/v2/operation.rb', line 31

def full_name
  "#{api_title} - #{summary}"
end

#signatureObject



40
41
42
# File 'lib/swagger/v2/operation.rb', line 40

def signature
  "#{verb.to_s.upcase} #{parent.uri_template}"
end

#verbObject

The HTTP verb for the operation.



36
37
38
# File 'lib/swagger/v2/operation.rb', line 36

def verb
  parent.operations.key self
end