Class: Swagger::Blocks::Nodes::RootNode

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

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

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


6
7
8
# File 'lib/swagger/blocks/nodes/root_node.rb', line 6

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

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

Raises:


10
11
12
13
14
15
16
# File 'lib/swagger/blocks/nodes/root_node.rb', line 10

def parameter(param, inline_keys = nil, &block)
  raise NotSupportedError unless is_swagger_2_0?

  # TODO validate 'param' is as per spec
  self.data[:parameters] ||= {}
  self.data[:parameters][param] = Swagger::Blocks::Nodes::ParameterNode.call(version: version, inline_keys: inline_keys, &block)
end

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

Raises:


18
19
20
21
22
23
24
# File 'lib/swagger/blocks/nodes/root_node.rb', line 18

def response(resp, inline_keys = nil, &block)
  raise NotSupportedError unless is_swagger_2_0?

  # 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

Raises:


33
34
35
36
37
38
# File 'lib/swagger/blocks/nodes/root_node.rb', line 33

def security(inline_keys = nil, &block)
  raise NotSupportedError unless is_swagger_2_0?

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

#security_definition(name, inline_keys = nil, &block) ⇒ Object

Raises:


26
27
28
29
30
31
# File 'lib/swagger/blocks/nodes/root_node.rb', line 26

def security_definition(name, inline_keys = nil, &block)
  raise NotSupportedError unless is_swagger_2_0?

  self.data[:securityDefinitions] ||= {}
  self.data[:securityDefinitions][name] = Swagger::Blocks::Nodes::SecuritySchemeNode.call(version: version, inline_keys: inline_keys, &block)
end

#tag(inline_keys = nil, &block) ⇒ Object Also known as: tags

Raises:


40
41
42
43
44
45
# File 'lib/swagger/blocks/nodes/root_node.rb', line 40

def tag(inline_keys = nil, &block)
  raise NotSupportedError unless is_swagger_2_0?

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