forked from loafle/openapi-generator-original
[Ruby] Added Support for Building Models from Hashes with Strings as Keys (#11243)
* [Ruby] Added Support for Building Models from Hashes with Strings as Keys * generate samples
This commit is contained in:
@@ -102,6 +102,7 @@ module Petstore
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
super(attributes)
|
||||
attributes = attributes.transform_keys(&:to_sym)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
||||
self.send("#{key}=", nil)
|
||||
|
||||
@@ -98,6 +98,7 @@ module Petstore
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
attributes = attributes.transform_keys(&:to_sym)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
||||
self.send("#{key}=", nil)
|
||||
|
||||
Reference in New Issue
Block a user