Improve model class of ruby-client (#1670)

* Add Model.build_from_hash

* Use Model.build_from_hash instead of Model.new.build_from_hash

* Update sample for ruby-client

* Update sample for openapi3 ruby-client
This commit is contained in:
meganemura 2018-12-15 17:24:03 +09:00 committed by William Cheng
parent cacce1f707
commit 82fcde1d91
76 changed files with 581 additions and 148 deletions

View File

@ -204,9 +204,7 @@ module {{moduleName}}
end
else
# models, e.g. Pet
{{moduleName}}.const_get(return_type).new.tap do |model|
model.build_from_hash data
end
{{moduleName}}.const_get(return_type).build_from_hash(data)
end
end

View File

@ -1,3 +1,10 @@
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -58,8 +65,7 @@
end
end
else # model
temp_model = {{moduleName}}.const_get(type).new
temp_model.build_from_hash(value)
{{moduleName}}.const_get(type).build_from_hash(value)
end
end

View File

@ -2,6 +2,13 @@
{{#allowableValues}}{{#enumVars}}
{{{name}}} = {{{value}}}.freeze{{/enumVars}}{{/allowableValues}}
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
def self.build_from_hash(value)
new.build_from_hash(value)
end
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
@ -10,4 +17,4 @@
raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty?
value
end
end
end

View File

@ -239,8 +239,7 @@
{{#-first}}
_any_of_found = false
openapi_any_of.each do |_class|
_any_of = {{moduleName}}.const_get(_class).new
_any_of.build_from_hash(self.to_hash)
_any_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash)
if _any_of.valid?
_any_of_found = true
end
@ -256,8 +255,7 @@
{{#-first}}
_one_of_found = false
openapi_one_of.each do |_class|
_one_of = {{moduleName}}.const_get(_class).new
_one_of.build_from_hash(self.to_hash)
_one_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash)
if _one_of.valid?
if _one_of_found?
return false

View File

@ -210,9 +210,7 @@ module Petstore
end
else
# models, e.g. Pet
Petstore.const_get(return_type).new.tap do |model|
model.build_from_hash data
end
Petstore.const_get(return_type).build_from_hash(data)
end
end

View File

@ -89,6 +89,13 @@ module Petstore
[map_property, map_of_map_property].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -146,8 +153,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -97,6 +97,13 @@ module Petstore
[class_name, color].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -154,8 +161,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -94,6 +94,13 @@ module Petstore
[code, type, message].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -151,8 +158,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -78,6 +78,13 @@ module Petstore
[array_array_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -135,8 +142,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -78,6 +78,13 @@ module Petstore
[array_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -135,8 +142,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -100,6 +100,13 @@ module Petstore
[array_of_string, array_array_of_integer, array_array_of_model].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -157,8 +164,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -122,6 +122,13 @@ module Petstore
[small_camel, capital_camel, small_snake, capital_snake, sca_eth_flow_points, att_name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -179,8 +186,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -86,6 +86,13 @@ module Petstore
[declawed].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -144,8 +151,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -92,6 +92,13 @@ module Petstore
[id, name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -149,8 +156,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -77,6 +77,13 @@ module Petstore
[_class].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -134,8 +141,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[client].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -86,6 +86,13 @@ module Petstore
[breed].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -144,8 +151,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -121,6 +121,13 @@ module Petstore
[just_symbol, array_enum].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -178,8 +185,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -19,6 +19,13 @@ module Petstore
EFG = '-efg'.freeze
XYZ = '(xyz)'.freeze
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
def self.build_from_hash(value)
new.build_from_hash(value)
end
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
@ -28,4 +35,5 @@ module Petstore
value
end
end
end

View File

@ -187,6 +187,13 @@ module Petstore
[enum_string, enum_string_required, enum_integer, enum_number, outer_enum].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -244,8 +251,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -78,6 +78,13 @@ module Petstore
[source_uri].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -135,8 +142,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -87,6 +87,13 @@ module Petstore
[file, files].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -144,8 +151,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -390,6 +390,13 @@ module Petstore
[integer, int32, int64, number, float, double, string, byte, binary, date, date_time, uuid, password].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -447,8 +454,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -85,6 +85,13 @@ module Petstore
[bar, foo].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -142,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[_123_list].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -133,6 +133,13 @@ module Petstore
[map_map_of_string, map_of_enum_string, direct_map, indirect_map].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -190,8 +197,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -96,6 +96,13 @@ module Petstore
[uuid, date_time, map].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -153,8 +160,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -86,6 +86,13 @@ module Petstore
[name, _class].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -143,8 +150,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -77,6 +77,13 @@ module Petstore
[_return].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -134,8 +141,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -109,6 +109,13 @@ module Petstore
[name, snake_case, property, _123_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -166,8 +173,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[just_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -158,6 +158,13 @@ module Petstore
[id, pet_id, quantity, ship_date, status, complete].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -215,8 +222,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -94,6 +94,13 @@ module Petstore
[my_number, my_string, my_boolean].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -151,8 +158,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -19,6 +19,13 @@ module Petstore
APPROVED = 'approved'.freeze
DELIVERED = 'delivered'.freeze
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
def self.build_from_hash(value)
new.build_from_hash(value)
end
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
@ -28,4 +35,5 @@ module Petstore
value
end
end
end

View File

@ -170,6 +170,13 @@ module Petstore
[id, category, name, photo_urls, tags, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -227,8 +234,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -85,6 +85,13 @@ module Petstore
[bar, baz].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -142,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[special_property_name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -85,6 +85,13 @@ module Petstore
[id, name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -142,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -140,6 +140,13 @@ module Petstore
[id, username, first_name, last_name, email, password, phone, user_status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -197,8 +204,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -210,9 +210,7 @@ module Petstore
end
else
# models, e.g. Pet
Petstore.const_get(return_type).new.tap do |model|
model.build_from_hash data
end
Petstore.const_get(return_type).build_from_hash(data)
end
end

View File

@ -89,6 +89,13 @@ module Petstore
[map_property, map_of_map_property].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -146,8 +153,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -97,6 +97,13 @@ module Petstore
[class_name, color].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -154,8 +161,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -94,6 +94,13 @@ module Petstore
[code, type, message].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -151,8 +158,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -78,6 +78,13 @@ module Petstore
[array_array_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -135,8 +142,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -78,6 +78,13 @@ module Petstore
[array_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -135,8 +142,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -100,6 +100,13 @@ module Petstore
[array_of_string, array_array_of_integer, array_array_of_model].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -157,8 +164,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -122,6 +122,13 @@ module Petstore
[small_camel, capital_camel, small_snake, capital_snake, sca_eth_flow_points, att_name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -179,8 +186,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -86,6 +86,13 @@ module Petstore
[declawed].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -144,8 +151,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -92,6 +92,13 @@ module Petstore
[id, name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -149,8 +156,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -77,6 +77,13 @@ module Petstore
[_class].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -134,8 +141,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[client].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -86,6 +86,13 @@ module Petstore
[breed].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -144,8 +151,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -121,6 +121,13 @@ module Petstore
[just_symbol, array_enum].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -178,8 +185,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -19,6 +19,13 @@ module Petstore
EFG = '-efg'.freeze
XYZ = '(xyz)'.freeze
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
def self.build_from_hash(value)
new.build_from_hash(value)
end
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
@ -28,4 +35,5 @@ module Petstore
value
end
end
end

View File

@ -187,6 +187,13 @@ module Petstore
[enum_string, enum_string_required, enum_integer, enum_number, outer_enum].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -244,8 +251,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -78,6 +78,13 @@ module Petstore
[source_uri].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -135,8 +142,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -87,6 +87,13 @@ module Petstore
[file, files].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -144,8 +151,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -78,6 +78,13 @@ module Petstore
[bar].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -135,8 +142,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -421,6 +421,13 @@ module Petstore
[integer, int32, int64, number, float, double, string, byte, binary, date, date_time, uuid, password, pattern_with_digits, pattern_with_digits_and_delimiter].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -478,8 +485,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -85,6 +85,13 @@ module Petstore
[bar, foo].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -142,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[string].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[_123_list].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -133,6 +133,13 @@ module Petstore
[map_map_of_string, map_of_enum_string, direct_map, indirect_map].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -190,8 +197,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -96,6 +96,13 @@ module Petstore
[uuid, date_time, map].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -153,8 +160,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -86,6 +86,13 @@ module Petstore
[name, _class].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -143,8 +150,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -77,6 +77,13 @@ module Petstore
[_return].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -134,8 +141,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -109,6 +109,13 @@ module Petstore
[name, snake_case, property, _123_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -166,8 +173,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[just_number].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -158,6 +158,13 @@ module Petstore
[id, pet_id, quantity, ship_date, status, complete].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -215,8 +222,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -94,6 +94,13 @@ module Petstore
[my_number, my_string, my_boolean].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -151,8 +158,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -19,6 +19,13 @@ module Petstore
APPROVED = 'approved'.freeze
DELIVERED = 'delivered'.freeze
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
def self.build_from_hash(value)
new.build_from_hash(value)
end
# Builds the enum from string
# @param [String] The enum value in the form of the string
# @return [String] The enum value
@ -28,4 +35,5 @@ module Petstore
value
end
end
end

View File

@ -170,6 +170,13 @@ module Petstore
[id, category, name, photo_urls, tags, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -227,8 +234,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -85,6 +85,13 @@ module Petstore
[bar, baz].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -142,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -76,6 +76,13 @@ module Petstore
[special_property_name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -133,8 +140,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -85,6 +85,13 @@ module Petstore
[id, name].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -142,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -140,6 +140,13 @@ module Petstore
[id, username, first_name, last_name, email, password, phone, user_status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
@ -197,8 +204,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end