Skip to content

Commit c8385e3

Browse files
api-clients-generation-pipeline[bot]charlie-zhang109claudeci.datadog-api-spec
authored
Set x-keep-typed-in-additional-properties on UsageSummary schemas (#3493)
* Support x-keep-typed-in-additional-properties in Ruby model generator When a schema sets `x-keep-typed-in-additional-properties: true`, also add typed property keys to `additional_properties` so all fields are accessible from a single map regardless of when they were added to the spec. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: copy typed fields into additional_properties after coercion, not before The previous approach stored the raw pre-coercion hash value. After setters run, self.attr_name holds the coerced value. We now copy post-coercion so both access paths return consistent types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Regenerate client from commit 3677df7 of spec repo --------- Co-authored-by: Charlie Zhang <charlie.zhang@datadoghq.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent f672b6d commit c8385e3

5 files changed

Lines changed: 928 additions & 0 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24110,6 +24110,7 @@ components:
2411024110
format: int64
2411124111
type: integer
2411224112
type: object
24113+
x-keep-typed-in-additional-properties: true
2411324114
UsageSummaryDateOrg:
2411424115
description: |-
2411524116
Global hourly report of all data billed by Datadog for a given organization.
@@ -25429,6 +25430,7 @@ components:
2542925430
format: int64
2543025431
type: integer
2543125432
type: object
25433+
x-keep-typed-in-additional-properties: true
2543225434
UsageSummaryResponse:
2543325435
description: |-
2543425436
Response summarizing all usage aggregated across the months in the request for
@@ -26776,6 +26778,7 @@ components:
2677626778
format: int64
2677726779
type: integer
2677826780
type: object
26781+
x-keep-typed-in-additional-properties: true
2677926782
UsageSyntheticsAPIHour:
2678026783
description: Number of Synthetics API tests run for each hour for a given organization.
2678126784
properties:

.generator/src/generator/templates/model_generic.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
{%- endif %}
102102
end
103103
{%- endfor %}
104+
{%- if model.get("x-keep-typed-in-additional-properties") %}
105+
{%- for attr, definition in model.get("properties", {}).items() %}
106+
self.additional_properties[:'{{ attr|attribute_name }}'] = self.{{ attr|attribute_name }} if attributes.key?(:'{{ attr|attribute_name }}')
107+
{%- endfor %}
108+
{%- endif %}
104109
end
105110

106111
{%- set ns = namespace(hasValidation=False) %}

0 commit comments

Comments
 (0)