Class: Swagger::Blocks::Nodes::OperationNode

Inherits:
Swagger::Blocks::Node show all
Defined in:
lib/swagger/blocks/nodes/operation_node.rb

Overview

Instance Attribute Summary

Attributes inherited from Swagger::Blocks::Node

#name, #version

Instance Method Summary collapse

Methods inherited from Swagger::Blocks::Node

#as_json, call, #data, #is_swagger_2_0?, #key, #keys

Instance Method Details

#externalDocs(inline_keys = nil, &block) ⇒ Object


19
20
21
# File 'lib/swagger/blocks/nodes/operation_node.rb', line 19

def externalDocs(inline_keys = nil, &block)
  self.data[:externalDocs] = Swagger::Blocks::Nodes::ExternalDocsNode.call(version: version, inline_keys: inline_keys, &block)
end

#parameter(inline_keys = nil, &block) ⇒ Object


6
7
8
9
10
11
# File 'lib/swagger/blocks/nodes/operation_node.rb', line 6

def parameter(inline_keys = nil, &block)
  inline_keys = {'$ref' => "#/parameters/#{inline_keys}"} if inline_keys.is_a?(Symbol)

  self.data[:parameters] ||= []
  self.data[:parameters] << Swagger::Blocks::Nodes::ParameterNode.call(version: version, inline_keys: inline_keys, &block)
end

#response(resp, inline_keys = nil, &block) ⇒ Object


13
14
15
16
17
# File 'lib/swagger/blocks/nodes/operation_node.rb', line 13

def response(resp, inline_keys = nil, &block)
  # TODO validate 'resp' is as per spec
  self.data[:responses] ||= {}
  self.data[:responses][resp] = Swagger::Blocks::Nodes::ResponseNode.call(version: version, inline_keys: inline_keys, &block)
end

#security(inline_keys = nil, &block) ⇒ Object


23
24
25
26
# File 'lib/swagger/blocks/nodes/operation_node.rb', line 23

def security(inline_keys = nil, &block)
  self.data[:security] ||= []
  self.data[:security] << Swagger::Blocks::Nodes::SecurityRequirementNode.call(version: version, inline_keys: inline_keys, &block)
end