Fix ruby model generation with objects and additionalProperties (#6816)

* Fix model generation with objects and additionalProperties

* Generate Ruby Petstore

* Generate Ruby Security Petstore
This commit is contained in:
Stephan E 2017-10-26 13:59:38 +02:00 committed by wing328
parent 4f3c86aa14
commit f78d958ec0
4 changed files with 12 additions and 7 deletions

View File

@ -56,11 +56,16 @@
{{#vars}} {{#vars}}
if attributes.has_key?(:'{{{baseName}}}') if attributes.has_key?(:'{{{baseName}}}')
{{#isContainer}} {{#isListContainer}}
if (value = attributes[:'{{{baseName}}}']).is_a?(Array) if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
self.{{{name}}} = value self.{{{name}}} = value
end end
{{/isContainer}} {{/isListContainer}}
{{#isMapContainer}}
if (value = attributes[:'{{{baseName}}}']).is_a?(Hash)
self.{{{name}}} = value
end
{{/isMapContainer}}
{{^isContainer}} {{^isContainer}}
self.{{{name}}} = attributes[:'{{{baseName}}}'] self.{{{name}}} = attributes[:'{{{baseName}}}']
{{/isContainer}} {{/isContainer}}

View File

@ -45,13 +45,13 @@ module Petstore
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes.has_key?(:'map_property') if attributes.has_key?(:'map_property')
if (value = attributes[:'map_property']).is_a?(Array) if (value = attributes[:'map_property']).is_a?(Hash)
self.map_property = value self.map_property = value
end end
end end
if attributes.has_key?(:'map_of_map_property') if attributes.has_key?(:'map_of_map_property')
if (value = attributes[:'map_of_map_property']).is_a?(Array) if (value = attributes[:'map_of_map_property']).is_a?(Hash)
self.map_of_map_property = value self.map_of_map_property = value
end end
end end

View File

@ -66,13 +66,13 @@ module Petstore
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes.has_key?(:'map_map_of_string') if attributes.has_key?(:'map_map_of_string')
if (value = attributes[:'map_map_of_string']).is_a?(Array) if (value = attributes[:'map_map_of_string']).is_a?(Hash)
self.map_map_of_string = value self.map_map_of_string = value
end end
end end
if attributes.has_key?(:'map_of_enum_string') if attributes.has_key?(:'map_of_enum_string')
if (value = attributes[:'map_of_enum_string']).is_a?(Array) if (value = attributes[:'map_of_enum_string']).is_a?(Hash)
self.map_of_enum_string = value self.map_of_enum_string = value
end end
end end

View File

@ -57,7 +57,7 @@ module Petstore
end end
if attributes.has_key?(:'map') if attributes.has_key?(:'map')
if (value = attributes[:'map']).is_a?(Array) if (value = attributes[:'map']).is_a?(Hash)
self.map = value self.map = value
end end
end end