From 1ed23a77cb2d3bba2e2203bd212ff7ab737455a1 Mon Sep 17 00:00:00 2001 From: meganemura Date: Fri, 14 Dec 2018 18:06:54 +0900 Subject: [PATCH 1/4] Add Model.build_from_hash --- .../src/main/resources/ruby-client/base_object.mustache | 7 +++++++ .../ruby-client/partial_model_enum_class.mustache | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache b/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache index faef2ae199e1..f96f8b408c23 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache @@ -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 diff --git a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache index 36cee9e79481..797bab82ab3d 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache @@ -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 \ No newline at end of file + end From 8138fdb148f7730b706afc49ac0816d256b1fff9 Mon Sep 17 00:00:00 2001 From: meganemura Date: Fri, 14 Dec 2018 18:09:32 +0900 Subject: [PATCH 2/4] Use Model.build_from_hash instead of Model.new.build_from_hash --- .../src/main/resources/ruby-client/api_client.mustache | 4 +--- .../src/main/resources/ruby-client/base_object.mustache | 3 +-- .../resources/ruby-client/partial_model_generic.mustache | 6 ++---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache index 03b8ca31f928..02dfd6703a9d 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache @@ -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 diff --git a/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache b/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache index f96f8b408c23..9ebcde2c6c1b 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/base_object.mustache @@ -65,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 diff --git a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache index f6082b111ab9..17755675e7e0 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache @@ -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 From f51a3130dce2da6f331f63c7d10ab63bfcdd1db4 Mon Sep 17 00:00:00 2001 From: meganemura Date: Fri, 14 Dec 2018 18:26:42 +0900 Subject: [PATCH 3/4] Update sample for ruby-client --- .../client/petstore/ruby/lib/petstore/api_client.rb | 4 +--- .../lib/petstore/models/additional_properties_class.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/animal.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/api_response.rb | 10 ++++++++-- .../petstore/models/array_of_array_of_number_only.rb | 10 ++++++++-- .../ruby/lib/petstore/models/array_of_number_only.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/array_test.rb | 10 ++++++++-- .../ruby/lib/petstore/models/capitalization.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/cat.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/category.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/class_model.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/client.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/dog.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/enum_arrays.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/enum_class.rb | 8 ++++++++ .../petstore/ruby/lib/petstore/models/enum_test.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/file.rb | 10 ++++++++-- .../ruby/lib/petstore/models/file_schema_test_class.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/format_test.rb | 10 ++++++++-- .../ruby/lib/petstore/models/has_only_read_only.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/list.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/map_test.rb | 10 ++++++++-- ...mixed_properties_and_additional_properties_class.rb | 10 ++++++++-- .../ruby/lib/petstore/models/model200_response.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/model_return.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/name.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/number_only.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/order.rb | 10 ++++++++-- .../ruby/lib/petstore/models/outer_composite.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/outer_enum.rb | 8 ++++++++ .../client/petstore/ruby/lib/petstore/models/pet.rb | 10 ++++++++-- .../ruby/lib/petstore/models/read_only_first.rb | 10 ++++++++-- .../ruby/lib/petstore/models/special_model_name.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/tag.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/user.rb | 10 ++++++++-- 35 files changed, 273 insertions(+), 67 deletions(-) diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 2e38bc099f7d..85df1d28fd98 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index 6b716e0fa3d4..878be7f81251 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index b82f4d6de053..31eaba3f8b39 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index 7b3e9eeae239..91aff68e5d8a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb index 75605c56bd5e..aa8c2d34bed8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb index 22f04b5b9251..276eba10bbf5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb index e37a54fdecc5..5da3bda45b38 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb index 9be52e89ff07..59085dadb981 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 300da74d3613..4c42f0755ad5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index a00d2e34927d..dd6dd978269a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb index 013dfc01e5be..0f70d9ef08d7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index e3e84e1d86cf..5a248bc0c3e1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index ea62445687eb..de675a834df2 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb index d870963ab7e5..043911c09964 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -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 @@ -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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb index a0b472f3c168..12060da1e83d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb @@ -19,6 +19,13 @@ class EnumClass 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 @@ def build_from_hash(value) value end end + end diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb index b66bdd164727..54d62e17aec9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -187,6 +187,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/file.rb b/samples/client/petstore/ruby/lib/petstore/models/file.rb index 473eb78e06df..9d7eacc845dc 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file.rb @@ -78,6 +78,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb index 43619c4d00c4..dac348cdffab 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb @@ -87,6 +87,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 0d1bc02dddad..e129fa706803 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -390,6 +390,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb index 272a53c53f2d..e4abd4939bac 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -85,6 +85,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index d0399fb4bd40..9f3421caeb5f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -76,6 +76,13 @@ def hash [_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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb index 02f17237f700..98e26cb4d729 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -133,6 +133,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 35e069618c0e..fe3efa3e57dc 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -96,6 +96,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb index b1321c3ffae8..3a5985006c92 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -86,6 +86,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index d573b9ea9af9..9efe48d4fc3b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -77,6 +77,13 @@ def hash [_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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 98aab8f78f41..345adf28ff1a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -109,6 +109,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb index 1e7e626cd17e..7a064ce652fd 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -76,6 +76,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 11f9f4c3710c..e15cb6eaba68 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -158,6 +158,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb index 230bc670767f..bcc41d2e5fd2 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -94,6 +94,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb index cec4c0ef8307..4338180c37b8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb @@ -19,6 +19,13 @@ class OuterEnum 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 @@ def build_from_hash(value) value end end + end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 183f2d9b7ba2..df356088bf21 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -170,6 +170,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb index a181f9a0a9ed..846c6dffc2c1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -85,6 +85,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 2ed4335bef2e..2309bb09f295 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -76,6 +76,13 @@ def hash [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 @@ 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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index e160a1de2758..68c8955a56c9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -85,6 +85,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 @@ -142,8 +149,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 diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index 2c2e0402db59..879aa6299d51 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -140,6 +140,13 @@ def hash [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 @@ 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 From b66ea1e1d14a280619138efeb8e04fc55b79e3c7 Mon Sep 17 00:00:00 2001 From: meganemura Date: Fri, 14 Dec 2018 19:05:10 +0900 Subject: [PATCH 4/4] Update sample for openapi3 ruby-client --- .../client/petstore/ruby/lib/petstore/api_client.rb | 4 +--- .../lib/petstore/models/additional_properties_class.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/animal.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/api_response.rb | 10 ++++++++-- .../petstore/models/array_of_array_of_number_only.rb | 10 ++++++++-- .../ruby/lib/petstore/models/array_of_number_only.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/array_test.rb | 10 ++++++++-- .../ruby/lib/petstore/models/capitalization.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/cat.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/category.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/class_model.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/client.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/dog.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/enum_arrays.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/enum_class.rb | 8 ++++++++ .../petstore/ruby/lib/petstore/models/enum_test.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/file.rb | 10 ++++++++-- .../ruby/lib/petstore/models/file_schema_test_class.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/foo.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/format_test.rb | 10 ++++++++-- .../ruby/lib/petstore/models/has_only_read_only.rb | 10 ++++++++-- .../lib/petstore/models/inline_response_default.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/list.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/map_test.rb | 10 ++++++++-- ...mixed_properties_and_additional_properties_class.rb | 10 ++++++++-- .../ruby/lib/petstore/models/model200_response.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/model_return.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/name.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/number_only.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/order.rb | 10 ++++++++-- .../ruby/lib/petstore/models/outer_composite.rb | 10 ++++++++-- .../petstore/ruby/lib/petstore/models/outer_enum.rb | 8 ++++++++ .../client/petstore/ruby/lib/petstore/models/pet.rb | 10 ++++++++-- .../ruby/lib/petstore/models/read_only_first.rb | 10 ++++++++-- .../ruby/lib/petstore/models/special_model_name.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/tag.rb | 10 ++++++++-- .../client/petstore/ruby/lib/petstore/models/user.rb | 10 ++++++++-- 37 files changed, 289 insertions(+), 71 deletions(-) diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb index 2e38bc099f7d..85df1d28fd98 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index 6b716e0fa3d4..878be7f81251 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb index b82f4d6de053..31eaba3f8b39 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb index 7b3e9eeae239..91aff68e5d8a 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb index 75605c56bd5e..aa8c2d34bed8 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb index 22f04b5b9251..276eba10bbf5 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb index e37a54fdecc5..5da3bda45b38 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb index 9be52e89ff07..59085dadb981 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb index 300da74d3613..4c42f0755ad5 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb index a00d2e34927d..dd6dd978269a 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb index 013dfc01e5be..0f70d9ef08d7 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb index e3e84e1d86cf..5a248bc0c3e1 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb index ea62445687eb..de675a834df2 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb index d870963ab7e5..043911c09964 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -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 @@ -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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb index a0b472f3c168..12060da1e83d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb @@ -19,6 +19,13 @@ class EnumClass 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 @@ def build_from_hash(value) value end end + end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb index b66bdd164727..54d62e17aec9 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -187,6 +187,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb index 473eb78e06df..9d7eacc845dc 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb @@ -78,6 +78,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb index 43619c4d00c4..dac348cdffab 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb @@ -87,6 +87,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb index 1d7224109238..6c344358b8fd 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb @@ -78,6 +78,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb index a1bab83fc893..90890cbd079e 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -421,6 +421,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb index 272a53c53f2d..e4abd4939bac 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -85,6 +85,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb index 5d4ac11be7e6..56bd9d09388c 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb @@ -76,6 +76,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb index d0399fb4bd40..9f3421caeb5f 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb @@ -76,6 +76,13 @@ def hash [_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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb index 02f17237f700..98e26cb4d729 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -133,6 +133,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 35e069618c0e..fe3efa3e57dc 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -96,6 +96,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb index b1321c3ffae8..3a5985006c92 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -86,6 +86,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb index d573b9ea9af9..9efe48d4fc3b 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -77,6 +77,13 @@ def hash [_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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb index 98aab8f78f41..345adf28ff1a 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb @@ -109,6 +109,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb index 1e7e626cd17e..7a064ce652fd 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -76,6 +76,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb index 11f9f4c3710c..e15cb6eaba68 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb @@ -158,6 +158,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb index 230bc670767f..bcc41d2e5fd2 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -94,6 +94,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb index cec4c0ef8307..4338180c37b8 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb @@ -19,6 +19,13 @@ class OuterEnum 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 @@ def build_from_hash(value) value end end + end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb index 183f2d9b7ba2..df356088bf21 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb @@ -170,6 +170,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb index a181f9a0a9ed..846c6dffc2c1 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -85,6 +85,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 2ed4335bef2e..2309bb09f295 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -76,6 +76,13 @@ def hash [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 @@ 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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb index e160a1de2758..68c8955a56c9 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb @@ -85,6 +85,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 @@ -142,8 +149,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 diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb index 2c2e0402db59..879aa6299d51 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb @@ -140,6 +140,13 @@ def hash [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 @@ 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