Class: Swagger::Blocks::AllOfNode
- Inherits:
-
Node
- Object
- Node
- Swagger::Blocks::AllOfNode
show all
- Defined in:
- lib/swagger/blocks.rb
Instance Attribute Summary
Attributes inherited from Node
#name, #version
Instance Method Summary
collapse
Methods inherited from Node
call, #is_swagger_1_2?, #is_swagger_2_0?
Instance Method Details
#as_json ⇒ Object
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
|
# File 'lib/swagger/blocks.rb', line 610
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
633
634
635
|
# File 'lib/swagger/blocks.rb', line 633
def data
@data ||= []
end
|
#key(key, value) ⇒ Object
637
638
639
|
# File 'lib/swagger/blocks.rb', line 637
def key(key, value)
raise NotSupportedError
end
|
#schema(&block) ⇒ Object
641
642
643
|
# File 'lib/swagger/blocks.rb', line 641
def schema(&block)
data << Swagger::Blocks::SchemaNode.call(version: version, &block)
end
|