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