[pull] master from DataDog:master#416
Merged
Merged
Conversation
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
…3500) * 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 <noreply@anthropic.com> * fix: update model_base.j2 template and add deserialization tests - Apply same build_from_hash typed-fields-to-additional_properties fix to the generator template so regenerated files stay correct - Add two unit tests for the new behavior using UsageSummaryResponse Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: use symbol keys in tests and replace each_with_object dead code - Test hashes now use symbol keys to match what the real API client passes after JSON.parse(..., symbolize_names: true) - Replace each_with_object({}) (accumulator never written) with plain each in v1/v2 model_base.rb and the generator template Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: store raw attribute values in additional_properties instead of deserialized objects The previous approach stored `self.send(key)` (the deserialized Ruby object, potentially an `UnparsedObject`) into `additional_properties`. The generated `to_hash` in models with additional_properties then outputs AP values without calling `_to_hash`, overwriting the correctly-converted typed field values with raw Ruby objects. This caused `lookup` traversal to encounter `UnparsedObject` instead of a plain Hash when accessing nested fields, raising NoMethodError. Store `attributes[json_key]` (the raw JSON value) instead, matching what `initialize` already does for unknown fields. This preserves AP accessibility for typed fields while keeping `to_hash` output correct. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: mirror typed fields into additional_properties only for x-keep-typed-in-additional-properties models Reverts the generic model_base.rb approach (which broke pagination by overwriting cursor updates with stale AP values) and instead adds a build_from_hash override only in models that declare x-keep-typed-in-additional-properties. The override calls super to set typed fields, then mirrors them into additional_properties via a json_key loop — matching the existing initialize pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )