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

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

Constant Summary

Constants inherited from Swagger::Blocks::Node

Swagger::Blocks::Node::VERSION_2, Swagger::Blocks::Node::VERSION_3

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_openapi_3_0?, #is_swagger_2_0?, #key, #keys, #ref?, #static_ref?, #value_as_json

Instance Method Details

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

Raises:


58
59
60
61
62
63
# File 'lib/swagger/blocks/nodes/root_node.rb', line 58

def extension(name, inline_keys = nil, &block)
  raise NotSupportedError unless is_openapi_3_0?

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

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


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

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

#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? || is_openapi_3_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

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

Raises:


51
52
53
54
55
56
# File 'lib/swagger/blocks/nodes/root_node.rb', line 51

def server(inline_keys = nil, &block)
  raise NotSupportedError unless is_openapi_3_0?

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

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

Raises:


44
45
46
47
48
49
# File 'lib/swagger/blocks/nodes/root_node.rb', line 44

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

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