Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -10,4 +17,4 @@
raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty?
value
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions samples/client/petstore/ruby/lib/petstore/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ def convert_to_type(data, return_type)
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ def hash
[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
Expand Down Expand Up @@ -146,8 +153,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/animal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ def hash
[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
Expand Down Expand Up @@ -154,8 +161,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/api_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ def hash
[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
Expand Down Expand Up @@ -151,8 +158,7 @@ def _deserialize(type, value)
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def hash
[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
Expand Down Expand Up @@ -135,8 +142,7 @@ def _deserialize(type, value)
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def hash
[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
Expand Down Expand Up @@ -135,8 +142,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/array_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def hash
[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
Expand Down Expand Up @@ -157,8 +164,7 @@ def _deserialize(type, value)
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def hash
[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
Expand Down Expand Up @@ -179,8 +186,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def hash
[declawed, 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
Expand Down Expand Up @@ -169,8 +176,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ def hash
[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
Expand Down Expand Up @@ -149,8 +156,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/class_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ def hash
[_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
Expand Down Expand Up @@ -134,8 +141,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ def hash
[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
Expand Down Expand Up @@ -133,8 +140,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/dog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def hash
[breed, 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
Expand Down Expand Up @@ -169,8 +176,7 @@ def _deserialize(type, value)
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

Expand Down
10 changes: 8 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ def hash
[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
Expand Down Expand Up @@ -178,8 +185,7 @@ def _deserialize(type, value)
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

Expand Down
Loading