Class: Swagger::Blocks::Nodes::AllOfNode
Constant Summary
Swagger::Blocks::Node::VERSION_2, Swagger::Blocks::Node::VERSION_3
Instance Attribute Summary
#name, #version
Instance Method Summary
collapse
call, #is_openapi_3_0?, #is_swagger_2_0?, #keys, #ref?, #static_ref?, #value_as_json
Instance Method Details
#as_json(options = {}) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 5
def as_json(options = {})
version = options.fetch(:version, '2.0')
result = []
self.data.each do |value|
if value.is_a?(Node)
result << value.as_json(version: version)
elsif value.is_a?(Array)
r = []
value.each { |v| r << value_as_json(v, version) }
result << r
elsif (is_swagger_2_0? || is_openapi_3_0?) && value.is_a?(Hash)
r = {}
value.each_pair {|k, v| r[k] = value_as_json(v, version) }
result << r
else
result = value
end
end
return result if !name
{name => result}
end
|
#data ⇒ Object
29
30
31
|
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 29
def data
@data ||= []
end
|
#key(key, value) ⇒ Object
33
34
35
|
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 33
def key(key, value)
raise NotSupportedError
end
|
#schema(inline_keys = nil, &block) ⇒ Object
37
38
39
|
# File 'lib/swagger/blocks/nodes/all_of_node.rb', line 37
def schema(inline_keys = nil, &block)
data << Swagger::Blocks::Nodes::SchemaNode.call(version: version, inline_keys: inline_keys, &block)
end
|