From f3e573a55df30ace6adc3d525a13c0632572b339 Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Mon, 7 Sep 2026 16:53:02 +0200 Subject: [PATCH 1/6] [ruby] fix: build_from_hash maps attributes inherited from allOf parents A discriminator allOf child generates as a real subclass, but build_from_hash iterated only openapi_types/attribute_map - class methods that dispatch on the child class in every frame of the ancestry, so a parent's attributes were never mapped from the wire hash: a required inherited attribute made deserialization raise ArgumentError, an optional one came back silently nil. The pre-existing super(attributes) call could not help: its result was discarded, and it iterated the child's own types anyway. Walk the ancestry merging each ancestor's openapi_types and attribute_map (the child wins on a name clash) and drop the discarded-result super call. RubyClientCodegenTest asserts the walk on the generated two-level Lizard < Reptile < Pet fixture (fails without the template change), and the three petstore custom base_object specs now deserialize a Cat that carries its parent's attributes. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../ruby-client/base_object.mustache | 26 ++++++++++------ .../codegen/ruby/RubyClientCodegenTest.java | 30 +++++++++++++++++++ .../spec/custom/base_object_spec.rb | 11 +++++++ .../spec/custom/base_object_spec.rb | 11 +++++++ .../ruby/spec/custom/base_object_spec.rb | 11 +++++++ 5 files changed, 80 insertions(+), 9 deletions(-) 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 d752c497c42c..81e0cef9f5b0 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 @@ -3,22 +3,30 @@ # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - {{#parent}} - super(attributes) - {{/parent}} attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index ed256377bc80..22a121e281d5 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -762,4 +762,34 @@ public void testQueryParamJsonSerializationSetsQueryIsJsonMimeType() { assertTrue(op.queryParams.stream().allMatch(p -> p.queryIsJsonMimeType), "All content:application/json query params should have queryIsJsonMimeType=true"); } + + @Test(description = "an allOf child's build_from_hash maps the attributes inherited from its parents") + public void testBuildFromHashMapsInheritedAttributes() throws Exception { + final File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/allOf_composition_discriminator.yaml"); + CodegenConfig codegenConfig = new RubyClientCodegen(); + codegenConfig.setOutputDir(output.getAbsolutePath()); + + ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(codegenConfig); + new DefaultGenerator().opts(clientOptInput).generate(); + + // Lizard < Reptile < Pet: the walk has to collect openapi_types and + // attribute_map from the whole ancestry, not just the child's own + java.nio.file.Path lizard = new File(output, "lib/openapi_client/models/lizard.rb").toPath(); + TestUtils.assertFileContains(lizard, + "types = openapi_types\n" + + " map = attribute_map\n" + + " klass = superclass\n" + + " while klass.respond_to?(:openapi_types)\n" + + " types = klass.openapi_types.merge(types)\n" + + " map = klass.attribute_map.merge(map)\n" + + " klass = klass.superclass\n" + + " end"); + // the discarded-result super call is gone: openapi_types/attribute_map + // dispatch on the child class in the parent's frame too, so it never + // contributed the parent's attributes - it only built a second instance + TestUtils.assertFileNotContains(lizard, "super(attributes)\n attributes = attributes.transform_keys(&:to_sym)"); + } } diff --git a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb index a046c5bd4e11..62615879f450 100644 --- a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb @@ -166,4 +166,15 @@ def initialize(attributes = {}) expect(obj.to_hash).to eq(expect_data) end end + + describe 'attributes inherited from an allOf parent' do + it 'build_from_hash maps the parent attributes too' do + cat = Petstore::Cat.build_from_hash({ 'className' => 'Cat', 'color' => 'black', 'declawed' => true }) + + expect(cat).to be_instance_of(Petstore::Cat) + expect(cat.class_name).to eq('Cat') + expect(cat.color).to eq('black') + expect(cat.declawed).to eq(true) + end + end end diff --git a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb index a046c5bd4e11..62615879f450 100644 --- a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb @@ -166,4 +166,15 @@ def initialize(attributes = {}) expect(obj.to_hash).to eq(expect_data) end end + + describe 'attributes inherited from an allOf parent' do + it 'build_from_hash maps the parent attributes too' do + cat = Petstore::Cat.build_from_hash({ 'className' => 'Cat', 'color' => 'black', 'declawed' => true }) + + expect(cat).to be_instance_of(Petstore::Cat) + expect(cat.class_name).to eq('Cat') + expect(cat.color).to eq('black') + expect(cat.declawed).to eq(true) + end + end end diff --git a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb index a046c5bd4e11..62615879f450 100644 --- a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb @@ -166,4 +166,15 @@ def initialize(attributes = {}) expect(obj.to_hash).to eq(expect_data) end end + + describe 'attributes inherited from an allOf parent' do + it 'build_from_hash maps the parent attributes too' do + cat = Petstore::Cat.build_from_hash({ 'className' => 'Cat', 'color' => 'black', 'declawed' => true }) + + expect(cat).to be_instance_of(Petstore::Cat) + expect(cat.class_name).to eq('Cat') + expect(cat.color).to eq('black') + expect(cat.declawed).to eq(true) + end + end end From 7cd186d97a24f7b177a16f8390a61b15a25698da Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Mon, 7 Sep 2026 16:53:03 +0200 Subject: [PATCH 2/6] update ruby samples Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../lib/openapi_client/models/bird.rb | 23 +++++++++++++----- .../lib/openapi_client/models/category.rb | 23 +++++++++++++----- .../lib/openapi_client/models/data_query.rb | 24 +++++++++++++------ .../openapi_client/models/default_value.rb | 23 +++++++++++++----- .../models/number_properties_only.rb | 23 +++++++++++++----- .../lib/openapi_client/models/pet.rb | 23 +++++++++++++----- .../lib/openapi_client/models/query.rb | 23 +++++++++++++----- .../lib/openapi_client/models/tag.rb | 23 +++++++++++++----- ...st_form_object_multipart_request_marker.rb | 23 +++++++++++++----- ...ue_object_all_of_query_object_parameter.rb | 23 +++++++++++++----- ...rue_array_string_query_object_parameter.rb | 23 +++++++++++++----- .../lib/openapi_client/models/bird.rb | 23 +++++++++++++----- .../lib/openapi_client/models/category.rb | 23 +++++++++++++----- .../lib/openapi_client/models/data_query.rb | 24 +++++++++++++------ .../openapi_client/models/default_value.rb | 23 +++++++++++++----- .../models/number_properties_only.rb | 23 +++++++++++++----- .../lib/openapi_client/models/pet.rb | 23 +++++++++++++----- .../lib/openapi_client/models/query.rb | 23 +++++++++++++----- .../lib/openapi_client/models/tag.rb | 23 +++++++++++++----- ...st_form_object_multipart_request_marker.rb | 23 +++++++++++++----- ...ue_object_all_of_query_object_parameter.rb | 23 +++++++++++++----- ...rue_array_string_query_object_parameter.rb | 23 +++++++++++++----- .../lib/openapi_client/models/bird.rb | 23 +++++++++++++----- .../lib/openapi_client/models/category.rb | 23 +++++++++++++----- .../lib/openapi_client/models/data_query.rb | 24 +++++++++++++------ .../openapi_client/models/default_value.rb | 23 +++++++++++++----- .../models/number_properties_only.rb | 23 +++++++++++++----- .../lib/openapi_client/models/pet.rb | 23 +++++++++++++----- .../lib/openapi_client/models/query.rb | 23 +++++++++++++----- .../lib/openapi_client/models/tag.rb | 23 +++++++++++++----- ...st_form_object_multipart_request_marker.rb | 23 +++++++++++++----- ...ue_object_all_of_query_object_parameter.rb | 23 +++++++++++++----- ...rue_array_string_query_object_parameter.rb | 23 +++++++++++++----- .../models/additional_properties_class.rb | 23 +++++++++++++----- .../petstore/models/all_of_with_single_ref.rb | 23 +++++++++++++----- .../lib/petstore/models/animal.rb | 23 +++++++++++++----- .../lib/petstore/models/api_response.rb | 23 +++++++++++++----- .../models/array_of_array_of_number_only.rb | 23 +++++++++++++----- .../petstore/models/array_of_number_only.rb | 23 +++++++++++++----- .../lib/petstore/models/array_test.rb | 23 +++++++++++++----- .../lib/petstore/models/capitalization.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/cat.rb | 24 +++++++++++++------ .../lib/petstore/models/category.rb | 23 +++++++++++++----- .../petstore/models/child_with_nullable.rb | 24 +++++++++++++------ .../lib/petstore/models/class_model.rb | 23 +++++++++++++----- .../lib/petstore/models/client.rb | 23 +++++++++++++----- .../lib/petstore/models/deprecated_object.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/dog.rb | 24 +++++++++++++------ .../lib/petstore/models/enum_arrays.rb | 23 +++++++++++++----- .../lib/petstore/models/enum_test.rb | 23 +++++++++++++----- .../fake_big_decimal_map200_response.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/file.rb | 23 +++++++++++++----- .../petstore/models/file_schema_test_class.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/foo.rb | 23 +++++++++++++----- .../models/foo_get_default_response.rb | 23 +++++++++++++----- .../lib/petstore/models/format_test.rb | 23 +++++++++++++----- .../lib/petstore/models/has_only_read_only.rb | 23 +++++++++++++----- .../petstore/models/health_check_result.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/list.rb | 23 +++++++++++++----- .../lib/petstore/models/map_test.rb | 23 +++++++++++++----- ...perties_and_additional_properties_class.rb | 23 +++++++++++++----- .../lib/petstore/models/model200_response.rb | 23 +++++++++++++----- .../lib/petstore/models/model_return.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/name.rb | 23 +++++++++++++----- .../lib/petstore/models/nullable_class.rb | 23 +++++++++++++----- .../lib/petstore/models/number_only.rb | 23 +++++++++++++----- .../models/object_with_deprecated_fields.rb | 23 +++++++++++++----- .../lib/petstore/models/order.rb | 23 +++++++++++++----- .../lib/petstore/models/outer_composite.rb | 23 +++++++++++++----- .../models/outer_object_with_enum_property.rb | 23 +++++++++++++----- .../petstore/models/parent_with_nullable.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/pet.rb | 23 +++++++++++++----- .../lib/petstore/models/read_only_first.rb | 23 +++++++++++++----- .../lib/petstore/models/special_model_name.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/tag.rb | 23 +++++++++++++----- ..._freeform_additional_properties_request.rb | 23 +++++++++++++----- .../ruby-autoload/lib/petstore/models/user.rb | 23 +++++++++++++----- .../client/petstore/ruby-faraday/Gemfile.lock | 4 ++-- .../models/additional_properties_class.rb | 23 +++++++++++++----- .../petstore/models/all_of_with_single_ref.rb | 23 +++++++++++++----- .../lib/petstore/models/animal.rb | 23 +++++++++++++----- .../lib/petstore/models/api_response.rb | 23 +++++++++++++----- .../models/array_of_array_of_number_only.rb | 23 +++++++++++++----- .../petstore/models/array_of_number_only.rb | 23 +++++++++++++----- .../lib/petstore/models/array_test.rb | 23 +++++++++++++----- .../lib/petstore/models/capitalization.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/cat.rb | 24 +++++++++++++------ .../lib/petstore/models/category.rb | 23 +++++++++++++----- .../lib/petstore/models/class_model.rb | 23 +++++++++++++----- .../lib/petstore/models/client.rb | 23 +++++++++++++----- .../lib/petstore/models/deprecated_object.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/dog.rb | 24 +++++++++++++------ .../lib/petstore/models/enum_arrays.rb | 23 +++++++++++++----- .../lib/petstore/models/enum_test.rb | 23 +++++++++++++----- .../fake_big_decimal_map200_response.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/file.rb | 23 +++++++++++++----- .../petstore/models/file_schema_test_class.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/foo.rb | 23 +++++++++++++----- .../models/foo_get_default_response.rb | 23 +++++++++++++----- .../lib/petstore/models/format_test.rb | 23 +++++++++++++----- .../lib/petstore/models/has_only_read_only.rb | 23 +++++++++++++----- .../petstore/models/health_check_result.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/list.rb | 23 +++++++++++++----- .../lib/petstore/models/map_test.rb | 23 +++++++++++++----- ...perties_and_additional_properties_class.rb | 23 +++++++++++++----- .../lib/petstore/models/model200_response.rb | 23 +++++++++++++----- .../lib/petstore/models/model_return.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/name.rb | 23 +++++++++++++----- .../lib/petstore/models/nullable_class.rb | 23 +++++++++++++----- .../lib/petstore/models/number_only.rb | 23 +++++++++++++----- .../models/object_with_deprecated_fields.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/order.rb | 23 +++++++++++++----- .../lib/petstore/models/outer_composite.rb | 23 +++++++++++++----- .../models/outer_object_with_enum_property.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/pet.rb | 23 +++++++++++++----- .../petstore/models/property_name_mapping.rb | 23 +++++++++++++----- .../lib/petstore/models/read_only_first.rb | 23 +++++++++++++----- .../lib/petstore/models/special_model_name.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/tag.rb | 23 +++++++++++++----- ..._freeform_additional_properties_request.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/user.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/whale.rb | 23 +++++++++++++----- .../ruby-faraday/lib/petstore/models/zebra.rb | 23 +++++++++++++----- .../models/additional_properties_class.rb | 23 +++++++++++++----- .../petstore/models/all_of_with_single_ref.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/animal.rb | 23 +++++++++++++----- .../lib/petstore/models/api_response.rb | 23 +++++++++++++----- .../models/array_of_array_of_number_only.rb | 23 +++++++++++++----- .../petstore/models/array_of_number_only.rb | 23 +++++++++++++----- .../lib/petstore/models/array_test.rb | 23 +++++++++++++----- .../lib/petstore/models/capitalization.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/cat.rb | 24 +++++++++++++------ .../lib/petstore/models/category.rb | 23 +++++++++++++----- .../lib/petstore/models/class_model.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/client.rb | 23 +++++++++++++----- .../lib/petstore/models/deprecated_object.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/dog.rb | 24 +++++++++++++------ .../lib/petstore/models/enum_arrays.rb | 23 +++++++++++++----- .../lib/petstore/models/enum_test.rb | 23 +++++++++++++----- .../fake_big_decimal_map200_response.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/file.rb | 23 +++++++++++++----- .../petstore/models/file_schema_test_class.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/foo.rb | 23 +++++++++++++----- .../models/foo_get_default_response.rb | 23 +++++++++++++----- .../lib/petstore/models/format_test.rb | 23 +++++++++++++----- .../lib/petstore/models/has_only_read_only.rb | 23 +++++++++++++----- .../petstore/models/health_check_result.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/list.rb | 23 +++++++++++++----- .../lib/petstore/models/map_test.rb | 23 +++++++++++++----- ...perties_and_additional_properties_class.rb | 23 +++++++++++++----- .../lib/petstore/models/model200_response.rb | 23 +++++++++++++----- .../lib/petstore/models/model_return.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/name.rb | 23 +++++++++++++----- .../lib/petstore/models/nullable_class.rb | 23 +++++++++++++----- .../lib/petstore/models/number_only.rb | 23 +++++++++++++----- .../models/object_with_deprecated_fields.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/order.rb | 23 +++++++++++++----- .../lib/petstore/models/outer_composite.rb | 23 +++++++++++++----- .../models/outer_object_with_enum_property.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/pet.rb | 23 +++++++++++++----- .../petstore/models/property_name_mapping.rb | 23 +++++++++++++----- .../lib/petstore/models/read_only_first.rb | 23 +++++++++++++----- .../lib/petstore/models/special_model_name.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/tag.rb | 23 +++++++++++++----- ..._freeform_additional_properties_request.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/user.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/whale.rb | 23 +++++++++++++----- .../ruby-httpx/lib/petstore/models/zebra.rb | 23 +++++++++++++----- .../models/additional_properties_class.rb | 23 +++++++++++++----- .../petstore/models/all_of_with_single_ref.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/animal.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/api_response.rb | 23 +++++++++++++----- .../models/array_of_array_of_number_only.rb | 23 +++++++++++++----- .../petstore/models/array_of_number_only.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/array_test.rb | 23 +++++++++++++----- .../lib/petstore/models/capitalization.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/cat.rb | 24 +++++++++++++------ .../ruby/lib/petstore/models/category.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/class_model.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/client.rb | 23 +++++++++++++----- .../lib/petstore/models/deprecated_object.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/dog.rb | 24 +++++++++++++------ .../ruby/lib/petstore/models/enum_arrays.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/enum_test.rb | 23 +++++++++++++----- .../fake_big_decimal_map200_response.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/file.rb | 23 +++++++++++++----- .../petstore/models/file_schema_test_class.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/foo.rb | 23 +++++++++++++----- .../models/foo_get_default_response.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/format_test.rb | 23 +++++++++++++----- .../lib/petstore/models/has_only_read_only.rb | 23 +++++++++++++----- .../petstore/models/health_check_result.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/list.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/map_test.rb | 23 +++++++++++++----- ...perties_and_additional_properties_class.rb | 23 +++++++++++++----- .../lib/petstore/models/model200_response.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/model_return.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/name.rb | 23 +++++++++++++----- .../lib/petstore/models/nullable_class.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/number_only.rb | 23 +++++++++++++----- .../models/object_with_deprecated_fields.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/order.rb | 23 +++++++++++++----- .../lib/petstore/models/outer_composite.rb | 23 +++++++++++++----- .../models/outer_object_with_enum_property.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/pet.rb | 23 +++++++++++++----- .../petstore/models/property_name_mapping.rb | 23 +++++++++++++----- .../lib/petstore/models/read_only_first.rb | 23 +++++++++++++----- .../lib/petstore/models/special_model_name.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/tag.rb | 23 +++++++++++++----- ..._freeform_additional_properties_request.rb | 23 +++++++++++++----- .../petstore/ruby/lib/petstore/models/user.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/whale.rb | 23 +++++++++++++----- .../ruby/lib/petstore/models/zebra.rb | 23 +++++++++++++----- .../lib/petstore/models/array_alias.rb | 24 +++++++++++++------ .../lib/petstore/models/map_alias.rb | 23 +++++++++++++----- 215 files changed, 3640 insertions(+), 1299 deletions(-) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb index 791ff7830e90..bb79bf1c519b 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb index 2ae2f25e7bb6..e558333825f2 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb index 1a31b4d3e83f..9e9d8976d93b 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb @@ -161,20 +161,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb index 9dbb442bb860..e21c0fdf6780 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb @@ -212,18 +212,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb index 46b63c582964..9812f0016bd1 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb @@ -155,18 +155,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb index d1a334676d56..79d5efdb517a 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb @@ -227,18 +227,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb index 7598d312f1dd..7d9c34274f88 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb @@ -143,18 +143,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb index d087eafa1516..99eea26aeabe 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 1b00e10e7dc3..1649f2f0c722 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 02afae09bce2..560b83ea4b27 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -144,18 +144,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index fa9520a4f16c..39fb2fecfea5 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb index 791ff7830e90..bb79bf1c519b 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb index 2ae2f25e7bb6..e558333825f2 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb index 1a31b4d3e83f..9e9d8976d93b 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb @@ -161,20 +161,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb index 9dbb442bb860..e21c0fdf6780 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb @@ -212,18 +212,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb index 46b63c582964..9812f0016bd1 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb @@ -155,18 +155,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb index d1a334676d56..79d5efdb517a 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb @@ -227,18 +227,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb index 7598d312f1dd..7d9c34274f88 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb @@ -143,18 +143,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb index d087eafa1516..99eea26aeabe 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 1b00e10e7dc3..1649f2f0c722 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 02afae09bce2..560b83ea4b27 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -144,18 +144,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index fa9520a4f16c..39fb2fecfea5 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb index 791ff7830e90..bb79bf1c519b 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb index 2ae2f25e7bb6..e558333825f2 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb index 1a31b4d3e83f..9e9d8976d93b 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb @@ -161,20 +161,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb index 9dbb442bb860..e21c0fdf6780 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb @@ -212,18 +212,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb index 46b63c582964..9812f0016bd1 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb @@ -155,18 +155,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb index d1a334676d56..79d5efdb517a 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb @@ -227,18 +227,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb index 7598d312f1dd..7d9c34274f88 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb @@ -143,18 +143,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb index d087eafa1516..99eea26aeabe 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 1b00e10e7dc3..1649f2f0c722 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 02afae09bce2..560b83ea4b27 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -144,18 +144,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index fa9520a4f16c..39fb2fecfea5 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb index 9b823593d156..9ec03111fc38 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb @@ -122,18 +122,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb index 600c974fa1e5..4581a7740eaa 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb @@ -140,18 +140,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb index 21d89bccb837..37d09285f53e 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb @@ -142,18 +142,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb index bbbaf9358be2..a7c040fb8f5d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb index e20b1728d130..3477ef02806a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb index 63890ff64424..f86643782a55 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb index c74060151e07..8f3e8d2bab13 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb @@ -161,18 +161,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb index e0bbeb211eb3..7653d972a974 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb @@ -155,18 +155,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb index a84dc5038bef..ed13b482a4a1 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb index 2f2b7f1a5785..f26dbd6e30e5 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb @@ -135,18 +135,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb index a7c86c864e6e..6845a9c94be0 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb @@ -140,20 +140,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb index fafd11df773a..bf5ff3216fd7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb index a349b7251d7b..e95c80ae30f0 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb index 9f1ee6720cab..35cc19e2020a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb index 522e1a72f47e..d3099592a779 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb index 1f7c48bf859b..9121236c907c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb index 5159875cb89b..f854cf6c7af0 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb @@ -254,18 +254,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb index 6d5e47b59656..ea6b6b7d9be7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb index 219237eb3c07..f6d77577ae04 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb index 8fdab5a25e86..d13bd9a9a493 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb index ceb5b7497955..f63d984207e9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb index 42538a14e2cb..c485789a41e9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb index 03a4e130a8f9..f273072f54bb 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb @@ -525,18 +525,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb index cc584c09e54f..44ee9a9df8e2 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb index a66e1b71331d..f5fd688ef293 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb index 2dc658065278..620ff57fc0a6 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb index 78c5472f24ae..1ab375d72b2c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb @@ -166,18 +166,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index bf1d3768951b..36f68fec8c4f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -129,18 +129,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb index 9cff83ced2c9..239cbaeeb4c6 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb @@ -119,18 +119,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb index d520a45c2040..2e582a7cbc0c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb index 45b01b5746d3..3c991b0571f1 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb index f81fb17f118a..34b7cb569a08 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb @@ -230,18 +230,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb index 9bf457dfd188..af432acc8b31 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb index dceda346bd70..e2c79d68dab1 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb @@ -138,18 +138,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb index f7e7b4eb9117..820666bd80ab 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb @@ -191,18 +191,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb index 2245e8512600..b7fa2c562eb6 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb index 8ffad20f8d89..f956597c8601 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb @@ -148,18 +148,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb index dde93af94488..cb6d37e97337 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb @@ -158,18 +158,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb index e3594a1fb052..5403a5b76bea 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb @@ -227,18 +227,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb index c2121474ebb7..e99f2cb7934a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb index 9569fbfd13dd..dd02780e4e61 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb index 6d6f57468181..b57fd9ff9941 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index dc481c119d22..5f28f1cbd9f6 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb index 9b06f2ff6d7a..61c2706b47de 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb @@ -173,18 +173,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/Gemfile.lock b/samples/client/petstore/ruby-faraday/Gemfile.lock index 081638f0e42a..89c35709fe4f 100644 --- a/samples/client/petstore/ruby-faraday/Gemfile.lock +++ b/samples/client/petstore/ruby-faraday/Gemfile.lock @@ -15,8 +15,8 @@ GEM diff-lcs (1.5.1) faraday (2.9.0) faraday-net_http (>= 2.0, < 3.2) - faraday-multipart (1.0.4) - multipart-post (~> 2) + faraday-multipart (1.2.0) + multipart-post (~> 2.0) faraday-net_http (3.1.0) net-http jaro_winkler (1.5.6) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb index 9b823593d156..9ec03111fc38 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb @@ -122,18 +122,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb index 600c974fa1e5..4581a7740eaa 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb @@ -140,18 +140,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb index 21d89bccb837..37d09285f53e 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb @@ -142,18 +142,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb index bbbaf9358be2..a7c040fb8f5d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb index e20b1728d130..3477ef02806a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb index 63890ff64424..f86643782a55 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb index c74060151e07..8f3e8d2bab13 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb @@ -161,18 +161,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb index e0bbeb211eb3..7653d972a974 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb @@ -155,18 +155,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb index a84dc5038bef..ed13b482a4a1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb index 2f2b7f1a5785..f26dbd6e30e5 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb @@ -135,18 +135,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb index fafd11df773a..bf5ff3216fd7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb index a349b7251d7b..e95c80ae30f0 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb index 9f1ee6720cab..35cc19e2020a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb index 522e1a72f47e..d3099592a779 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb index 1f7c48bf859b..9121236c907c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb index 5159875cb89b..f854cf6c7af0 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb @@ -254,18 +254,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb index 6d5e47b59656..ea6b6b7d9be7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb index 219237eb3c07..f6d77577ae04 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb index 8fdab5a25e86..d13bd9a9a493 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb index ceb5b7497955..f63d984207e9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb index 42538a14e2cb..c485789a41e9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb index 03a4e130a8f9..f273072f54bb 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb @@ -525,18 +525,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb index cc584c09e54f..44ee9a9df8e2 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb index a66e1b71331d..f5fd688ef293 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb index 2dc658065278..620ff57fc0a6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb index 78c5472f24ae..1ab375d72b2c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb @@ -166,18 +166,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index bf1d3768951b..36f68fec8c4f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -129,18 +129,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb index 9cff83ced2c9..239cbaeeb4c6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb @@ -119,18 +119,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb index d520a45c2040..2e582a7cbc0c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb index 45b01b5746d3..3c991b0571f1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb index f81fb17f118a..34b7cb569a08 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb @@ -230,18 +230,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb index 9bf457dfd188..af432acc8b31 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb index dceda346bd70..e2c79d68dab1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb @@ -138,18 +138,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb index f7e7b4eb9117..820666bd80ab 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb @@ -191,18 +191,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb index 2245e8512600..b7fa2c562eb6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb index 8ffad20f8d89..f956597c8601 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb @@ -148,18 +148,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb index e3594a1fb052..5403a5b76bea 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb @@ -227,18 +227,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb index 8328edb9227a..93b016d9ea66 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb @@ -136,18 +136,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb index c2121474ebb7..e99f2cb7934a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb index 9569fbfd13dd..dd02780e4e61 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb index 6d6f57468181..b57fd9ff9941 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index dc481c119d22..5f28f1cbd9f6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb index 9b06f2ff6d7a..61c2706b47de 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb @@ -173,18 +173,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb index 23249be434e4..9060d440ef64 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb @@ -144,18 +144,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb index 10e910f409f7..673e36ec14c1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb @@ -169,18 +169,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb index 9b823593d156..9ec03111fc38 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb @@ -122,18 +122,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb index 600c974fa1e5..4581a7740eaa 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb @@ -140,18 +140,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb index 21d89bccb837..37d09285f53e 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb @@ -142,18 +142,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb index bbbaf9358be2..a7c040fb8f5d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb index e20b1728d130..3477ef02806a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb index 63890ff64424..f86643782a55 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb index c74060151e07..8f3e8d2bab13 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb @@ -161,18 +161,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb index e0bbeb211eb3..7653d972a974 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb @@ -155,18 +155,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb index a84dc5038bef..ed13b482a4a1 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb index 2f2b7f1a5785..f26dbd6e30e5 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb @@ -135,18 +135,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb index fafd11df773a..bf5ff3216fd7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb index a349b7251d7b..e95c80ae30f0 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb index 9f1ee6720cab..35cc19e2020a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb index 522e1a72f47e..d3099592a779 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb index 1f7c48bf859b..9121236c907c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb index 5159875cb89b..f854cf6c7af0 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb @@ -254,18 +254,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb index 6d5e47b59656..ea6b6b7d9be7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb index 219237eb3c07..f6d77577ae04 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb index 8fdab5a25e86..d13bd9a9a493 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb index ceb5b7497955..f63d984207e9 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb index 42538a14e2cb..c485789a41e9 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb index 03a4e130a8f9..f273072f54bb 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb @@ -525,18 +525,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb index cc584c09e54f..44ee9a9df8e2 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb index a66e1b71331d..f5fd688ef293 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb index 2dc658065278..620ff57fc0a6 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb index 78c5472f24ae..1ab375d72b2c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb @@ -166,18 +166,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index bf1d3768951b..36f68fec8c4f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -129,18 +129,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb index 9cff83ced2c9..239cbaeeb4c6 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb @@ -119,18 +119,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb index d520a45c2040..2e582a7cbc0c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb index 45b01b5746d3..3c991b0571f1 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb index f81fb17f118a..34b7cb569a08 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb @@ -230,18 +230,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb index 9bf457dfd188..af432acc8b31 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb index dceda346bd70..e2c79d68dab1 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb @@ -138,18 +138,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb index f7e7b4eb9117..820666bd80ab 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb @@ -191,18 +191,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb index 2245e8512600..b7fa2c562eb6 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb index 8ffad20f8d89..f956597c8601 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb @@ -148,18 +148,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb index e3594a1fb052..5403a5b76bea 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb @@ -227,18 +227,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb index 8328edb9227a..93b016d9ea66 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb @@ -136,18 +136,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb index c2121474ebb7..e99f2cb7934a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb index 9569fbfd13dd..dd02780e4e61 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb index 6d6f57468181..b57fd9ff9941 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index dc481c119d22..5f28f1cbd9f6 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb index 9b06f2ff6d7a..61c2706b47de 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb @@ -173,18 +173,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb index 23249be434e4..9060d440ef64 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb @@ -144,18 +144,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb index 10e910f409f7..673e36ec14c1 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb @@ -169,18 +169,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 9b823593d156..9ec03111fc38 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 @@ -122,18 +122,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb index 600c974fa1e5..4581a7740eaa 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb @@ -140,18 +140,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 21d89bccb837..37d09285f53e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -142,18 +142,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 bbbaf9358be2..a7c040fb8f5d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 e20b1728d130..3477ef02806a 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 @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 63890ff64424..f86643782a55 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 @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 c74060151e07..8f3e8d2bab13 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -161,18 +161,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb index e0bbeb211eb3..7653d972a974 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -155,18 +155,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index a84dc5038bef..ed13b482a4a1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 2f2b7f1a5785..f26dbd6e30e5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -135,18 +135,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 fafd11df773a..bf5ff3216fd7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index a349b7251d7b..e95c80ae30f0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb index 9f1ee6720cab..35cc19e2020a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 522e1a72f47e..d3099592a779 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -118,20 +118,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 1f7c48bf859b..9121236c907c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 5159875cb89b..f854cf6c7af0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -254,18 +254,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb index 6d5e47b59656..ea6b6b7d9be7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/file.rb b/samples/client/petstore/ruby/lib/petstore/models/file.rb index 219237eb3c07..f6d77577ae04 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 8fdab5a25e86..d13bd9a9a493 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 @@ -120,18 +120,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/client/petstore/ruby/lib/petstore/models/foo.rb index ceb5b7497955..f63d984207e9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb index 42538a14e2cb..c485789a41e9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 03a4e130a8f9..f273072f54bb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -525,18 +525,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 cc584c09e54f..44ee9a9df8e2 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 @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb index a66e1b71331d..f5fd688ef293 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb @@ -111,18 +111,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index 2dc658065278..620ff57fc0a6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 78c5472f24ae..1ab375d72b2c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -166,18 +166,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 bf1d3768951b..36f68fec8c4f 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 @@ -129,18 +129,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 9cff83ced2c9..239cbaeeb4c6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -119,18 +119,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 d520a45c2040..2e582a7cbc0c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -110,18 +110,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 45b01b5746d3..3c991b0571f1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -154,18 +154,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb index f81fb17f118a..34b7cb569a08 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb @@ -230,18 +230,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 9bf457dfd188..af432acc8b31 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb index dceda346bd70..e2c79d68dab1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb @@ -138,18 +138,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index f7e7b4eb9117..820666bd80ab 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -191,18 +191,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 2245e8512600..b7fa2c562eb6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -127,18 +127,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb index 8ffad20f8d89..f956597c8601 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb @@ -148,18 +148,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index e3594a1fb052..5403a5b76bea 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -227,18 +227,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb index 09e50b68dc06..6ea182ad3c77 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb @@ -136,18 +136,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 c2121474ebb7..e99f2cb7934a 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 @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) 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 9569fbfd13dd..dd02780e4e61 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 @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index 6d6f57468181..b57fd9ff9941 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -118,18 +118,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index dc481c119d22..5f28f1cbd9f6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -109,18 +109,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index 9b06f2ff6d7a..61c2706b47de 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -173,18 +173,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/whale.rb b/samples/client/petstore/ruby/lib/petstore/models/whale.rb index 23249be434e4..9060d440ef64 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/whale.rb @@ -144,18 +144,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb index 10e910f409f7..673e36ec14c1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb @@ -169,18 +169,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb index 9ffe5b9100b1..53a2c9652657 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb @@ -102,20 +102,30 @@ def hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - super(attributes) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb index 431c5fbcab6c..6dcd089635af 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb @@ -100,18 +100,29 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) + # collect the attributes this model knows about, including the ones + # defined in its parent(s), so an allOf child also maps its inherited + # attributes (the child's own declaration wins on a name clash) + types = openapi_types + map = attribute_map + klass = superclass + while klass.respond_to?(:openapi_types) + types = klass.openapi_types.merge(types) + map = klass.attribute_map.merge(map) + klass = klass.superclass + end transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + types.each_pair do |key, type| + if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes[map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) } end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + elsif !attributes[map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]]) end end new(transformed_hash) From 97e0462f2fc080520ffce417ac0039fbb65b7bbe Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Mon, 7 Sep 2026 21:27:44 +0200 Subject: [PATCH 3/6] [ruby] fix: to_hash loses the same inherited attributes The serialization direction has the identical defect: attribute_map and openapi_nullable dispatch on the child class in every ancestor frame, so the inherited super chain only repeated the child's own attributes and a round-tripped allOf child lost its parent's fields again on the way out. Walk the ancestry the same way build_from_hash now does; for a model without a generated parent the walk does not run and the output is unchanged. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../resources/ruby-client/base_object.mustache | 18 +++++++++++++++--- .../codegen/ruby/RubyClientCodegenTest.java | 12 ++++++++++++ .../spec/custom/base_object_spec.rb | 6 ++++++ .../ruby-httpx/spec/custom/base_object_spec.rb | 6 ++++++ .../ruby/spec/custom/base_object_spec.rb | 6 ++++++ 5 files changed, 45 insertions(+), 3 deletions(-) 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 81e0cef9f5b0..4fb5acc89423 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 @@ -35,11 +35,23 @@ # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = {{^parent}}{}{{/parent}}{{#parent}}super{{/parent}} - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index 22a121e281d5..a04b88269764 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -791,5 +791,17 @@ public void testBuildFromHashMapsInheritedAttributes() throws Exception { // dispatch on the child class in the parent's frame too, so it never // contributed the parent's attributes - it only built a second instance TestUtils.assertFileNotContains(lizard, "super(attributes)\n attributes = attributes.transform_keys(&:to_sym)"); + // to_hash walks the same ancestry: attribute_map/openapi_nullable dispatch on the + // child in every ancestor frame, so the old super chain only repeated the child's + // own attributes and a round-tripped model lost its inherited fields + TestUtils.assertFileContains(lizard, + "map = self.class.attribute_map\n" + + " nullable = self.class.openapi_nullable\n" + + " klass = self.class.superclass\n" + + " while klass.respond_to?(:openapi_types)\n" + + " map = klass.attribute_map.merge(map)\n" + + " nullable = nullable | klass.openapi_nullable\n" + + " klass = klass.superclass\n" + + " end"); } } diff --git a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb index 62615879f450..cca4f2cd1419 100644 --- a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb @@ -176,5 +176,11 @@ def initialize(attributes = {}) expect(cat.color).to eq('black') expect(cat.declawed).to eq(true) end + + it 'to_hash serializes the parent attributes too' do + cat = Petstore::Cat.build_from_hash({ 'className' => 'Cat', 'color' => 'black', 'declawed' => true }) + + expect(cat.to_hash).to eq({ className: 'Cat', color: 'black', declawed: true }) + end end end diff --git a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb index 62615879f450..cca4f2cd1419 100644 --- a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb @@ -176,5 +176,11 @@ def initialize(attributes = {}) expect(cat.color).to eq('black') expect(cat.declawed).to eq(true) end + + it 'to_hash serializes the parent attributes too' do + cat = Petstore::Cat.build_from_hash({ 'className' => 'Cat', 'color' => 'black', 'declawed' => true }) + + expect(cat.to_hash).to eq({ className: 'Cat', color: 'black', declawed: true }) + end end end diff --git a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb index 62615879f450..cca4f2cd1419 100644 --- a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb @@ -176,5 +176,11 @@ def initialize(attributes = {}) expect(cat.color).to eq('black') expect(cat.declawed).to eq(true) end + + it 'to_hash serializes the parent attributes too' do + cat = Petstore::Cat.build_from_hash({ 'className' => 'Cat', 'color' => 'black', 'declawed' => true }) + + expect(cat.to_hash).to eq({ className: 'Cat', color: 'black', declawed: true }) + end end end From 609c4a4d8a0633116ecefccf14e9a48c58a61a53 Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Mon, 7 Sep 2026 21:27:45 +0200 Subject: [PATCH 4/6] update ruby samples Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../lib/openapi_client/models/bird.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/category.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/data_query.rb | 18 +++++++++++++++--- .../lib/openapi_client/models/default_value.rb | 16 ++++++++++++++-- .../models/number_properties_only.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/pet.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/query.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/tag.rb | 16 ++++++++++++++-- ...est_form_object_multipart_request_marker.rb | 16 ++++++++++++++-- ...rue_object_all_of_query_object_parameter.rb | 16 ++++++++++++++-- ...true_array_string_query_object_parameter.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/bird.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/category.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/data_query.rb | 18 +++++++++++++++--- .../lib/openapi_client/models/default_value.rb | 16 ++++++++++++++-- .../models/number_properties_only.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/pet.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/query.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/tag.rb | 16 ++++++++++++++-- ...est_form_object_multipart_request_marker.rb | 16 ++++++++++++++-- ...rue_object_all_of_query_object_parameter.rb | 16 ++++++++++++++-- ...true_array_string_query_object_parameter.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/bird.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/category.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/data_query.rb | 18 +++++++++++++++--- .../lib/openapi_client/models/default_value.rb | 16 ++++++++++++++-- .../models/number_properties_only.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/pet.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/query.rb | 16 ++++++++++++++-- .../lib/openapi_client/models/tag.rb | 16 ++++++++++++++-- ...est_form_object_multipart_request_marker.rb | 16 ++++++++++++++-- ...rue_object_all_of_query_object_parameter.rb | 16 ++++++++++++++-- ...true_array_string_query_object_parameter.rb | 16 ++++++++++++++-- .../models/additional_properties_class.rb | 16 ++++++++++++++-- .../petstore/models/all_of_with_single_ref.rb | 16 ++++++++++++++-- .../lib/petstore/models/animal.rb | 16 ++++++++++++++-- .../lib/petstore/models/api_response.rb | 16 ++++++++++++++-- .../models/array_of_array_of_number_only.rb | 16 ++++++++++++++-- .../petstore/models/array_of_number_only.rb | 16 ++++++++++++++-- .../lib/petstore/models/array_test.rb | 16 ++++++++++++++-- .../lib/petstore/models/capitalization.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/cat.rb | 18 +++++++++++++++--- .../lib/petstore/models/category.rb | 16 ++++++++++++++-- .../lib/petstore/models/child_with_nullable.rb | 18 +++++++++++++++--- .../lib/petstore/models/class_model.rb | 16 ++++++++++++++-- .../lib/petstore/models/client.rb | 16 ++++++++++++++-- .../lib/petstore/models/deprecated_object.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/dog.rb | 18 +++++++++++++++--- .../lib/petstore/models/enum_arrays.rb | 16 ++++++++++++++-- .../lib/petstore/models/enum_test.rb | 16 ++++++++++++++-- .../models/fake_big_decimal_map200_response.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/file.rb | 16 ++++++++++++++-- .../petstore/models/file_schema_test_class.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/foo.rb | 16 ++++++++++++++-- .../models/foo_get_default_response.rb | 16 ++++++++++++++-- .../lib/petstore/models/format_test.rb | 16 ++++++++++++++-- .../lib/petstore/models/has_only_read_only.rb | 16 ++++++++++++++-- .../lib/petstore/models/health_check_result.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/list.rb | 16 ++++++++++++++-- .../lib/petstore/models/map_test.rb | 16 ++++++++++++++-- ...operties_and_additional_properties_class.rb | 16 ++++++++++++++-- .../lib/petstore/models/model200_response.rb | 16 ++++++++++++++-- .../lib/petstore/models/model_return.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/name.rb | 16 ++++++++++++++-- .../lib/petstore/models/nullable_class.rb | 16 ++++++++++++++-- .../lib/petstore/models/number_only.rb | 16 ++++++++++++++-- .../models/object_with_deprecated_fields.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/order.rb | 16 ++++++++++++++-- .../lib/petstore/models/outer_composite.rb | 16 ++++++++++++++-- .../models/outer_object_with_enum_property.rb | 16 ++++++++++++++-- .../petstore/models/parent_with_nullable.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/pet.rb | 16 ++++++++++++++-- .../lib/petstore/models/read_only_first.rb | 16 ++++++++++++++-- .../lib/petstore/models/special_model_name.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/tag.rb | 16 ++++++++++++++-- ...e_freeform_additional_properties_request.rb | 16 ++++++++++++++-- .../ruby-autoload/lib/petstore/models/user.rb | 16 ++++++++++++++-- .../models/additional_properties_class.rb | 16 ++++++++++++++-- .../petstore/models/all_of_with_single_ref.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/animal.rb | 16 ++++++++++++++-- .../lib/petstore/models/api_response.rb | 16 ++++++++++++++-- .../models/array_of_array_of_number_only.rb | 16 ++++++++++++++-- .../petstore/models/array_of_number_only.rb | 16 ++++++++++++++-- .../lib/petstore/models/array_test.rb | 16 ++++++++++++++-- .../lib/petstore/models/capitalization.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/cat.rb | 18 +++++++++++++++--- .../lib/petstore/models/category.rb | 16 ++++++++++++++-- .../lib/petstore/models/class_model.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/client.rb | 16 ++++++++++++++-- .../lib/petstore/models/deprecated_object.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/dog.rb | 18 +++++++++++++++--- .../lib/petstore/models/enum_arrays.rb | 16 ++++++++++++++-- .../lib/petstore/models/enum_test.rb | 16 ++++++++++++++-- .../models/fake_big_decimal_map200_response.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/file.rb | 16 ++++++++++++++-- .../petstore/models/file_schema_test_class.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/foo.rb | 16 ++++++++++++++-- .../models/foo_get_default_response.rb | 16 ++++++++++++++-- .../lib/petstore/models/format_test.rb | 16 ++++++++++++++-- .../lib/petstore/models/has_only_read_only.rb | 16 ++++++++++++++-- .../lib/petstore/models/health_check_result.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/list.rb | 16 ++++++++++++++-- .../lib/petstore/models/map_test.rb | 16 ++++++++++++++-- ...operties_and_additional_properties_class.rb | 16 ++++++++++++++-- .../lib/petstore/models/model200_response.rb | 16 ++++++++++++++-- .../lib/petstore/models/model_return.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/name.rb | 16 ++++++++++++++-- .../lib/petstore/models/nullable_class.rb | 16 ++++++++++++++-- .../lib/petstore/models/number_only.rb | 16 ++++++++++++++-- .../models/object_with_deprecated_fields.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/order.rb | 16 ++++++++++++++-- .../lib/petstore/models/outer_composite.rb | 16 ++++++++++++++-- .../models/outer_object_with_enum_property.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/pet.rb | 16 ++++++++++++++-- .../petstore/models/property_name_mapping.rb | 16 ++++++++++++++-- .../lib/petstore/models/read_only_first.rb | 16 ++++++++++++++-- .../lib/petstore/models/special_model_name.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/tag.rb | 16 ++++++++++++++-- ...e_freeform_additional_properties_request.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/user.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/whale.rb | 16 ++++++++++++++-- .../ruby-faraday/lib/petstore/models/zebra.rb | 16 ++++++++++++++-- .../models/additional_properties_class.rb | 16 ++++++++++++++-- .../petstore/models/all_of_with_single_ref.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/animal.rb | 16 ++++++++++++++-- .../lib/petstore/models/api_response.rb | 16 ++++++++++++++-- .../models/array_of_array_of_number_only.rb | 16 ++++++++++++++-- .../petstore/models/array_of_number_only.rb | 16 ++++++++++++++-- .../lib/petstore/models/array_test.rb | 16 ++++++++++++++-- .../lib/petstore/models/capitalization.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/cat.rb | 18 +++++++++++++++--- .../ruby-httpx/lib/petstore/models/category.rb | 16 ++++++++++++++-- .../lib/petstore/models/class_model.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/client.rb | 16 ++++++++++++++-- .../lib/petstore/models/deprecated_object.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/dog.rb | 18 +++++++++++++++--- .../lib/petstore/models/enum_arrays.rb | 16 ++++++++++++++-- .../lib/petstore/models/enum_test.rb | 16 ++++++++++++++-- .../models/fake_big_decimal_map200_response.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/file.rb | 16 ++++++++++++++-- .../petstore/models/file_schema_test_class.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/foo.rb | 16 ++++++++++++++-- .../models/foo_get_default_response.rb | 16 ++++++++++++++-- .../lib/petstore/models/format_test.rb | 16 ++++++++++++++-- .../lib/petstore/models/has_only_read_only.rb | 16 ++++++++++++++-- .../lib/petstore/models/health_check_result.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/list.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/map_test.rb | 16 ++++++++++++++-- ...operties_and_additional_properties_class.rb | 16 ++++++++++++++-- .../lib/petstore/models/model200_response.rb | 16 ++++++++++++++-- .../lib/petstore/models/model_return.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/name.rb | 16 ++++++++++++++-- .../lib/petstore/models/nullable_class.rb | 16 ++++++++++++++-- .../lib/petstore/models/number_only.rb | 16 ++++++++++++++-- .../models/object_with_deprecated_fields.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/order.rb | 16 ++++++++++++++-- .../lib/petstore/models/outer_composite.rb | 16 ++++++++++++++-- .../models/outer_object_with_enum_property.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/pet.rb | 16 ++++++++++++++-- .../petstore/models/property_name_mapping.rb | 16 ++++++++++++++-- .../lib/petstore/models/read_only_first.rb | 16 ++++++++++++++-- .../lib/petstore/models/special_model_name.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/tag.rb | 16 ++++++++++++++-- ...e_freeform_additional_properties_request.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/user.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/whale.rb | 16 ++++++++++++++-- .../ruby-httpx/lib/petstore/models/zebra.rb | 16 ++++++++++++++-- .../models/additional_properties_class.rb | 16 ++++++++++++++-- .../petstore/models/all_of_with_single_ref.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/animal.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/api_response.rb | 16 ++++++++++++++-- .../models/array_of_array_of_number_only.rb | 16 ++++++++++++++-- .../petstore/models/array_of_number_only.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/array_test.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/capitalization.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/cat.rb | 18 +++++++++++++++--- .../ruby/lib/petstore/models/category.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/class_model.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/client.rb | 16 ++++++++++++++-- .../lib/petstore/models/deprecated_object.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/dog.rb | 18 +++++++++++++++--- .../ruby/lib/petstore/models/enum_arrays.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/enum_test.rb | 16 ++++++++++++++-- .../models/fake_big_decimal_map200_response.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/file.rb | 16 ++++++++++++++-- .../petstore/models/file_schema_test_class.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/foo.rb | 16 ++++++++++++++-- .../models/foo_get_default_response.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/format_test.rb | 16 ++++++++++++++-- .../lib/petstore/models/has_only_read_only.rb | 16 ++++++++++++++-- .../lib/petstore/models/health_check_result.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/list.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/map_test.rb | 16 ++++++++++++++-- ...operties_and_additional_properties_class.rb | 16 ++++++++++++++-- .../lib/petstore/models/model200_response.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/model_return.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/name.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/nullable_class.rb | 16 ++++++++++++++-- .../ruby/lib/petstore/models/number_only.rb | 16 ++++++++++++++-- .../models/object_with_deprecated_fields.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/order.rb | 16 ++++++++++++++-- .../lib/petstore/models/outer_composite.rb | 16 ++++++++++++++-- .../models/outer_object_with_enum_property.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/pet.rb | 16 ++++++++++++++-- .../petstore/models/property_name_mapping.rb | 16 ++++++++++++++-- .../lib/petstore/models/read_only_first.rb | 16 ++++++++++++++-- .../lib/petstore/models/special_model_name.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/tag.rb | 16 ++++++++++++++-- ...e_freeform_additional_properties_request.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/user.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/whale.rb | 16 ++++++++++++++-- .../petstore/ruby/lib/petstore/models/zebra.rb | 16 ++++++++++++++-- .../lib/petstore/models/array_alias.rb | 18 +++++++++++++++--- .../lib/petstore/models/map_alias.rb | 16 ++++++++++++++-- 214 files changed, 3009 insertions(+), 441 deletions(-) diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb index bb79bf1c519b..5c06d4a230a3 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb index e558333825f2..201b204de6ad 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb index 9e9d8976d93b..c1c0364614a4 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb @@ -193,11 +193,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb index e21c0fdf6780..ca98373a804a 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb @@ -243,11 +243,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb index 9812f0016bd1..f66cea512b38 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb @@ -186,11 +186,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb index 79d5efdb517a..c376bf0ceafa 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb @@ -258,11 +258,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb index 7d9c34274f88..9666a9ebda5c 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb @@ -174,11 +174,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb index 99eea26aeabe..f1f55beb34bb 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 1649f2f0c722..92c3e02b7039 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 560b83ea4b27..98a08247498a 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -175,11 +175,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 39fb2fecfea5..20e6f18ef7cf 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb index bb79bf1c519b..5c06d4a230a3 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb index e558333825f2..201b204de6ad 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb index 9e9d8976d93b..c1c0364614a4 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb @@ -193,11 +193,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb index e21c0fdf6780..ca98373a804a 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb @@ -243,11 +243,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb index 9812f0016bd1..f66cea512b38 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb @@ -186,11 +186,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb index 79d5efdb517a..c376bf0ceafa 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb @@ -258,11 +258,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb index 7d9c34274f88..9666a9ebda5c 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb @@ -174,11 +174,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb index 99eea26aeabe..f1f55beb34bb 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 1649f2f0c722..92c3e02b7039 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 560b83ea4b27..98a08247498a 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -175,11 +175,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 39fb2fecfea5..20e6f18ef7cf 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb index bb79bf1c519b..5c06d4a230a3 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb index e558333825f2..201b204de6ad 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb index 9e9d8976d93b..c1c0364614a4 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb @@ -193,11 +193,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb index e21c0fdf6780..ca98373a804a 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb @@ -243,11 +243,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb index 9812f0016bd1..f66cea512b38 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb @@ -186,11 +186,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb index 79d5efdb517a..c376bf0ceafa 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb @@ -258,11 +258,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb index 7d9c34274f88..9666a9ebda5c 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb @@ -174,11 +174,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb index 99eea26aeabe..f1f55beb34bb 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 1649f2f0c722..92c3e02b7039 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 560b83ea4b27..98a08247498a 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -175,11 +175,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 39fb2fecfea5..20e6f18ef7cf 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb index 9ec03111fc38..60ebe12d65cf 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb @@ -153,11 +153,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb index 4581a7740eaa..80b4a578eef3 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb @@ -171,11 +171,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb index 37d09285f53e..ee8fef2fb481 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb @@ -173,11 +173,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb index a7c040fb8f5d..33febb1d3eba 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb index 3477ef02806a..b8436ac4c89e 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb index f86643782a55..2736eeff468a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb index 8f3e8d2bab13..ed20719d6f84 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb @@ -192,11 +192,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb index 7653d972a974..7d4d31eb882f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb @@ -186,11 +186,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb index ed13b482a4a1..bc750588d67c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb index f26dbd6e30e5..7e420381d63e 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb @@ -166,11 +166,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb index 6845a9c94be0..481f8144b373 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb @@ -172,11 +172,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb index bf5ff3216fd7..3ace64039703 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb index e95c80ae30f0..c643344bad7b 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb index 35cc19e2020a..af553a8c869f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb index d3099592a779..ed02954a2a26 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb index 9121236c907c..abb903b2daef 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb index f854cf6c7af0..16bd7e80014a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb @@ -285,11 +285,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb index ea6b6b7d9be7..512fdd9aed51 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb index f6d77577ae04..dd56c2b589d6 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb index d13bd9a9a493..e2631616bcaf 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb index f63d984207e9..6549b092de53 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb index c485789a41e9..7e93b506fb92 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb index f273072f54bb..12ba7d916daf 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb @@ -556,11 +556,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb index 44ee9a9df8e2..3b924711097f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb index f5fd688ef293..c391ca1c23e1 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb index 620ff57fc0a6..9102fe755627 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb index 1ab375d72b2c..dd2a25d6468b 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb @@ -197,11 +197,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 36f68fec8c4f..01b4ba0c2d57 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -160,11 +160,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb index 239cbaeeb4c6..c3a7a4623caf 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb index 2e582a7cbc0c..bfedaa2a20df 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb index 3c991b0571f1..29bbbdd9d4e3 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb index 34b7cb569a08..e50e1b07101a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb @@ -261,11 +261,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb index af432acc8b31..b6d42b0f3545 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb index e2c79d68dab1..dd0d09e2ff37 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb @@ -169,11 +169,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb index 820666bd80ab..136bd9bc3244 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb @@ -222,11 +222,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb index b7fa2c562eb6..f2aa2e83b76f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb index f956597c8601..1e0b442ea8d9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb @@ -179,11 +179,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb index cb6d37e97337..81bf1d5df2b9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb @@ -189,11 +189,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb index 5403a5b76bea..2c3df943e75f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb @@ -258,11 +258,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb index e99f2cb7934a..e8c200b816c0 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb index dd02780e4e61..76c253707d2d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb index b57fd9ff9941..e9f8a03fb31c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5f28f1cbd9f6..5347e0a738ce 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb index 61c2706b47de..5bd8b6c4d3e3 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb @@ -204,11 +204,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb index 9ec03111fc38..60ebe12d65cf 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb @@ -153,11 +153,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb index 4581a7740eaa..80b4a578eef3 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb @@ -171,11 +171,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb index 37d09285f53e..ee8fef2fb481 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb @@ -173,11 +173,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb index a7c040fb8f5d..33febb1d3eba 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb index 3477ef02806a..b8436ac4c89e 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb index f86643782a55..2736eeff468a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb index 8f3e8d2bab13..ed20719d6f84 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb @@ -192,11 +192,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb index 7653d972a974..7d4d31eb882f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb @@ -186,11 +186,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb index ed13b482a4a1..bc750588d67c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb index f26dbd6e30e5..7e420381d63e 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb @@ -166,11 +166,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb index bf5ff3216fd7..3ace64039703 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb index e95c80ae30f0..c643344bad7b 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb index 35cc19e2020a..af553a8c869f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb index d3099592a779..ed02954a2a26 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb index 9121236c907c..abb903b2daef 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb index f854cf6c7af0..16bd7e80014a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb @@ -285,11 +285,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb index ea6b6b7d9be7..512fdd9aed51 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb index f6d77577ae04..dd56c2b589d6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb index d13bd9a9a493..e2631616bcaf 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb index f63d984207e9..6549b092de53 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb index c485789a41e9..7e93b506fb92 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb index f273072f54bb..12ba7d916daf 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb @@ -556,11 +556,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb index 44ee9a9df8e2..3b924711097f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb index f5fd688ef293..c391ca1c23e1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb index 620ff57fc0a6..9102fe755627 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb index 1ab375d72b2c..dd2a25d6468b 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb @@ -197,11 +197,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 36f68fec8c4f..01b4ba0c2d57 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -160,11 +160,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb index 239cbaeeb4c6..c3a7a4623caf 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb index 2e582a7cbc0c..bfedaa2a20df 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb index 3c991b0571f1..29bbbdd9d4e3 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb index 34b7cb569a08..e50e1b07101a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb @@ -261,11 +261,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb index af432acc8b31..b6d42b0f3545 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb index e2c79d68dab1..dd0d09e2ff37 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb @@ -169,11 +169,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb index 820666bd80ab..136bd9bc3244 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb @@ -222,11 +222,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb index b7fa2c562eb6..f2aa2e83b76f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb index f956597c8601..1e0b442ea8d9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb @@ -179,11 +179,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb index 5403a5b76bea..2c3df943e75f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb @@ -258,11 +258,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb index 93b016d9ea66..8c73d0df58c8 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb @@ -167,11 +167,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb index e99f2cb7934a..e8c200b816c0 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb index dd02780e4e61..76c253707d2d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb index b57fd9ff9941..e9f8a03fb31c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5f28f1cbd9f6..5347e0a738ce 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb index 61c2706b47de..5bd8b6c4d3e3 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb @@ -204,11 +204,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb index 9060d440ef64..224432b93fb6 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb @@ -175,11 +175,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb index 673e36ec14c1..ad1f443d35db 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb @@ -200,11 +200,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb index 9ec03111fc38..60ebe12d65cf 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb @@ -153,11 +153,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb index 4581a7740eaa..80b4a578eef3 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb @@ -171,11 +171,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb index 37d09285f53e..ee8fef2fb481 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb @@ -173,11 +173,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb index a7c040fb8f5d..33febb1d3eba 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb index 3477ef02806a..b8436ac4c89e 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb index f86643782a55..2736eeff468a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb index 8f3e8d2bab13..ed20719d6f84 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb @@ -192,11 +192,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb index 7653d972a974..7d4d31eb882f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb @@ -186,11 +186,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb index ed13b482a4a1..bc750588d67c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb index f26dbd6e30e5..7e420381d63e 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb @@ -166,11 +166,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb index bf5ff3216fd7..3ace64039703 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb index e95c80ae30f0..c643344bad7b 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb index 35cc19e2020a..af553a8c869f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb index d3099592a779..ed02954a2a26 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb index 9121236c907c..abb903b2daef 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb index f854cf6c7af0..16bd7e80014a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb @@ -285,11 +285,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb index ea6b6b7d9be7..512fdd9aed51 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb index f6d77577ae04..dd56c2b589d6 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb index d13bd9a9a493..e2631616bcaf 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb index f63d984207e9..6549b092de53 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb index c485789a41e9..7e93b506fb92 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb index f273072f54bb..12ba7d916daf 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb @@ -556,11 +556,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb index 44ee9a9df8e2..3b924711097f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb index f5fd688ef293..c391ca1c23e1 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb index 620ff57fc0a6..9102fe755627 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb index 1ab375d72b2c..dd2a25d6468b 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb @@ -197,11 +197,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 36f68fec8c4f..01b4ba0c2d57 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -160,11 +160,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb index 239cbaeeb4c6..c3a7a4623caf 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb index 2e582a7cbc0c..bfedaa2a20df 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb index 3c991b0571f1..29bbbdd9d4e3 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb index 34b7cb569a08..e50e1b07101a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb @@ -261,11 +261,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb index af432acc8b31..b6d42b0f3545 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb index e2c79d68dab1..dd0d09e2ff37 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb @@ -169,11 +169,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb index 820666bd80ab..136bd9bc3244 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb @@ -222,11 +222,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb index b7fa2c562eb6..f2aa2e83b76f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb index f956597c8601..1e0b442ea8d9 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb @@ -179,11 +179,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb index 5403a5b76bea..2c3df943e75f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb @@ -258,11 +258,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb index 93b016d9ea66..8c73d0df58c8 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb @@ -167,11 +167,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb index e99f2cb7934a..e8c200b816c0 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb index dd02780e4e61..76c253707d2d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb index b57fd9ff9941..e9f8a03fb31c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5f28f1cbd9f6..5347e0a738ce 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb index 61c2706b47de..5bd8b6c4d3e3 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb @@ -204,11 +204,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb index 9060d440ef64..224432b93fb6 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb @@ -175,11 +175,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb index 673e36ec14c1..ad1f443d35db 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb @@ -200,11 +200,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 9ec03111fc38..60ebe12d65cf 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 @@ -153,11 +153,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb index 4581a7740eaa..80b4a578eef3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb @@ -171,11 +171,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 37d09285f53e..ee8fef2fb481 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -173,11 +173,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 a7c040fb8f5d..33febb1d3eba 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 3477ef02806a..b8436ac4c89e 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 @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 f86643782a55..2736eeff468a 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 @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 8f3e8d2bab13..ed20719d6f84 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -192,11 +192,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb index 7653d972a974..7d4d31eb882f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -186,11 +186,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index ed13b482a4a1..bc750588d67c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index f26dbd6e30e5..7e420381d63e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -166,11 +166,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 bf5ff3216fd7..3ace64039703 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index e95c80ae30f0..c643344bad7b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb index 35cc19e2020a..af553a8c869f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index d3099592a779..ed02954a2a26 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 9121236c907c..abb903b2daef 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 f854cf6c7af0..16bd7e80014a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -285,11 +285,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb index ea6b6b7d9be7..512fdd9aed51 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/file.rb b/samples/client/petstore/ruby/lib/petstore/models/file.rb index f6d77577ae04..dd56c2b589d6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 d13bd9a9a493..e2631616bcaf 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 @@ -151,11 +151,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/client/petstore/ruby/lib/petstore/models/foo.rb index f63d984207e9..6549b092de53 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb index c485789a41e9..7e93b506fb92 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 f273072f54bb..12ba7d916daf 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -556,11 +556,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 44ee9a9df8e2..3b924711097f 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 @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb index f5fd688ef293..c391ca1c23e1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb @@ -142,11 +142,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index 620ff57fc0a6..9102fe755627 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 1ab375d72b2c..dd2a25d6468b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -197,11 +197,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 36f68fec8c4f..01b4ba0c2d57 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 @@ -160,11 +160,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 239cbaeeb4c6..c3a7a4623caf 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -150,11 +150,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 2e582a7cbc0c..bfedaa2a20df 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -141,11 +141,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 3c991b0571f1..29bbbdd9d4e3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -185,11 +185,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb index 34b7cb569a08..e50e1b07101a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb @@ -261,11 +261,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 af432acc8b31..b6d42b0f3545 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb index e2c79d68dab1..dd0d09e2ff37 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb @@ -169,11 +169,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 820666bd80ab..136bd9bc3244 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -222,11 +222,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 b7fa2c562eb6..f2aa2e83b76f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -158,11 +158,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb index f956597c8601..1e0b442ea8d9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb @@ -179,11 +179,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 5403a5b76bea..2c3df943e75f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -258,11 +258,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb index 6ea182ad3c77..198467e34748 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb @@ -167,11 +167,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 e99f2cb7934a..e8c200b816c0 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 @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) 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 dd02780e4e61..76c253707d2d 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 @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index b57fd9ff9941..e9f8a03fb31c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -149,11 +149,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5f28f1cbd9f6..5347e0a738ce 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -140,11 +140,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index 61c2706b47de..5bd8b6c4d3e3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -204,11 +204,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/whale.rb b/samples/client/petstore/ruby/lib/petstore/models/whale.rb index 9060d440ef64..224432b93fb6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/whale.rb @@ -175,11 +175,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb index 673e36ec14c1..ad1f443d35db 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb @@ -200,11 +200,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb index 53a2c9652657..ce0a030346bb 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb @@ -134,11 +134,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - hash = super - self.class.attribute_map.each_pair do |attr, param| + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end + hash = {} + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb index 6dcd089635af..a388cc13fc70 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb @@ -131,11 +131,23 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash + # collect the attributes this model knows about, including the ones defined + # in its parent(s): attribute_map and openapi_nullable resolve to the child + # class in every ancestor frame, so the inherited super chain only repeated + # the child's own attributes and dropped the inherited ones + map = self.class.attribute_map + nullable = self.class.openapi_nullable + klass = self.class.superclass + while klass.respond_to?(:openapi_types) + map = klass.attribute_map.merge(map) + nullable = nullable | klass.openapi_nullable + klass = klass.superclass + end hash = {} - self.class.attribute_map.each_pair do |attr, param| + map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end From 69d6e25d6adc84ae26249d427123647047943498 Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Tue, 8 Sep 2026 11:33:20 +0200 Subject: [PATCH 5/6] [ruby] fix: ancestor nullability defers to a child's redeclaration, and Set loads Two findings from review: the merged-nullable union let a parent's nullable flag survive a child redeclaring the attribute as non-nullable - an ancestor's entry now only applies to attributes no nearer class declares - and the walk evaluates openapi_nullable eagerly for every to_hash call, so the generated models require 'set' explicitly instead of leaning on the Set builtin autoload rubies before 3.2 do not have. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz --- .../ruby-client/base_object.mustache | 3 +- .../main/resources/ruby-client/model.mustache | 1 + .../codegen/ruby/RubyClientCodegenTest.java | 6 +++- .../lib/openapi_client/models/bird.rb | 4 ++- .../lib/openapi_client/models/category.rb | 4 ++- .../lib/openapi_client/models/data_query.rb | 4 ++- .../openapi_client/models/default_value.rb | 4 ++- .../models/number_properties_only.rb | 4 ++- .../lib/openapi_client/models/pet.rb | 4 ++- .../lib/openapi_client/models/query.rb | 4 ++- .../openapi_client/models/string_enum_ref.rb | 1 + .../lib/openapi_client/models/tag.rb | 4 ++- ...st_form_object_multipart_request_marker.rb | 4 ++- ...ue_object_all_of_query_object_parameter.rb | 4 ++- ...rue_array_string_query_object_parameter.rb | 4 ++- .../lib/openapi_client/models/bird.rb | 4 ++- .../lib/openapi_client/models/category.rb | 4 ++- .../lib/openapi_client/models/data_query.rb | 4 ++- .../openapi_client/models/default_value.rb | 4 ++- .../models/number_properties_only.rb | 4 ++- .../lib/openapi_client/models/pet.rb | 4 ++- .../lib/openapi_client/models/query.rb | 4 ++- .../openapi_client/models/string_enum_ref.rb | 1 + .../lib/openapi_client/models/tag.rb | 4 ++- ...st_form_object_multipart_request_marker.rb | 4 ++- ...ue_object_all_of_query_object_parameter.rb | 4 ++- ...rue_array_string_query_object_parameter.rb | 4 ++- .../lib/openapi_client/models/bird.rb | 4 ++- .../lib/openapi_client/models/category.rb | 4 ++- .../lib/openapi_client/models/data_query.rb | 4 ++- .../openapi_client/models/default_value.rb | 4 ++- .../models/number_properties_only.rb | 4 ++- .../lib/openapi_client/models/pet.rb | 4 ++- .../lib/openapi_client/models/query.rb | 4 ++- .../openapi_client/models/string_enum_ref.rb | 1 + .../lib/openapi_client/models/tag.rb | 4 ++- ...st_form_object_multipart_request_marker.rb | 4 ++- ...ue_object_all_of_query_object_parameter.rb | 4 ++- ...rue_array_string_query_object_parameter.rb | 4 ++- .../models/additional_properties_class.rb | 4 ++- .../petstore/models/all_of_with_single_ref.rb | 4 ++- .../lib/petstore/models/animal.rb | 4 ++- .../lib/petstore/models/api_response.rb | 4 ++- .../models/array_of_array_of_number_only.rb | 4 ++- .../petstore/models/array_of_number_only.rb | 4 ++- .../lib/petstore/models/array_test.rb | 4 ++- .../lib/petstore/models/capitalization.rb | 4 ++- .../ruby-autoload/lib/petstore/models/cat.rb | 4 ++- .../lib/petstore/models/category.rb | 4 ++- .../petstore/models/child_with_nullable.rb | 4 ++- .../lib/petstore/models/class_model.rb | 4 ++- .../lib/petstore/models/client.rb | 4 ++- .../lib/petstore/models/deprecated_object.rb | 4 ++- .../ruby-autoload/lib/petstore/models/dog.rb | 4 ++- .../lib/petstore/models/enum_arrays.rb | 4 ++- .../lib/petstore/models/enum_class.rb | 1 + .../lib/petstore/models/enum_test.rb | 4 ++- .../fake_big_decimal_map200_response.rb | 4 ++- .../ruby-autoload/lib/petstore/models/file.rb | 4 ++- .../petstore/models/file_schema_test_class.rb | 4 ++- .../ruby-autoload/lib/petstore/models/foo.rb | 4 ++- .../models/foo_get_default_response.rb | 4 ++- .../lib/petstore/models/format_test.rb | 4 ++- .../lib/petstore/models/has_only_read_only.rb | 4 ++- .../petstore/models/health_check_result.rb | 4 ++- .../ruby-autoload/lib/petstore/models/list.rb | 4 ++- .../lib/petstore/models/map_test.rb | 4 ++- ...perties_and_additional_properties_class.rb | 4 ++- .../lib/petstore/models/model200_response.rb | 4 ++- .../lib/petstore/models/model_return.rb | 4 ++- .../ruby-autoload/lib/petstore/models/name.rb | 4 ++- .../lib/petstore/models/nullable_class.rb | 4 ++- .../lib/petstore/models/number_only.rb | 4 ++- .../models/object_with_deprecated_fields.rb | 4 ++- .../lib/petstore/models/order.rb | 4 ++- .../lib/petstore/models/outer_composite.rb | 4 ++- .../lib/petstore/models/outer_enum.rb | 1 + .../models/outer_enum_default_value.rb | 1 + .../lib/petstore/models/outer_enum_integer.rb | 1 + .../outer_enum_integer_default_value.rb | 1 + .../models/outer_object_with_enum_property.rb | 4 ++- .../petstore/models/parent_with_nullable.rb | 4 ++- .../ruby-autoload/lib/petstore/models/pet.rb | 4 ++- .../lib/petstore/models/read_only_first.rb | 4 ++- .../lib/petstore/models/single_ref_type.rb | 1 + .../lib/petstore/models/special_model_name.rb | 4 ++- .../ruby-autoload/lib/petstore/models/tag.rb | 4 ++- ..._freeform_additional_properties_request.rb | 4 ++- .../ruby-autoload/lib/petstore/models/user.rb | 4 ++- .../models/additional_properties_class.rb | 4 ++- .../petstore/models/all_of_with_single_ref.rb | 4 ++- .../lib/petstore/models/animal.rb | 4 ++- .../lib/petstore/models/api_response.rb | 4 ++- .../models/array_of_array_of_number_only.rb | 4 ++- .../petstore/models/array_of_number_only.rb | 4 ++- .../lib/petstore/models/array_test.rb | 4 ++- .../lib/petstore/models/capitalization.rb | 4 ++- .../ruby-faraday/lib/petstore/models/cat.rb | 4 ++- .../lib/petstore/models/category.rb | 4 ++- .../lib/petstore/models/class_model.rb | 4 ++- .../lib/petstore/models/client.rb | 4 ++- .../ruby-faraday/lib/petstore/models/cow.rb | 1 + .../lib/petstore/models/deprecated_object.rb | 4 ++- .../ruby-faraday/lib/petstore/models/dog.rb | 4 ++- .../lib/petstore/models/enum_arrays.rb | 4 ++- .../lib/petstore/models/enum_class.rb | 1 + .../lib/petstore/models/enum_test.rb | 4 ++- .../fake_big_decimal_map200_response.rb | 4 ++- .../ruby-faraday/lib/petstore/models/file.rb | 4 ++- .../petstore/models/file_schema_test_class.rb | 4 ++- .../ruby-faraday/lib/petstore/models/foo.rb | 4 ++- .../models/foo_get_default_response.rb | 4 ++- .../lib/petstore/models/format_test.rb | 4 ++- .../lib/petstore/models/has_only_read_only.rb | 4 ++- .../petstore/models/health_check_result.rb | 4 ++- .../ruby-faraday/lib/petstore/models/list.rb | 4 ++- .../lib/petstore/models/mammal.rb | 1 + .../lib/petstore/models/mammal_anyof.rb | 1 + .../models/mammal_without_discriminator.rb | 1 + .../lib/petstore/models/map_test.rb | 4 ++- ...perties_and_additional_properties_class.rb | 4 ++- .../lib/petstore/models/model200_response.rb | 4 ++- .../lib/petstore/models/model_return.rb | 4 ++- .../ruby-faraday/lib/petstore/models/name.rb | 4 ++- .../lib/petstore/models/nullable_class.rb | 4 ++- .../lib/petstore/models/number_only.rb | 4 ++- .../models/object_with_deprecated_fields.rb | 4 ++- .../petstore/models/one_of_primitive_types.rb | 1 + .../ruby-faraday/lib/petstore/models/order.rb | 4 ++- .../lib/petstore/models/outer_composite.rb | 4 ++- .../lib/petstore/models/outer_enum.rb | 1 + .../models/outer_enum_default_value.rb | 1 + .../lib/petstore/models/outer_enum_integer.rb | 1 + .../outer_enum_integer_default_value.rb | 1 + .../models/outer_object_with_enum_property.rb | 4 ++- .../ruby-faraday/lib/petstore/models/pet.rb | 4 ++- .../petstore/models/property_name_mapping.rb | 4 ++- .../lib/petstore/models/read_only_first.rb | 4 ++- .../lib/petstore/models/single_ref_type.rb | 1 + .../lib/petstore/models/special_model_name.rb | 4 ++- .../ruby-faraday/lib/petstore/models/tag.rb | 4 ++- ..._freeform_additional_properties_request.rb | 4 ++- .../ruby-faraday/lib/petstore/models/user.rb | 4 ++- .../ruby-faraday/lib/petstore/models/whale.rb | 4 ++- .../ruby-faraday/lib/petstore/models/zebra.rb | 4 ++- .../spec/custom/base_object_spec.rb | 30 +++++++++++++++++++ .../models/additional_properties_class.rb | 4 ++- .../petstore/models/all_of_with_single_ref.rb | 4 ++- .../ruby-httpx/lib/petstore/models/animal.rb | 4 ++- .../lib/petstore/models/api_response.rb | 4 ++- .../models/array_of_array_of_number_only.rb | 4 ++- .../petstore/models/array_of_number_only.rb | 4 ++- .../lib/petstore/models/array_test.rb | 4 ++- .../lib/petstore/models/capitalization.rb | 4 ++- .../ruby-httpx/lib/petstore/models/cat.rb | 4 ++- .../lib/petstore/models/category.rb | 4 ++- .../lib/petstore/models/class_model.rb | 4 ++- .../ruby-httpx/lib/petstore/models/client.rb | 4 ++- .../ruby-httpx/lib/petstore/models/cow.rb | 1 + .../lib/petstore/models/deprecated_object.rb | 4 ++- .../ruby-httpx/lib/petstore/models/dog.rb | 4 ++- .../lib/petstore/models/enum_arrays.rb | 4 ++- .../lib/petstore/models/enum_class.rb | 1 + .../lib/petstore/models/enum_test.rb | 4 ++- .../fake_big_decimal_map200_response.rb | 4 ++- .../ruby-httpx/lib/petstore/models/file.rb | 4 ++- .../petstore/models/file_schema_test_class.rb | 4 ++- .../ruby-httpx/lib/petstore/models/foo.rb | 4 ++- .../models/foo_get_default_response.rb | 4 ++- .../lib/petstore/models/format_test.rb | 4 ++- .../lib/petstore/models/has_only_read_only.rb | 4 ++- .../petstore/models/health_check_result.rb | 4 ++- .../ruby-httpx/lib/petstore/models/list.rb | 4 ++- .../ruby-httpx/lib/petstore/models/mammal.rb | 1 + .../lib/petstore/models/mammal_anyof.rb | 1 + .../models/mammal_without_discriminator.rb | 1 + .../lib/petstore/models/map_test.rb | 4 ++- ...perties_and_additional_properties_class.rb | 4 ++- .../lib/petstore/models/model200_response.rb | 4 ++- .../lib/petstore/models/model_return.rb | 4 ++- .../ruby-httpx/lib/petstore/models/name.rb | 4 ++- .../lib/petstore/models/nullable_class.rb | 4 ++- .../lib/petstore/models/number_only.rb | 4 ++- .../models/object_with_deprecated_fields.rb | 4 ++- .../petstore/models/one_of_primitive_types.rb | 1 + .../ruby-httpx/lib/petstore/models/order.rb | 4 ++- .../lib/petstore/models/outer_composite.rb | 4 ++- .../lib/petstore/models/outer_enum.rb | 1 + .../models/outer_enum_default_value.rb | 1 + .../lib/petstore/models/outer_enum_integer.rb | 1 + .../outer_enum_integer_default_value.rb | 1 + .../models/outer_object_with_enum_property.rb | 4 ++- .../ruby-httpx/lib/petstore/models/pet.rb | 4 ++- .../petstore/models/property_name_mapping.rb | 4 ++- .../lib/petstore/models/read_only_first.rb | 4 ++- .../lib/petstore/models/single_ref_type.rb | 1 + .../lib/petstore/models/special_model_name.rb | 4 ++- .../ruby-httpx/lib/petstore/models/tag.rb | 4 ++- ..._freeform_additional_properties_request.rb | 4 ++- .../ruby-httpx/lib/petstore/models/user.rb | 4 ++- .../ruby-httpx/lib/petstore/models/whale.rb | 4 ++- .../ruby-httpx/lib/petstore/models/zebra.rb | 4 ++- .../spec/custom/base_object_spec.rb | 30 +++++++++++++++++++ .../models/additional_properties_class.rb | 4 ++- .../petstore/models/all_of_with_single_ref.rb | 4 ++- .../ruby/lib/petstore/models/animal.rb | 4 ++- .../ruby/lib/petstore/models/api_response.rb | 4 ++- .../models/array_of_array_of_number_only.rb | 4 ++- .../petstore/models/array_of_number_only.rb | 4 ++- .../ruby/lib/petstore/models/array_test.rb | 4 ++- .../lib/petstore/models/capitalization.rb | 4 ++- .../petstore/ruby/lib/petstore/models/cat.rb | 4 ++- .../ruby/lib/petstore/models/category.rb | 4 ++- .../ruby/lib/petstore/models/class_model.rb | 4 ++- .../ruby/lib/petstore/models/client.rb | 4 ++- .../petstore/ruby/lib/petstore/models/cow.rb | 1 + .../lib/petstore/models/deprecated_object.rb | 4 ++- .../petstore/ruby/lib/petstore/models/dog.rb | 4 ++- .../ruby/lib/petstore/models/enum_arrays.rb | 4 ++- .../ruby/lib/petstore/models/enum_class.rb | 1 + .../ruby/lib/petstore/models/enum_test.rb | 4 ++- .../fake_big_decimal_map200_response.rb | 4 ++- .../petstore/ruby/lib/petstore/models/file.rb | 4 ++- .../petstore/models/file_schema_test_class.rb | 4 ++- .../petstore/ruby/lib/petstore/models/foo.rb | 4 ++- .../models/foo_get_default_response.rb | 4 ++- .../ruby/lib/petstore/models/format_test.rb | 4 ++- .../lib/petstore/models/has_only_read_only.rb | 4 ++- .../petstore/models/health_check_result.rb | 4 ++- .../petstore/ruby/lib/petstore/models/list.rb | 4 ++- .../ruby/lib/petstore/models/mammal.rb | 1 + .../ruby/lib/petstore/models/mammal_anyof.rb | 1 + .../models/mammal_without_discriminator.rb | 1 + .../ruby/lib/petstore/models/map_test.rb | 4 ++- ...perties_and_additional_properties_class.rb | 4 ++- .../lib/petstore/models/model200_response.rb | 4 ++- .../ruby/lib/petstore/models/model_return.rb | 4 ++- .../petstore/ruby/lib/petstore/models/name.rb | 4 ++- .../lib/petstore/models/nullable_class.rb | 4 ++- .../ruby/lib/petstore/models/number_only.rb | 4 ++- .../models/object_with_deprecated_fields.rb | 4 ++- .../petstore/models/one_of_primitive_types.rb | 1 + .../ruby/lib/petstore/models/order.rb | 4 ++- .../lib/petstore/models/outer_composite.rb | 4 ++- .../ruby/lib/petstore/models/outer_enum.rb | 1 + .../models/outer_enum_default_value.rb | 1 + .../lib/petstore/models/outer_enum_integer.rb | 1 + .../outer_enum_integer_default_value.rb | 1 + .../models/outer_object_with_enum_property.rb | 4 ++- .../petstore/ruby/lib/petstore/models/pet.rb | 4 ++- .../petstore/models/property_name_mapping.rb | 4 ++- .../lib/petstore/models/read_only_first.rb | 4 ++- .../lib/petstore/models/single_ref_type.rb | 1 + .../lib/petstore/models/special_model_name.rb | 4 ++- .../petstore/ruby/lib/petstore/models/tag.rb | 4 ++- ..._freeform_additional_properties_request.rb | 4 ++- .../petstore/ruby/lib/petstore/models/user.rb | 4 ++- .../ruby/lib/petstore/models/whale.rb | 4 ++- .../ruby/lib/petstore/models/zebra.rb | 4 ++- .../ruby/spec/custom/base_object_spec.rb | 30 +++++++++++++++++++ .../lib/petstore/models/array_alias.rb | 4 ++- .../lib/petstore/models/map_alias.rb | 4 ++- 262 files changed, 782 insertions(+), 216 deletions(-) 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 4fb5acc89423..f25a512b5a7a 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 @@ -43,8 +43,9 @@ nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/modules/openapi-generator/src/main/resources/ruby-client/model.mustache b/modules/openapi-generator/src/main/resources/ruby-client/model.mustache index 723dba82ffd4..fe71e76ca394 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/model.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/model.mustache @@ -4,6 +4,7 @@ =end require 'date' +require 'set' require 'time' module {{moduleName}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index a04b88269764..9ab274fd3eda 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -799,9 +799,13 @@ public void testBuildFromHashMapsInheritedAttributes() throws Exception { " nullable = self.class.openapi_nullable\n" + " klass = self.class.superclass\n" + " while klass.respond_to?(:openapi_types)\n" + + " # an ancestor's nullability only applies to attributes no nearer class redeclares\n" + + " nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys)\n" + " map = klass.attribute_map.merge(map)\n" + - " nullable = nullable | klass.openapi_nullable\n" + " klass = klass.superclass\n" + " end"); + // the walk evaluates openapi_nullable eagerly, so Set must be loaded on rubies + // where it is not yet a builtin autoload + TestUtils.assertFileContains(lizard, "require 'set'"); } } diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb index 5c06d4a230a3..8cda283934e8 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb index 201b204de6ad..28f1164e3cc3 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb index c1c0364614a4..62f7dfffd244 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -201,8 +202,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb index ca98373a804a..fcdc5d3f1025 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -251,8 +252,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb index f66cea512b38..3994598e1e81 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -194,8 +195,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb index c376bf0ceafa..1e42b815e93d 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -266,8 +267,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb index 9666a9ebda5c..501661567c64 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -182,8 +183,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb index 0777b5e07042..4a9ae3054ded 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb index f1f55beb34bb..d3b27cae66ef 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 92c3e02b7039..2bc861a89940 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 98a08247498a..58afc507821d 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -183,8 +184,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 20e6f18ef7cf..0845d0de0469 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb index 5c06d4a230a3..8cda283934e8 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb index 201b204de6ad..28f1164e3cc3 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb index c1c0364614a4..62f7dfffd244 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -201,8 +202,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb index ca98373a804a..fcdc5d3f1025 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -251,8 +252,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb index f66cea512b38..3994598e1e81 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -194,8 +195,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb index c376bf0ceafa..1e42b815e93d 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -266,8 +267,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb index 9666a9ebda5c..501661567c64 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -182,8 +183,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb index 0777b5e07042..4a9ae3054ded 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb index f1f55beb34bb..d3b27cae66ef 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 92c3e02b7039..2bc861a89940 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 98a08247498a..58afc507821d 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -183,8 +184,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 20e6f18ef7cf..0845d0de0469 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb index 5c06d4a230a3..8cda283934e8 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb index 201b204de6ad..28f1164e3cc3 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb index c1c0364614a4..62f7dfffd244 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -201,8 +202,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb index ca98373a804a..fcdc5d3f1025 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -251,8 +252,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb index f66cea512b38..3994598e1e81 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -194,8 +195,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb index c376bf0ceafa..1e42b815e93d 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -266,8 +267,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb index 9666a9ebda5c..501661567c64 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -182,8 +183,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb index 0777b5e07042..4a9ae3054ded 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb index f1f55beb34bb..d3b27cae66ef 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 92c3e02b7039..2bc861a89940 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 98a08247498a..58afc507821d 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -183,8 +184,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 20e6f18ef7cf..0845d0de0469 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module OpenapiClient @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb index 60ebe12d65cf..318e5b5bd6e4 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -161,8 +162,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb index 80b4a578eef3..c9cf74e48eb9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -179,8 +180,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb index ee8fef2fb481..f16064590127 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -181,8 +182,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb index 33febb1d3eba..2b8f6f3da716 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb index b8436ac4c89e..61ec9a339f8a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb index 2736eeff468a..25936c36112d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb index ed20719d6f84..4250f94d5602 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -200,8 +201,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb index 7d4d31eb882f..980b6d4f6fdf 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -194,8 +195,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb index bc750588d67c..ccf06cb566c7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb index 7e420381d63e..1e13601082aa 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -174,8 +175,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb index 481f8144b373..43b774c168d7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -180,8 +181,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb index 3ace64039703..368596110da9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb index c643344bad7b..2c8707232d25 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb index af553a8c869f..b5cfe6462091 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb index ed02954a2a26..2acab0f70063 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb index abb903b2daef..0dc6e78adaf5 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb index 54bffd17d38c..a62e4022056d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb index 16bd7e80014a..b9bd10e9f232 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -293,8 +294,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb index 512fdd9aed51..2b15275e0af8 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb index dd56c2b589d6..e16db98d6d8e 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb index e2631616bcaf..b8c3a85378e7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb index 6549b092de53..4912ef30b029 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb index 7e93b506fb92..9994654f38d4 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb index 12ba7d916daf..b22f471e3367 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -564,8 +565,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb index 3b924711097f..e12981d112e4 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb index c391ca1c23e1..5ee62c4fc45e 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb index 9102fe755627..ffbc3b957a30 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb index dd2a25d6468b..acb0dc9c82d4 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -205,8 +206,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 01b4ba0c2d57..36969d7426cb 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -168,8 +169,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb index c3a7a4623caf..72b7d2292c99 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb index bfedaa2a20df..61b38f1c7145 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb index 29bbbdd9d4e3..be828a1f316f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb index e50e1b07101a..09c9ce983a33 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -269,8 +270,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb index b6d42b0f3545..f16ccf580bb9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb index dd0d09e2ff37..5b49ba4d887a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -177,8 +178,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb index 136bd9bc3244..e780b4a33e07 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -230,8 +231,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb index f2aa2e83b76f..3fa7f5c7f2d7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb index acd2130a7b3f..553a17fc7baa 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb index 0dd059474528..22218ed7dc56 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb index d3288d09b952..272c02c4b297 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb index 147293ad274c..ba0177c87428 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb index 1e0b442ea8d9..4aff91a0894b 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -187,8 +188,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb index 81bf1d5df2b9..3c0654c4a6eb 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -197,8 +198,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb index 2c3df943e75f..c6157317e624 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -266,8 +267,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb index e8c200b816c0..b3453085466d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb index 3f09a14e0cbb..935576e416a8 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb index 76c253707d2d..956b8d95ca63 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb index e9f8a03fb31c..dac93098e66f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5347e0a738ce..857d0a9ebd3c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb index 5bd8b6c4d3e3..a4e13e3f82dd 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -212,8 +213,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb index 60ebe12d65cf..318e5b5bd6e4 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -161,8 +162,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb index 80b4a578eef3..c9cf74e48eb9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -179,8 +180,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb index ee8fef2fb481..f16064590127 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -181,8 +182,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb index 33febb1d3eba..2b8f6f3da716 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb index b8436ac4c89e..61ec9a339f8a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb index 2736eeff468a..25936c36112d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb index ed20719d6f84..4250f94d5602 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -200,8 +201,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb index 7d4d31eb882f..980b6d4f6fdf 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -194,8 +195,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb index bc750588d67c..ccf06cb566c7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb index 7e420381d63e..1e13601082aa 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -174,8 +175,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb index 3ace64039703..368596110da9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb index c643344bad7b..2c8707232d25 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb index b100c2538a23..5ed3c0951421 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb index af553a8c869f..b5cfe6462091 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb index ed02954a2a26..2acab0f70063 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb index abb903b2daef..0dc6e78adaf5 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb index 54bffd17d38c..a62e4022056d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb index 16bd7e80014a..b9bd10e9f232 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -293,8 +294,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb index 512fdd9aed51..2b15275e0af8 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb index dd56c2b589d6..e16db98d6d8e 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb index e2631616bcaf..b8c3a85378e7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb index 6549b092de53..4912ef30b029 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb index 7e93b506fb92..9994654f38d4 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb index 12ba7d916daf..b22f471e3367 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -564,8 +565,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb index 3b924711097f..e12981d112e4 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb index c391ca1c23e1..5ee62c4fc45e 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb index 9102fe755627..ffbc3b957a30 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb index 91c5a53ffdcd..9150806f1c9f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb index 36e88a462640..1e1b125ad925 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb index 11556be23523..200f1d743785 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb index dd2a25d6468b..acb0dc9c82d4 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -205,8 +206,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 01b4ba0c2d57..36969d7426cb 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -168,8 +169,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb index c3a7a4623caf..72b7d2292c99 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb index bfedaa2a20df..61b38f1c7145 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb index 29bbbdd9d4e3..be828a1f316f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb index e50e1b07101a..09c9ce983a33 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -269,8 +270,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb index b6d42b0f3545..f16ccf580bb9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb index dd0d09e2ff37..5b49ba4d887a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -177,8 +178,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb index 68d2585262a4..e15b48634c65 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb index 136bd9bc3244..e780b4a33e07 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -230,8 +231,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb index f2aa2e83b76f..3fa7f5c7f2d7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb index acd2130a7b3f..553a17fc7baa 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb index 0dd059474528..22218ed7dc56 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb index c39ede502d25..e01f8df22f36 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb index 147293ad274c..ba0177c87428 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb index 1e0b442ea8d9..4aff91a0894b 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -187,8 +188,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb index 2c3df943e75f..c6157317e624 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -266,8 +267,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb index 8c73d0df58c8..3456b9510d0f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -175,8 +176,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb index e8c200b816c0..b3453085466d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb index 3f09a14e0cbb..935576e416a8 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb index 76c253707d2d..956b8d95ca63 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb index e9f8a03fb31c..dac93098e66f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5347e0a738ce..857d0a9ebd3c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb index 5bd8b6c4d3e3..a4e13e3f82dd 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -212,8 +213,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb index 224432b93fb6..b2de797c8a39 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -183,8 +184,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb index ad1f443d35db..6d766c38164b 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -208,8 +209,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb index cca4f2cd1419..de5c1890f244 100644 --- a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb @@ -182,5 +182,35 @@ def initialize(attributes = {}) expect(cat.to_hash).to eq({ className: 'Cat', color: 'black', declawed: true }) end + + it 'a child redeclaring an attribute as non-nullable wins over the ancestor nullability' do + parent = Class.new(Petstore::Animal) do + def self.attribute_map + { :flag => :flag } + end + + def self.openapi_types + { :flag => :'String' } + end + + def self.openapi_nullable + Set.new([:flag]) + end + attr_accessor :flag + end + child = Class.new(parent) do + def self.openapi_nullable + Set.new([]) + end + end + + nullable_instance = parent.allocate + nullable_instance.instance_variable_set(:@flag, nil) + expect(nullable_instance.to_hash).to eq({ flag: nil }) + + non_nullable_instance = child.allocate + non_nullable_instance.instance_variable_set(:@flag, nil) + expect(non_nullable_instance.to_hash).not_to have_key(:flag) + end end end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb index 60ebe12d65cf..318e5b5bd6e4 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -161,8 +162,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb index 80b4a578eef3..c9cf74e48eb9 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -179,8 +180,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb index ee8fef2fb481..f16064590127 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -181,8 +182,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb index 33febb1d3eba..2b8f6f3da716 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb index b8436ac4c89e..61ec9a339f8a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb index 2736eeff468a..25936c36112d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb index ed20719d6f84..4250f94d5602 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -200,8 +201,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb index 7d4d31eb882f..980b6d4f6fdf 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -194,8 +195,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb index bc750588d67c..ccf06cb566c7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb index 7e420381d63e..1e13601082aa 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -174,8 +175,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb index 3ace64039703..368596110da9 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb index c643344bad7b..2c8707232d25 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb index b100c2538a23..5ed3c0951421 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb index af553a8c869f..b5cfe6462091 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb index ed02954a2a26..2acab0f70063 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb index abb903b2daef..0dc6e78adaf5 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb index 54bffd17d38c..a62e4022056d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb index 16bd7e80014a..b9bd10e9f232 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -293,8 +294,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb index 512fdd9aed51..2b15275e0af8 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb index dd56c2b589d6..e16db98d6d8e 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb index e2631616bcaf..b8c3a85378e7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb index 6549b092de53..4912ef30b029 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb index 7e93b506fb92..9994654f38d4 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb index 12ba7d916daf..b22f471e3367 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -564,8 +565,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb index 3b924711097f..e12981d112e4 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb index c391ca1c23e1..5ee62c4fc45e 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb index 9102fe755627..ffbc3b957a30 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb index 91c5a53ffdcd..9150806f1c9f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb index 36e88a462640..1e1b125ad925 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb index 11556be23523..200f1d743785 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb index dd2a25d6468b..acb0dc9c82d4 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -205,8 +206,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 01b4ba0c2d57..36969d7426cb 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -168,8 +169,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb index c3a7a4623caf..72b7d2292c99 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb index bfedaa2a20df..61b38f1c7145 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb index 29bbbdd9d4e3..be828a1f316f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb index e50e1b07101a..09c9ce983a33 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -269,8 +270,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb index b6d42b0f3545..f16ccf580bb9 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb index dd0d09e2ff37..5b49ba4d887a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -177,8 +178,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb index 68d2585262a4..e15b48634c65 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb index 136bd9bc3244..e780b4a33e07 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -230,8 +231,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb index f2aa2e83b76f..3fa7f5c7f2d7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb index acd2130a7b3f..553a17fc7baa 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb index 0dd059474528..22218ed7dc56 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb index c39ede502d25..e01f8df22f36 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb index 147293ad274c..ba0177c87428 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb index 1e0b442ea8d9..4aff91a0894b 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -187,8 +188,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb index 2c3df943e75f..c6157317e624 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -266,8 +267,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb index 8c73d0df58c8..3456b9510d0f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -175,8 +176,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb index e8c200b816c0..b3453085466d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb index 3f09a14e0cbb..935576e416a8 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb index 76c253707d2d..956b8d95ca63 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb index e9f8a03fb31c..dac93098e66f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5347e0a738ce..857d0a9ebd3c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb index 5bd8b6c4d3e3..a4e13e3f82dd 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -212,8 +213,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb index 224432b93fb6..b2de797c8a39 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -183,8 +184,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb index ad1f443d35db..6d766c38164b 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -208,8 +209,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb index cca4f2cd1419..de5c1890f244 100644 --- a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb @@ -182,5 +182,35 @@ def initialize(attributes = {}) expect(cat.to_hash).to eq({ className: 'Cat', color: 'black', declawed: true }) end + + it 'a child redeclaring an attribute as non-nullable wins over the ancestor nullability' do + parent = Class.new(Petstore::Animal) do + def self.attribute_map + { :flag => :flag } + end + + def self.openapi_types + { :flag => :'String' } + end + + def self.openapi_nullable + Set.new([:flag]) + end + attr_accessor :flag + end + child = Class.new(parent) do + def self.openapi_nullable + Set.new([]) + end + end + + nullable_instance = parent.allocate + nullable_instance.instance_variable_set(:@flag, nil) + expect(nullable_instance.to_hash).to eq({ flag: nil }) + + non_nullable_instance = child.allocate + non_nullable_instance.instance_variable_set(:@flag, nil) + expect(non_nullable_instance.to_hash).not_to have_key(:flag) + end 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 60ebe12d65cf..318e5b5bd6e4 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -161,8 +162,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb index 80b4a578eef3..c9cf74e48eb9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -179,8 +180,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index ee8fef2fb481..f16064590127 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -181,8 +182,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 33febb1d3eba..2b8f6f3da716 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 b8436ac4c89e..61ec9a339f8a 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 2736eeff468a..25936c36112d 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 ed20719d6f84..4250f94d5602 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -200,8 +201,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb index 7d4d31eb882f..980b6d4f6fdf 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -194,8 +195,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index bc750588d67c..ccf06cb566c7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 7e420381d63e..1e13601082aa 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -174,8 +175,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 3ace64039703..368596110da9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index c643344bad7b..2c8707232d25 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/cow.rb b/samples/client/petstore/ruby/lib/petstore/models/cow.rb index b100c2538a23..5ed3c0951421 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cow.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cow.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb index af553a8c869f..b5cfe6462091 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index ed02954a2a26..2acab0f70063 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 abb903b2daef..0dc6e78adaf5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 54bffd17d38c..a62e4022056d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore 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 16bd7e80014a..b9bd10e9f232 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -293,8 +294,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb index 512fdd9aed51..2b15275e0af8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/file.rb b/samples/client/petstore/ruby/lib/petstore/models/file.rb index dd56c2b589d6..e16db98d6d8e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 e2631616bcaf..b8c3a85378e7 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -159,8 +160,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/client/petstore/ruby/lib/petstore/models/foo.rb index 6549b092de53..4912ef30b029 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb index 7e93b506fb92..9994654f38d4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 12ba7d916daf..b22f471e3367 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -564,8 +565,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 3b924711097f..e12981d112e4 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb index c391ca1c23e1..5ee62c4fc45e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -150,8 +151,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index 9102fe755627..ffbc3b957a30 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/mammal.rb b/samples/client/petstore/ruby/lib/petstore/models/mammal.rb index 91c5a53ffdcd..9150806f1c9f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mammal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mammal.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb b/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb index 36e88a462640..1e1b125ad925 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb b/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb index 11556be23523..200f1d743785 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore 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 dd2a25d6468b..acb0dc9c82d4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -205,8 +206,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 01b4ba0c2d57..36969d7426cb 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -168,8 +169,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 c3a7a4623caf..72b7d2292c99 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -158,8 +159,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 bfedaa2a20df..61b38f1c7145 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -149,8 +150,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 29bbbdd9d4e3..be828a1f316f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -193,8 +194,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb index e50e1b07101a..09c9ce983a33 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -269,8 +270,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 b6d42b0f3545..f16ccf580bb9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb index dd0d09e2ff37..5b49ba4d887a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -177,8 +178,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb b/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb index 68d2585262a4..e15b48634c65 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 136bd9bc3244..e780b4a33e07 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -230,8 +231,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 f2aa2e83b76f..3fa7f5c7f2d7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -166,8 +167,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 2a28686b572a..a57a48e52b93 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb index 97ef2fbb547c..a0d4ef9c80f9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb index c39ede502d25..e01f8df22f36 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb index 147293ad274c..ba0177c87428 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb index 1e0b442ea8d9..4aff91a0894b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -187,8 +188,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 2c3df943e75f..c6157317e624 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -266,8 +267,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb index 198467e34748..57b0bdc57fcc 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -175,8 +176,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} 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 e8c200b816c0..b3453085466d 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb index 3f09a14e0cbb..935576e416a8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore 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 76c253707d2d..956b8d95ca63 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 @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index e9f8a03fb31c..dac93098e66f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -157,8 +158,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 5347e0a738ce..857d0a9ebd3c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -148,8 +149,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index 5bd8b6c4d3e3..a4e13e3f82dd 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -212,8 +213,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/whale.rb b/samples/client/petstore/ruby/lib/petstore/models/whale.rb index 224432b93fb6..b2de797c8a39 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/whale.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -183,8 +184,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb index ad1f443d35db..6d766c38164b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -208,8 +209,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb index cca4f2cd1419..de5c1890f244 100644 --- a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb @@ -182,5 +182,35 @@ def initialize(attributes = {}) expect(cat.to_hash).to eq({ className: 'Cat', color: 'black', declawed: true }) end + + it 'a child redeclaring an attribute as non-nullable wins over the ancestor nullability' do + parent = Class.new(Petstore::Animal) do + def self.attribute_map + { :flag => :flag } + end + + def self.openapi_types + { :flag => :'String' } + end + + def self.openapi_nullable + Set.new([:flag]) + end + attr_accessor :flag + end + child = Class.new(parent) do + def self.openapi_nullable + Set.new([]) + end + end + + nullable_instance = parent.allocate + nullable_instance.instance_variable_set(:@flag, nil) + expect(nullable_instance.to_hash).to eq({ flag: nil }) + + non_nullable_instance = child.allocate + non_nullable_instance.instance_variable_set(:@flag, nil) + expect(non_nullable_instance.to_hash).not_to have_key(:flag) + end end end diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb index ce0a030346bb..6cd3cb0be883 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -142,8 +143,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb index a388cc13fc70..740cfc041047 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb @@ -11,6 +11,7 @@ =end require 'date' +require 'set' require 'time' module Petstore @@ -139,8 +140,9 @@ def to_hash nullable = self.class.openapi_nullable klass = self.class.superclass while klass.respond_to?(:openapi_types) + # an ancestor's nullability only applies to attributes no nearer class redeclares + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) map = klass.attribute_map.merge(map) - nullable = nullable | klass.openapi_nullable klass = klass.superclass end hash = {} From d456c2b32392cdf2de7b849b2d1c9c96ac04daa5 Mon Sep 17 00:00:00 2001 From: Wiebren Braakman Date: Mon, 21 Sep 2026 15:20:57 +0200 Subject: [PATCH 6/6] [ruby] fix: only hand an initializer the attributes it accepts, and load Set only where used build_from_hash and to_hash now take their attribute map from acceptable_attribute_map, the same map the generated initializer validates against. For a generated allOf child it is identical to the ancestry walk; for a consumer subclass that narrows attribute_map it keeps the attributes to the ones the subclass accepts, as on master, instead of passing its parent's fields to an initializer that rejects them. The ancestry walk remains for openapi_types and openapi_nullable. require 'set' is emitted only for generic models, the only ones whose openapi_nullable uses Set; enum classes and oneOf/anyOf modules no longer carry it. Co-Authored-By: Claude Opus 5 (1M context) --- .../ruby-client/base_object.mustache | 21 +++++++++++-------- .../main/resources/ruby-client/model.mustache | 10 +++++++++ .../codegen/ruby/RubyClientCodegenTest.java | 19 +++++++++++------ .../lib/openapi_client/models/bird.rb | 21 +++++++++++-------- .../lib/openapi_client/models/category.rb | 21 +++++++++++-------- .../lib/openapi_client/models/data_query.rb | 21 +++++++++++-------- .../openapi_client/models/default_value.rb | 21 +++++++++++-------- .../models/number_properties_only.rb | 21 +++++++++++-------- .../lib/openapi_client/models/pet.rb | 21 +++++++++++-------- .../lib/openapi_client/models/query.rb | 21 +++++++++++-------- .../openapi_client/models/string_enum_ref.rb | 1 - .../lib/openapi_client/models/tag.rb | 21 +++++++++++-------- ...st_form_object_multipart_request_marker.rb | 21 +++++++++++-------- ...ue_object_all_of_query_object_parameter.rb | 21 +++++++++++-------- ...rue_array_string_query_object_parameter.rb | 21 +++++++++++-------- .../lib/openapi_client/models/bird.rb | 21 +++++++++++-------- .../lib/openapi_client/models/category.rb | 21 +++++++++++-------- .../lib/openapi_client/models/data_query.rb | 21 +++++++++++-------- .../openapi_client/models/default_value.rb | 21 +++++++++++-------- .../models/number_properties_only.rb | 21 +++++++++++-------- .../lib/openapi_client/models/pet.rb | 21 +++++++++++-------- .../lib/openapi_client/models/query.rb | 21 +++++++++++-------- .../openapi_client/models/string_enum_ref.rb | 1 - .../lib/openapi_client/models/tag.rb | 21 +++++++++++-------- ...st_form_object_multipart_request_marker.rb | 21 +++++++++++-------- ...ue_object_all_of_query_object_parameter.rb | 21 +++++++++++-------- ...rue_array_string_query_object_parameter.rb | 21 +++++++++++-------- .../lib/openapi_client/models/bird.rb | 21 +++++++++++-------- .../lib/openapi_client/models/category.rb | 21 +++++++++++-------- .../lib/openapi_client/models/data_query.rb | 21 +++++++++++-------- .../openapi_client/models/default_value.rb | 21 +++++++++++-------- .../models/number_properties_only.rb | 21 +++++++++++-------- .../lib/openapi_client/models/pet.rb | 21 +++++++++++-------- .../lib/openapi_client/models/query.rb | 21 +++++++++++-------- .../openapi_client/models/string_enum_ref.rb | 1 - .../lib/openapi_client/models/tag.rb | 21 +++++++++++-------- ...st_form_object_multipart_request_marker.rb | 21 +++++++++++-------- ...ue_object_all_of_query_object_parameter.rb | 21 +++++++++++-------- ...rue_array_string_query_object_parameter.rb | 21 +++++++++++-------- .../models/additional_properties_class.rb | 21 +++++++++++-------- .../petstore/models/all_of_with_single_ref.rb | 21 +++++++++++-------- .../lib/petstore/models/animal.rb | 21 +++++++++++-------- .../lib/petstore/models/api_response.rb | 21 +++++++++++-------- .../models/array_of_array_of_number_only.rb | 21 +++++++++++-------- .../petstore/models/array_of_number_only.rb | 21 +++++++++++-------- .../lib/petstore/models/array_test.rb | 21 +++++++++++-------- .../lib/petstore/models/capitalization.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/cat.rb | 21 +++++++++++-------- .../lib/petstore/models/category.rb | 21 +++++++++++-------- .../petstore/models/child_with_nullable.rb | 21 +++++++++++-------- .../lib/petstore/models/class_model.rb | 21 +++++++++++-------- .../lib/petstore/models/client.rb | 21 +++++++++++-------- .../lib/petstore/models/deprecated_object.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/dog.rb | 21 +++++++++++-------- .../lib/petstore/models/enum_arrays.rb | 21 +++++++++++-------- .../lib/petstore/models/enum_class.rb | 1 - .../lib/petstore/models/enum_test.rb | 21 +++++++++++-------- .../fake_big_decimal_map200_response.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/file.rb | 21 +++++++++++-------- .../petstore/models/file_schema_test_class.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/foo.rb | 21 +++++++++++-------- .../models/foo_get_default_response.rb | 21 +++++++++++-------- .../lib/petstore/models/format_test.rb | 21 +++++++++++-------- .../lib/petstore/models/has_only_read_only.rb | 21 +++++++++++-------- .../petstore/models/health_check_result.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/list.rb | 21 +++++++++++-------- .../lib/petstore/models/map_test.rb | 21 +++++++++++-------- ...perties_and_additional_properties_class.rb | 21 +++++++++++-------- .../lib/petstore/models/model200_response.rb | 21 +++++++++++-------- .../lib/petstore/models/model_return.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/name.rb | 21 +++++++++++-------- .../lib/petstore/models/nullable_class.rb | 21 +++++++++++-------- .../lib/petstore/models/number_only.rb | 21 +++++++++++-------- .../models/object_with_deprecated_fields.rb | 21 +++++++++++-------- .../lib/petstore/models/order.rb | 21 +++++++++++-------- .../lib/petstore/models/outer_composite.rb | 21 +++++++++++-------- .../lib/petstore/models/outer_enum.rb | 1 - .../models/outer_enum_default_value.rb | 1 - .../lib/petstore/models/outer_enum_integer.rb | 1 - .../outer_enum_integer_default_value.rb | 1 - .../models/outer_object_with_enum_property.rb | 21 +++++++++++-------- .../petstore/models/parent_with_nullable.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/pet.rb | 21 +++++++++++-------- .../lib/petstore/models/read_only_first.rb | 21 +++++++++++-------- .../lib/petstore/models/single_ref_type.rb | 1 - .../lib/petstore/models/special_model_name.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/tag.rb | 21 +++++++++++-------- ..._freeform_additional_properties_request.rb | 21 +++++++++++-------- .../ruby-autoload/lib/petstore/models/user.rb | 21 +++++++++++-------- .../models/additional_properties_class.rb | 21 +++++++++++-------- .../petstore/models/all_of_with_single_ref.rb | 21 +++++++++++-------- .../lib/petstore/models/animal.rb | 21 +++++++++++-------- .../lib/petstore/models/api_response.rb | 21 +++++++++++-------- .../models/array_of_array_of_number_only.rb | 21 +++++++++++-------- .../petstore/models/array_of_number_only.rb | 21 +++++++++++-------- .../lib/petstore/models/array_test.rb | 21 +++++++++++-------- .../lib/petstore/models/capitalization.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/cat.rb | 21 +++++++++++-------- .../lib/petstore/models/category.rb | 21 +++++++++++-------- .../lib/petstore/models/class_model.rb | 21 +++++++++++-------- .../lib/petstore/models/client.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/cow.rb | 1 - .../lib/petstore/models/deprecated_object.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/dog.rb | 21 +++++++++++-------- .../lib/petstore/models/enum_arrays.rb | 21 +++++++++++-------- .../lib/petstore/models/enum_class.rb | 1 - .../lib/petstore/models/enum_test.rb | 21 +++++++++++-------- .../fake_big_decimal_map200_response.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/file.rb | 21 +++++++++++-------- .../petstore/models/file_schema_test_class.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/foo.rb | 21 +++++++++++-------- .../models/foo_get_default_response.rb | 21 +++++++++++-------- .../lib/petstore/models/format_test.rb | 21 +++++++++++-------- .../lib/petstore/models/has_only_read_only.rb | 21 +++++++++++-------- .../petstore/models/health_check_result.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/list.rb | 21 +++++++++++-------- .../lib/petstore/models/mammal.rb | 1 - .../lib/petstore/models/mammal_anyof.rb | 1 - .../models/mammal_without_discriminator.rb | 1 - .../lib/petstore/models/map_test.rb | 21 +++++++++++-------- ...perties_and_additional_properties_class.rb | 21 +++++++++++-------- .../lib/petstore/models/model200_response.rb | 21 +++++++++++-------- .../lib/petstore/models/model_return.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/name.rb | 21 +++++++++++-------- .../lib/petstore/models/nullable_class.rb | 21 +++++++++++-------- .../lib/petstore/models/number_only.rb | 21 +++++++++++-------- .../models/object_with_deprecated_fields.rb | 21 +++++++++++-------- .../petstore/models/one_of_primitive_types.rb | 1 - .../ruby-faraday/lib/petstore/models/order.rb | 21 +++++++++++-------- .../lib/petstore/models/outer_composite.rb | 21 +++++++++++-------- .../lib/petstore/models/outer_enum.rb | 1 - .../models/outer_enum_default_value.rb | 1 - .../lib/petstore/models/outer_enum_integer.rb | 1 - .../outer_enum_integer_default_value.rb | 1 - .../models/outer_object_with_enum_property.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/pet.rb | 21 +++++++++++-------- .../petstore/models/property_name_mapping.rb | 21 +++++++++++-------- .../lib/petstore/models/read_only_first.rb | 21 +++++++++++-------- .../lib/petstore/models/single_ref_type.rb | 1 - .../lib/petstore/models/special_model_name.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/tag.rb | 21 +++++++++++-------- ..._freeform_additional_properties_request.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/user.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/whale.rb | 21 +++++++++++-------- .../ruby-faraday/lib/petstore/models/zebra.rb | 21 +++++++++++-------- .../spec/custom/base_object_spec.rb | 17 +++++++++++++++ .../models/additional_properties_class.rb | 21 +++++++++++-------- .../petstore/models/all_of_with_single_ref.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/animal.rb | 21 +++++++++++-------- .../lib/petstore/models/api_response.rb | 21 +++++++++++-------- .../models/array_of_array_of_number_only.rb | 21 +++++++++++-------- .../petstore/models/array_of_number_only.rb | 21 +++++++++++-------- .../lib/petstore/models/array_test.rb | 21 +++++++++++-------- .../lib/petstore/models/capitalization.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/cat.rb | 21 +++++++++++-------- .../lib/petstore/models/category.rb | 21 +++++++++++-------- .../lib/petstore/models/class_model.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/client.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/cow.rb | 1 - .../lib/petstore/models/deprecated_object.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/dog.rb | 21 +++++++++++-------- .../lib/petstore/models/enum_arrays.rb | 21 +++++++++++-------- .../lib/petstore/models/enum_class.rb | 1 - .../lib/petstore/models/enum_test.rb | 21 +++++++++++-------- .../fake_big_decimal_map200_response.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/file.rb | 21 +++++++++++-------- .../petstore/models/file_schema_test_class.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/foo.rb | 21 +++++++++++-------- .../models/foo_get_default_response.rb | 21 +++++++++++-------- .../lib/petstore/models/format_test.rb | 21 +++++++++++-------- .../lib/petstore/models/has_only_read_only.rb | 21 +++++++++++-------- .../petstore/models/health_check_result.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/list.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/mammal.rb | 1 - .../lib/petstore/models/mammal_anyof.rb | 1 - .../models/mammal_without_discriminator.rb | 1 - .../lib/petstore/models/map_test.rb | 21 +++++++++++-------- ...perties_and_additional_properties_class.rb | 21 +++++++++++-------- .../lib/petstore/models/model200_response.rb | 21 +++++++++++-------- .../lib/petstore/models/model_return.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/name.rb | 21 +++++++++++-------- .../lib/petstore/models/nullable_class.rb | 21 +++++++++++-------- .../lib/petstore/models/number_only.rb | 21 +++++++++++-------- .../models/object_with_deprecated_fields.rb | 21 +++++++++++-------- .../petstore/models/one_of_primitive_types.rb | 1 - .../ruby-httpx/lib/petstore/models/order.rb | 21 +++++++++++-------- .../lib/petstore/models/outer_composite.rb | 21 +++++++++++-------- .../lib/petstore/models/outer_enum.rb | 1 - .../models/outer_enum_default_value.rb | 1 - .../lib/petstore/models/outer_enum_integer.rb | 1 - .../outer_enum_integer_default_value.rb | 1 - .../models/outer_object_with_enum_property.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/pet.rb | 21 +++++++++++-------- .../petstore/models/property_name_mapping.rb | 21 +++++++++++-------- .../lib/petstore/models/read_only_first.rb | 21 +++++++++++-------- .../lib/petstore/models/single_ref_type.rb | 1 - .../lib/petstore/models/special_model_name.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/tag.rb | 21 +++++++++++-------- ..._freeform_additional_properties_request.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/user.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/whale.rb | 21 +++++++++++-------- .../ruby-httpx/lib/petstore/models/zebra.rb | 21 +++++++++++-------- .../spec/custom/base_object_spec.rb | 17 +++++++++++++++ .../models/additional_properties_class.rb | 21 +++++++++++-------- .../petstore/models/all_of_with_single_ref.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/animal.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/api_response.rb | 21 +++++++++++-------- .../models/array_of_array_of_number_only.rb | 21 +++++++++++-------- .../petstore/models/array_of_number_only.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/array_test.rb | 21 +++++++++++-------- .../lib/petstore/models/capitalization.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/cat.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/category.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/class_model.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/client.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/cow.rb | 1 - .../lib/petstore/models/deprecated_object.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/dog.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/enum_arrays.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/enum_class.rb | 1 - .../ruby/lib/petstore/models/enum_test.rb | 21 +++++++++++-------- .../fake_big_decimal_map200_response.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/file.rb | 21 +++++++++++-------- .../petstore/models/file_schema_test_class.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/foo.rb | 21 +++++++++++-------- .../models/foo_get_default_response.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/format_test.rb | 21 +++++++++++-------- .../lib/petstore/models/has_only_read_only.rb | 21 +++++++++++-------- .../petstore/models/health_check_result.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/list.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/mammal.rb | 1 - .../ruby/lib/petstore/models/mammal_anyof.rb | 1 - .../models/mammal_without_discriminator.rb | 1 - .../ruby/lib/petstore/models/map_test.rb | 21 +++++++++++-------- ...perties_and_additional_properties_class.rb | 21 +++++++++++-------- .../lib/petstore/models/model200_response.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/model_return.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/name.rb | 21 +++++++++++-------- .../lib/petstore/models/nullable_class.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/number_only.rb | 21 +++++++++++-------- .../models/object_with_deprecated_fields.rb | 21 +++++++++++-------- .../petstore/models/one_of_primitive_types.rb | 1 - .../ruby/lib/petstore/models/order.rb | 21 +++++++++++-------- .../lib/petstore/models/outer_composite.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/outer_enum.rb | 1 - .../models/outer_enum_default_value.rb | 1 - .../lib/petstore/models/outer_enum_integer.rb | 1 - .../outer_enum_integer_default_value.rb | 1 - .../models/outer_object_with_enum_property.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/pet.rb | 21 +++++++++++-------- .../petstore/models/property_name_mapping.rb | 21 +++++++++++-------- .../lib/petstore/models/read_only_first.rb | 21 +++++++++++-------- .../lib/petstore/models/single_ref_type.rb | 1 - .../lib/petstore/models/special_model_name.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/tag.rb | 21 +++++++++++-------- ..._freeform_additional_properties_request.rb | 21 +++++++++++-------- .../petstore/ruby/lib/petstore/models/user.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/whale.rb | 21 +++++++++++-------- .../ruby/lib/petstore/models/zebra.rb | 21 +++++++++++-------- .../ruby/spec/custom/base_object_spec.rb | 17 +++++++++++++++ .../lib/petstore/models/array_alias.rb | 21 +++++++++++-------- .../lib/petstore/models/map_alias.rb | 21 +++++++++++-------- 262 files changed, 2654 insertions(+), 1983 deletions(-) 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 f25a512b5a7a..8256184e279b 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 @@ -4,19 +4,21 @@ def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -35,17 +37,18 @@ # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/modules/openapi-generator/src/main/resources/ruby-client/model.mustache b/modules/openapi-generator/src/main/resources/ruby-client/model.mustache index fe71e76ca394..be586a5ebaa0 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/model.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/model.mustache @@ -4,7 +4,17 @@ =end require 'date' +{{#models}} +{{#model}} +{{^isEnum}} +{{^oneOf}} +{{^anyOf}} require 'set' +{{/anyOf}} +{{/oneOf}} +{{/isEnum}} +{{/model}} +{{/models}} require 'time' module {{moduleName}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index 9ab274fd3eda..d739001c373e 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -779,14 +779,18 @@ public void testBuildFromHashMapsInheritedAttributes() throws Exception { // attribute_map from the whole ancestry, not just the child's own java.nio.file.Path lizard = new File(output, "lib/openapi_client/models/lizard.rb").toPath(); TestUtils.assertFileContains(lizard, - "types = openapi_types\n" + - " map = attribute_map\n" + + "map = acceptable_attribute_map\n" + + " types = openapi_types\n" + " klass = superclass\n" + " while klass.respond_to?(:openapi_types)\n" + " types = klass.openapi_types.merge(types)\n" + - " map = klass.attribute_map.merge(map)\n" + " klass = klass.superclass\n" + " end"); + // only attributes the initializer accepts are passed on, so a consumer subclass + // that narrows attribute_map is not handed its generated parent's attributes + TestUtils.assertFileContains(lizard, + "types.each_pair do |key, type|\n" + + " next unless map.key?(key)\n"); // the discarded-result super call is gone: openapi_types/attribute_map // dispatch on the child class in the parent's frame too, so it never // contributed the parent's attributes - it only built a second instance @@ -795,17 +799,20 @@ public void testBuildFromHashMapsInheritedAttributes() throws Exception { // child in every ancestor frame, so the old super chain only repeated the child's // own attributes and a round-tripped model lost its inherited fields TestUtils.assertFileContains(lizard, - "map = self.class.attribute_map\n" + + "map = self.class.acceptable_attribute_map\n" + " nullable = self.class.openapi_nullable\n" + + " declared = self.class.attribute_map.keys\n" + " klass = self.class.superclass\n" + " while klass.respond_to?(:openapi_types)\n" + " # an ancestor's nullability only applies to attributes no nearer class redeclares\n" + - " nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys)\n" + - " map = klass.attribute_map.merge(map)\n" + + " nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared)\n" + + " declared |= klass.attribute_map.keys\n" + " klass = klass.superclass\n" + " end"); // the walk evaluates openapi_nullable eagerly, so Set must be loaded on rubies // where it is not yet a builtin autoload TestUtils.assertFileContains(lizard, "require 'set'"); + // only the generic model uses Set; a oneOf module does not load it + TestUtils.assertFileNotContains(new File(output, "lib/openapi_client/models/my_pets.rb").toPath(), "require 'set'"); } } diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb index 8cda283934e8..61065223d6a8 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/bird.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb index 28f1164e3cc3..050bf133447c 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/category.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb index 62f7dfffd244..c31ca8e72184 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/data_query.rb @@ -163,19 +163,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -194,17 +196,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb index fcdc5d3f1025..e7e3bc9eb23b 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/default_value.rb @@ -213,19 +213,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -244,17 +246,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb index 3994598e1e81..06b9530b2a7b 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/number_properties_only.rb @@ -156,19 +156,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -187,17 +189,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb index 1e42b815e93d..ff43c8840c86 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/pet.rb @@ -228,19 +228,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -259,17 +261,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb index 501661567c64..905b4af2f6b2 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/query.rb @@ -144,19 +144,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -175,17 +177,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb index 4a9ae3054ded..0777b5e07042 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/string_enum_ref.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module OpenapiClient diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb index d3b27cae66ef..8256404852fa 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/tag.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 2bc861a89940..751f72b8ff30 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 58afc507821d..84f5dd888f9b 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -145,19 +145,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -176,17 +178,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 0845d0de0469..8c4462e583fa 100644 --- a/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-faraday/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb index 8cda283934e8..61065223d6a8 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/bird.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb index 28f1164e3cc3..050bf133447c 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/category.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb index 62f7dfffd244..c31ca8e72184 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/data_query.rb @@ -163,19 +163,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -194,17 +196,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb index fcdc5d3f1025..e7e3bc9eb23b 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/default_value.rb @@ -213,19 +213,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -244,17 +246,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb index 3994598e1e81..06b9530b2a7b 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/number_properties_only.rb @@ -156,19 +156,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -187,17 +189,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb index 1e42b815e93d..ff43c8840c86 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/pet.rb @@ -228,19 +228,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -259,17 +261,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb index 501661567c64..905b4af2f6b2 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/query.rb @@ -144,19 +144,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -175,17 +177,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb index 4a9ae3054ded..0777b5e07042 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/string_enum_ref.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module OpenapiClient diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb index d3b27cae66ef..8256404852fa 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/tag.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 2bc861a89940..751f72b8ff30 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 58afc507821d..84f5dd888f9b 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -145,19 +145,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -176,17 +178,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 0845d0de0469..8c4462e583fa 100644 --- a/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-httpx/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb index 8cda283934e8..61065223d6a8 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/bird.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb index 28f1164e3cc3..050bf133447c 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/category.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb index 62f7dfffd244..c31ca8e72184 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/data_query.rb @@ -163,19 +163,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -194,17 +196,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb index fcdc5d3f1025..e7e3bc9eb23b 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/default_value.rb @@ -213,19 +213,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -244,17 +246,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb index 3994598e1e81..06b9530b2a7b 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/number_properties_only.rb @@ -156,19 +156,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -187,17 +189,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb index 1e42b815e93d..ff43c8840c86 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/pet.rb @@ -228,19 +228,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -259,17 +261,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb index 501661567c64..905b4af2f6b2 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/query.rb @@ -144,19 +144,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -175,17 +177,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb index 4a9ae3054ded..0777b5e07042 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/string_enum_ref.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module OpenapiClient diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb index d3b27cae66ef..8256404852fa 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/tag.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb index 2bc861a89940..751f72b8ff30 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_form_object_multipart_request_marker.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb index 58afc507821d..84f5dd888f9b 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.rb @@ -145,19 +145,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -176,17 +178,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb index 0845d0de0469..8c4462e583fa 100644 --- a/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb +++ b/samples/client/echo_api/ruby-typhoeus/lib/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb index 318e5b5bd6e4..c38667361312 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/additional_properties_class.rb @@ -123,19 +123,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -154,17 +156,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb index c9cf74e48eb9..03d66622f4b7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/all_of_with_single_ref.rb @@ -141,19 +141,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -172,17 +174,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb index f16064590127..37c8ed97fafe 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/animal.rb @@ -143,19 +143,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -174,17 +176,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb index 2b8f6f3da716..a75596435a57 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/api_response.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb index 61ec9a339f8a..2361abe91a45 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_array_of_number_only.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb index 25936c36112d..c5fce5e95eba 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_of_number_only.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb index 4250f94d5602..32f3d67712ed 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/array_test.rb @@ -162,19 +162,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -193,17 +195,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb index 980b6d4f6fdf..0ae0ec8aabd7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/capitalization.rb @@ -156,19 +156,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -187,17 +189,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb index ccf06cb566c7..8731bb5c1752 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/cat.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb index 1e13601082aa..e90a6d77cdf0 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/category.rb @@ -136,19 +136,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -167,17 +169,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb index 43b774c168d7..ec5e5320ab76 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb @@ -142,19 +142,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -173,17 +175,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb index 368596110da9..d9fd81fa31c1 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/class_model.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb index 2c8707232d25..e97870e1e13d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/client.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb index b5cfe6462091..1c46195a76ca 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/deprecated_object.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb index 2acab0f70063..c0ff86af2bfa 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/dog.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb index 0dc6e78adaf5..2ac75434033a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_arrays.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb index a62e4022056d..54bffd17d38c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_class.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb index b9bd10e9f232..25fc70573176 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/enum_test.rb @@ -255,19 +255,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -286,17 +288,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb index 2b15275e0af8..ccb9e88f8b1a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb index e16db98d6d8e..8cf587edafa7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb index b8c3a85378e7..28a5dbe5a0a2 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/file_schema_test_class.rb @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb index 4912ef30b029..122daf6944c9 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb index 9994654f38d4..e2d5e8bd6b3c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/foo_get_default_response.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb index b22f471e3367..e6868a7827ed 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/format_test.rb @@ -526,19 +526,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -557,17 +559,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb index e12981d112e4..ca976a7a2f8f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/has_only_read_only.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb index 5ee62c4fc45e..6a6b964f77e0 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/health_check_result.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb index ffbc3b957a30..47b89b33e13a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/list.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb index acb0dc9c82d4..62aee42b20e4 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/map_test.rb @@ -167,19 +167,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -198,17 +200,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 36969d7426cb..b57aa5e5f25d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -130,19 +130,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -161,17 +163,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb index 72b7d2292c99..f9f6d6816b1d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model200_response.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb index 61b38f1c7145..fea44851083d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/model_return.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb index be828a1f316f..212867172066 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/name.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb index 09c9ce983a33..8d0a9afac54b 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/nullable_class.rb @@ -231,19 +231,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -262,17 +264,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb index f16ccf580bb9..91b11052712a 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/number_only.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb index 5b49ba4d887a..6f99097cc152 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/object_with_deprecated_fields.rb @@ -139,19 +139,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -170,17 +172,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb index e780b4a33e07..2b421927e870 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/order.rb @@ -192,19 +192,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -223,17 +225,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb index 3fa7f5c7f2d7..f4d47d9f422e 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_composite.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb index 553a17fc7baa..acd2130a7b3f 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb index 22218ed7dc56..0dd059474528 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb index 272c02c4b297..d3288d09b952 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb index ba0177c87428..147293ad274c 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb index 4aff91a0894b..240bf4258054 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/outer_object_with_enum_property.rb @@ -149,19 +149,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -180,17 +182,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb index 3c0654c4a6eb..136129724b4d 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb @@ -159,19 +159,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -190,17 +192,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb index c6157317e624..4ca1b4a26c69 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/pet.rb @@ -228,19 +228,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -259,17 +261,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb index b3453085466d..1c0141858780 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/read_only_first.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb index 935576e416a8..3f09a14e0cbb 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/single_ref_type.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb index 956b8d95ca63..a33b30780ab7 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/special_model_name.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb index dac93098e66f..3cf2f5bfe829 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/tag.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 857d0a9ebd3c..a27e8514ffad 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb index a4e13e3f82dd..07d1f3a96afd 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/user.rb @@ -174,19 +174,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -205,17 +207,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb index 318e5b5bd6e4..c38667361312 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/additional_properties_class.rb @@ -123,19 +123,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -154,17 +156,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb index c9cf74e48eb9..03d66622f4b7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb @@ -141,19 +141,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -172,17 +174,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb index f16064590127..37c8ed97fafe 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/animal.rb @@ -143,19 +143,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -174,17 +176,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb index 2b8f6f3da716..a75596435a57 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/api_response.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb index 61ec9a339f8a..2361abe91a45 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_array_of_number_only.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb index 25936c36112d..c5fce5e95eba 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_of_number_only.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb index 4250f94d5602..32f3d67712ed 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/array_test.rb @@ -162,19 +162,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -193,17 +195,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb index 980b6d4f6fdf..0ae0ec8aabd7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/capitalization.rb @@ -156,19 +156,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -187,17 +189,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb index ccf06cb566c7..8731bb5c1752 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cat.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb index 1e13601082aa..e90a6d77cdf0 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/category.rb @@ -136,19 +136,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -167,17 +169,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb index 368596110da9..d9fd81fa31c1 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/class_model.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb index 2c8707232d25..e97870e1e13d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/client.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb index 5ed3c0951421..b100c2538a23 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/cow.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb index b5cfe6462091..1c46195a76ca 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/deprecated_object.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb index 2acab0f70063..c0ff86af2bfa 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/dog.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb index 0dc6e78adaf5..2ac75434033a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_arrays.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb index a62e4022056d..54bffd17d38c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_class.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb index b9bd10e9f232..25fc70573176 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/enum_test.rb @@ -255,19 +255,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -286,17 +288,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb index 2b15275e0af8..ccb9e88f8b1a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb index e16db98d6d8e..8cf587edafa7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb index b8c3a85378e7..28a5dbe5a0a2 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/file_schema_test_class.rb @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb index 4912ef30b029..122daf6944c9 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb index 9994654f38d4..e2d5e8bd6b3c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/foo_get_default_response.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb index b22f471e3367..e6868a7827ed 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/format_test.rb @@ -526,19 +526,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -557,17 +559,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb index e12981d112e4..ca976a7a2f8f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/has_only_read_only.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb index 5ee62c4fc45e..6a6b964f77e0 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/health_check_result.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb index ffbc3b957a30..47b89b33e13a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/list.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb index 9150806f1c9f..91c5a53ffdcd 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb index 1e1b125ad925..36e88a462640 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_anyof.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb index 200f1d743785..11556be23523 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mammal_without_discriminator.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb index acb0dc9c82d4..62aee42b20e4 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/map_test.rb @@ -167,19 +167,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -198,17 +200,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 36969d7426cb..b57aa5e5f25d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -130,19 +130,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -161,17 +163,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb index 72b7d2292c99..f9f6d6816b1d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model200_response.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb index 61b38f1c7145..fea44851083d 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/model_return.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb index be828a1f316f..212867172066 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/name.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb index 09c9ce983a33..8d0a9afac54b 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/nullable_class.rb @@ -231,19 +231,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -262,17 +264,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb index f16ccf580bb9..91b11052712a 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/number_only.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb index 5b49ba4d887a..6f99097cc152 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/object_with_deprecated_fields.rb @@ -139,19 +139,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -170,17 +172,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb index e15b48634c65..68d2585262a4 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/one_of_primitive_types.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb index e780b4a33e07..2b421927e870 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/order.rb @@ -192,19 +192,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -223,17 +225,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb index 3fa7f5c7f2d7..f4d47d9f422e 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_composite.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb index 553a17fc7baa..acd2130a7b3f 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb index 22218ed7dc56..0dd059474528 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb index e01f8df22f36..c39ede502d25 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb index ba0177c87428..147293ad274c 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb index 4aff91a0894b..240bf4258054 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/outer_object_with_enum_property.rb @@ -149,19 +149,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -180,17 +182,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb index c6157317e624..4ca1b4a26c69 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/pet.rb @@ -228,19 +228,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -259,17 +261,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb index 3456b9510d0f..98702a7e7581 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/property_name_mapping.rb @@ -137,19 +137,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -168,17 +170,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb index b3453085466d..1c0141858780 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/read_only_first.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb index 935576e416a8..3f09a14e0cbb 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/single_ref_type.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb index 956b8d95ca63..a33b30780ab7 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/special_model_name.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb index dac93098e66f..3cf2f5bfe829 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/tag.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 857d0a9ebd3c..a27e8514ffad 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb index a4e13e3f82dd..07d1f3a96afd 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/user.rb @@ -174,19 +174,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -205,17 +207,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb index b2de797c8a39..0b99a73aad33 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/whale.rb @@ -145,19 +145,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -176,17 +178,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb index 6d766c38164b..52025ddfe0fb 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/zebra.rb @@ -170,19 +170,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -201,17 +203,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb index de5c1890f244..acb4d1588f79 100644 --- a/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-faraday/spec/custom/base_object_spec.rb @@ -212,5 +212,22 @@ def self.openapi_nullable non_nullable_instance.instance_variable_set(:@flag, nil) expect(non_nullable_instance.to_hash).not_to have_key(:flag) end + + it 'a subclass that narrows attribute_map is only handed the attributes it accepts' do + narrowed = Class.new(Petstore::Animal) do + def self.attribute_map + { :class_name => :className } + end + + def self.openapi_types + { :class_name => :'String' } + end + end + + obj = narrowed.build_from_hash({ 'className' => 'Cat', 'color' => 'black' }) + + expect(obj.class_name).to eq('Cat') + expect(obj.to_hash).to eq({ className: 'Cat' }) + end end end diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb index 318e5b5bd6e4..c38667361312 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/additional_properties_class.rb @@ -123,19 +123,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -154,17 +156,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb index c9cf74e48eb9..03d66622f4b7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/all_of_with_single_ref.rb @@ -141,19 +141,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -172,17 +174,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb index f16064590127..37c8ed97fafe 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/animal.rb @@ -143,19 +143,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -174,17 +176,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb index 2b8f6f3da716..a75596435a57 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/api_response.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb index 61ec9a339f8a..2361abe91a45 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_array_of_number_only.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb index 25936c36112d..c5fce5e95eba 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_of_number_only.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb index 4250f94d5602..32f3d67712ed 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/array_test.rb @@ -162,19 +162,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -193,17 +195,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb index 980b6d4f6fdf..0ae0ec8aabd7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/capitalization.rb @@ -156,19 +156,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -187,17 +189,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb index ccf06cb566c7..8731bb5c1752 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/cat.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb index 1e13601082aa..e90a6d77cdf0 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/category.rb @@ -136,19 +136,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -167,17 +169,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb index 368596110da9..d9fd81fa31c1 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/class_model.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb index 2c8707232d25..e97870e1e13d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/client.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb index 5ed3c0951421..b100c2538a23 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/cow.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb index b5cfe6462091..1c46195a76ca 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/deprecated_object.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb index 2acab0f70063..c0ff86af2bfa 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/dog.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb index 0dc6e78adaf5..2ac75434033a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_arrays.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb index a62e4022056d..54bffd17d38c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_class.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb index b9bd10e9f232..25fc70573176 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/enum_test.rb @@ -255,19 +255,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -286,17 +288,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb index 2b15275e0af8..ccb9e88f8b1a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb index e16db98d6d8e..8cf587edafa7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb index b8c3a85378e7..28a5dbe5a0a2 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/file_schema_test_class.rb @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb index 4912ef30b029..122daf6944c9 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb index 9994654f38d4..e2d5e8bd6b3c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/foo_get_default_response.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb index b22f471e3367..e6868a7827ed 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/format_test.rb @@ -526,19 +526,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -557,17 +559,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb index e12981d112e4..ca976a7a2f8f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/has_only_read_only.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb index 5ee62c4fc45e..6a6b964f77e0 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/health_check_result.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb index ffbc3b957a30..47b89b33e13a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/list.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb index 9150806f1c9f..91c5a53ffdcd 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb index 1e1b125ad925..36e88a462640 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_anyof.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb index 200f1d743785..11556be23523 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mammal_without_discriminator.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb index acb0dc9c82d4..62aee42b20e4 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/map_test.rb @@ -167,19 +167,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -198,17 +200,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 36969d7426cb..b57aa5e5f25d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -130,19 +130,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -161,17 +163,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb index 72b7d2292c99..f9f6d6816b1d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model200_response.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb index 61b38f1c7145..fea44851083d 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/model_return.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb index be828a1f316f..212867172066 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/name.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb index 09c9ce983a33..8d0a9afac54b 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/nullable_class.rb @@ -231,19 +231,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -262,17 +264,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb index f16ccf580bb9..91b11052712a 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/number_only.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb index 5b49ba4d887a..6f99097cc152 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/object_with_deprecated_fields.rb @@ -139,19 +139,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -170,17 +172,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb index e15b48634c65..68d2585262a4 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/one_of_primitive_types.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb index e780b4a33e07..2b421927e870 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/order.rb @@ -192,19 +192,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -223,17 +225,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb index 3fa7f5c7f2d7..f4d47d9f422e 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_composite.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb index 553a17fc7baa..acd2130a7b3f 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb index 22218ed7dc56..0dd059474528 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb index e01f8df22f36..c39ede502d25 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb index ba0177c87428..147293ad274c 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb index 4aff91a0894b..240bf4258054 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/outer_object_with_enum_property.rb @@ -149,19 +149,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -180,17 +182,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb index c6157317e624..4ca1b4a26c69 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/pet.rb @@ -228,19 +228,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -259,17 +261,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb index 3456b9510d0f..98702a7e7581 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/property_name_mapping.rb @@ -137,19 +137,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -168,17 +170,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb index b3453085466d..1c0141858780 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/read_only_first.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb index 935576e416a8..3f09a14e0cbb 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/single_ref_type.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb index 956b8d95ca63..a33b30780ab7 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/special_model_name.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb index dac93098e66f..3cf2f5bfe829 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/tag.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 857d0a9ebd3c..a27e8514ffad 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb index a4e13e3f82dd..07d1f3a96afd 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/user.rb @@ -174,19 +174,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -205,17 +207,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb index b2de797c8a39..0b99a73aad33 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/whale.rb @@ -145,19 +145,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -176,17 +178,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb index 6d766c38164b..52025ddfe0fb 100644 --- a/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby-httpx/lib/petstore/models/zebra.rb @@ -170,19 +170,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -201,17 +203,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb index de5c1890f244..acb4d1588f79 100644 --- a/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby-httpx/spec/custom/base_object_spec.rb @@ -212,5 +212,22 @@ def self.openapi_nullable non_nullable_instance.instance_variable_set(:@flag, nil) expect(non_nullable_instance.to_hash).not_to have_key(:flag) end + + it 'a subclass that narrows attribute_map is only handed the attributes it accepts' do + narrowed = Class.new(Petstore::Animal) do + def self.attribute_map + { :class_name => :className } + end + + def self.openapi_types + { :class_name => :'String' } + end + end + + obj = narrowed.build_from_hash({ 'className' => 'Cat', 'color' => 'black' }) + + expect(obj.class_name).to eq('Cat') + expect(obj.to_hash).to eq({ className: 'Cat' }) + end 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 318e5b5bd6e4..c38667361312 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 @@ -123,19 +123,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -154,17 +156,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb index c9cf74e48eb9..03d66622f4b7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb @@ -141,19 +141,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -172,17 +174,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index f16064590127..37c8ed97fafe 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -143,19 +143,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -174,17 +176,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 2b8f6f3da716..a75596435a57 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 61ec9a339f8a..2361abe91a45 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 @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 25936c36112d..c5fce5e95eba 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 @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 4250f94d5602..32f3d67712ed 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -162,19 +162,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -193,17 +195,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb index 980b6d4f6fdf..0ae0ec8aabd7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -156,19 +156,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -187,17 +189,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index ccf06cb566c7..8731bb5c1752 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 1e13601082aa..e90a6d77cdf0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -136,19 +136,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -167,17 +169,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 368596110da9..d9fd81fa31c1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index 2c8707232d25..e97870e1e13d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/cow.rb b/samples/client/petstore/ruby/lib/petstore/models/cow.rb index 5ed3c0951421..b100c2538a23 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cow.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cow.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb index b5cfe6462091..1c46195a76ca 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/deprecated_object.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 2acab0f70063..c0ff86af2bfa 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 0dc6e78adaf5..2ac75434033a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 a62e4022056d..54bffd17d38c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_class.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore 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 b9bd10e9f232..25fc70573176 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -255,19 +255,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -286,17 +288,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb index 2b15275e0af8..ccb9e88f8b1a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/fake_big_decimal_map200_response.rb @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/file.rb b/samples/client/petstore/ruby/lib/petstore/models/file.rb index e16db98d6d8e..8cf587edafa7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 b8c3a85378e7..28a5dbe5a0a2 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 @@ -121,19 +121,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -152,17 +154,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/client/petstore/ruby/lib/petstore/models/foo.rb index 4912ef30b029..122daf6944c9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb index 9994654f38d4..e2d5e8bd6b3c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/foo_get_default_response.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 b22f471e3367..e6868a7827ed 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -526,19 +526,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -557,17 +559,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 e12981d112e4..ca976a7a2f8f 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 @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb index 5ee62c4fc45e..6a6b964f77e0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/health_check_result.rb @@ -112,19 +112,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -143,17 +145,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index ffbc3b957a30..47b89b33e13a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/mammal.rb b/samples/client/petstore/ruby/lib/petstore/models/mammal.rb index 9150806f1c9f..91c5a53ffdcd 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mammal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mammal.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb b/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb index 1e1b125ad925..36e88a462640 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mammal_anyof.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb b/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb index 200f1d743785..11556be23523 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mammal_without_discriminator.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore 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 acb0dc9c82d4..62aee42b20e4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -167,19 +167,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -198,17 +200,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 36969d7426cb..b57aa5e5f25d 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 @@ -130,19 +130,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -161,17 +163,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 72b7d2292c99..f9f6d6816b1d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -120,19 +120,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -151,17 +153,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 61b38f1c7145..fea44851083d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -111,19 +111,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -142,17 +144,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index be828a1f316f..212867172066 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -155,19 +155,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -186,17 +188,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb index 09c9ce983a33..8d0a9afac54b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/nullable_class.rb @@ -231,19 +231,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -262,17 +264,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 f16ccf580bb9..91b11052712a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb index 5b49ba4d887a..6f99097cc152 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/object_with_deprecated_fields.rb @@ -139,19 +139,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -170,17 +172,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb b/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb index e15b48634c65..68d2585262a4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/one_of_primitive_types.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index e780b4a33e07..2b421927e870 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -192,19 +192,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -223,17 +225,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 3fa7f5c7f2d7..f4d47d9f422e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -128,19 +128,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -159,17 +161,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 a57a48e52b93..2a28686b572a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb index a0d4ef9c80f9..97ef2fbb547c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb index e01f8df22f36..c39ede502d25 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb index ba0177c87428..147293ad274c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_enum_integer_default_value.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb index 4aff91a0894b..240bf4258054 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_object_with_enum_property.rb @@ -149,19 +149,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -180,17 +182,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index c6157317e624..4ca1b4a26c69 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -228,19 +228,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -259,17 +261,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb index 57b0bdc57fcc..d786c366d8cd 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/property_name_mapping.rb @@ -137,19 +137,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -168,17 +170,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} 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 b3453085466d..1c0141858780 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 @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb b/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb index 935576e416a8..3f09a14e0cbb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/single_ref_type.rb @@ -11,7 +11,6 @@ =end require 'date' -require 'set' require 'time' module Petstore 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 956b8d95ca63..a33b30780ab7 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 @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index dac93098e66f..3cf2f5bfe829 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -119,19 +119,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -150,17 +152,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb index 857d0a9ebd3c..a27e8514ffad 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/test_inline_freeform_additional_properties_request.rb @@ -110,19 +110,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -141,17 +143,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index a4e13e3f82dd..07d1f3a96afd 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -174,19 +174,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -205,17 +207,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/whale.rb b/samples/client/petstore/ruby/lib/petstore/models/whale.rb index b2de797c8a39..0b99a73aad33 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/whale.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/whale.rb @@ -145,19 +145,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -176,17 +178,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb index 6d766c38164b..52025ddfe0fb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/zebra.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/zebra.rb @@ -170,19 +170,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -201,17 +203,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb index de5c1890f244..acb4d1588f79 100644 --- a/samples/client/petstore/ruby/spec/custom/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/custom/base_object_spec.rb @@ -212,5 +212,22 @@ def self.openapi_nullable non_nullable_instance.instance_variable_set(:@flag, nil) expect(non_nullable_instance.to_hash).not_to have_key(:flag) end + + it 'a subclass that narrows attribute_map is only handed the attributes it accepts' do + narrowed = Class.new(Petstore::Animal) do + def self.attribute_map + { :class_name => :className } + end + + def self.openapi_types + { :class_name => :'String' } + end + end + + obj = narrowed.build_from_hash({ 'className' => 'Cat', 'color' => 'black' }) + + expect(obj.class_name).to eq('Cat') + expect(obj.to_hash).to eq({ className: 'Cat' }) + end end end diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb index 6cd3cb0be883..0ee2b84b1310 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/array_alias.rb @@ -104,19 +104,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -135,17 +137,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {} diff --git a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb index 740cfc041047..e4e0468d1703 100644 --- a/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb +++ b/samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/models/map_alias.rb @@ -101,19 +101,21 @@ def hash def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) - # collect the attributes this model knows about, including the ones - # defined in its parent(s), so an allOf child also maps its inherited - # attributes (the child's own declaration wins on a name clash) + # map the attributes this model knows about, including the ones defined + # in its parent(s), so an allOf child also maps its inherited attributes + # (the child's own declaration wins on a name clash); acceptable_attribute_map + # is what the initializer accepts, so a subclass that narrows attribute_map + # is not handed attributes it rejects + map = acceptable_attribute_map types = openapi_types - map = attribute_map klass = superclass while klass.respond_to?(:openapi_types) types = klass.openapi_types.merge(types) - map = klass.attribute_map.merge(map) klass = klass.superclass end transformed_hash = {} types.each_pair do |key, type| + next unless map.key?(key) if attributes.key?(map[key]) && attributes[map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i @@ -132,17 +134,18 @@ def self.build_from_hash(attributes) # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash - # collect the attributes this model knows about, including the ones defined + # serialize the attributes this model knows about, including the ones defined # in its parent(s): attribute_map and openapi_nullable resolve to the child # class in every ancestor frame, so the inherited super chain only repeated # the child's own attributes and dropped the inherited ones - map = self.class.attribute_map + map = self.class.acceptable_attribute_map nullable = self.class.openapi_nullable + declared = self.class.attribute_map.keys klass = self.class.superclass while klass.respond_to?(:openapi_types) # an ancestor's nullability only applies to attributes no nearer class redeclares - nullable |= klass.openapi_nullable & (klass.attribute_map.keys - map.keys) - map = klass.attribute_map.merge(map) + nullable |= klass.openapi_nullable & (klass.attribute_map.keys - declared) + declared |= klass.attribute_map.keys klass = klass.superclass end hash = {}