[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:
Cameron Koegel
2022-03-08 11:59:53 -05:00
committed by GitHub
parent 16fd760b16
commit b1c6513015
85 changed files with 85 additions and 0 deletions

View File

@@ -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)

View File

@@ -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)