From c9da4c720eafafc75257429d49f05a319418cb26 Mon Sep 17 00:00:00 2001 From: Charlie Zhang Date: Wed, 17 Jun 2026 11:24:25 -0400 Subject: [PATCH] fix: copy typed fields to additional_properties in build_from_hash build_from_hash (used by the API client deserializer) only routed unknown fields to additional_properties; typed fields were set via their accessors but never mirrored into the AP hash. initialize() already has the per-field copy, but build_from_hash calls new() with no args so that copy ran against an empty attributes hash. Add a loop in build_from_hash that copies each typed field that was present in the JSON attributes into additional_properties after deserialization, matching the behaviour of initialize(). Applied to both v1 and v2 model_base.rb. Co-Authored-By: Claude Sonnet 4.6 --- lib/datadog_api_client/v1/model_base.rb | 5 +++++ lib/datadog_api_client/v2/model_base.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/datadog_api_client/v1/model_base.rb b/lib/datadog_api_client/v1/model_base.rb index 203568f08509..d56c5b331d47 100644 --- a/lib/datadog_api_client/v1/model_base.rb +++ b/lib/datadog_api_client/v1/model_base.rb @@ -83,6 +83,11 @@ def build_from_hash(attributes) end if self.respond_to?(:additional_properties) + self.class.openapi_types.each_key do |key| + json_key = self.class.attribute_map[key] + next unless json_key && attributes.key?(json_key) + self.additional_properties[json_key] = self.send(key) + end attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) self.additional_properties[k.to_sym] = v diff --git a/lib/datadog_api_client/v2/model_base.rb b/lib/datadog_api_client/v2/model_base.rb index 7bdfde0c6bcd..357c5187628e 100644 --- a/lib/datadog_api_client/v2/model_base.rb +++ b/lib/datadog_api_client/v2/model_base.rb @@ -83,6 +83,11 @@ def build_from_hash(attributes) end if self.respond_to?(:additional_properties) + self.class.openapi_types.each_key do |key| + json_key = self.class.attribute_map[key] + next unless json_key && attributes.key?(json_key) + self.additional_properties[json_key] = self.send(key) + end attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) self.additional_properties[k.to_sym] = v