Skip to content

Commit 3066b70

Browse files
api-clients-generation-pipeline[bot]charlie-zhang109claudeci.datadog-api-spec
authored
Set x-keep-typed-in-additional-properties on UsageSummary schemas (#1760)
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 b75a255 commit 3066b70

5 files changed

Lines changed: 25 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_simple.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ impl<'de> Deserialize<'de> for {{ name }} {
118118
let mut _unparsed = false;
119119

120120
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
121+
{%- if additionalProperties != false and model.get("x-keep-typed-in-additional-properties") %}
122+
// from_value::<serde_json::Value> is infallible so Ok always fires;
123+
// for typed AP schemas a type mismatch silently drops the entry (same as the catch-all arm).
124+
if let Ok(ap_value) = serde_json::from_value(v.clone()) {
125+
additional_properties.insert(k.clone(), ap_value);
126+
}
127+
{%- endif %}
121128
match k.as_str() {
122129
{%- for attr, schema in model.get("properties", {}).items() %}
123130
{%- set required = attr in model.required %}

src/datadogV1/model/model_usage_summary_date.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3483,6 +3483,11 @@ impl<'de> Deserialize<'de> for UsageSummaryDate {
34833483
let mut _unparsed = false;
34843484

34853485
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
3486+
// from_value::<serde_json::Value> is infallible so Ok always fires;
3487+
// for typed AP schemas a type mismatch silently drops the entry (same as the catch-all arm).
3488+
if let Ok(ap_value) = serde_json::from_value(v.clone()) {
3489+
additional_properties.insert(k.clone(), ap_value);
3490+
}
34863491
match k.as_str() {
34873492
"agent_host_top99p" => {
34883493
if v.is_null() {

src/datadogV1/model/model_usage_summary_date_org.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,6 +3550,11 @@ impl<'de> Deserialize<'de> for UsageSummaryDateOrg {
35503550
let mut _unparsed = false;
35513551

35523552
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
3553+
// from_value::<serde_json::Value> is infallible so Ok always fires;
3554+
// for typed AP schemas a type mismatch silently drops the entry (same as the catch-all arm).
3555+
if let Ok(ap_value) = serde_json::from_value(v.clone()) {
3556+
additional_properties.insert(k.clone(), ap_value);
3557+
}
35533558
match k.as_str() {
35543559
"account_name" => {
35553560
if v.is_null() {

src/datadogV1/model/model_usage_summary_response.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,6 +3634,11 @@ impl<'de> Deserialize<'de> for UsageSummaryResponse {
36343634
let mut _unparsed = false;
36353635

36363636
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
3637+
// from_value::<serde_json::Value> is infallible so Ok always fires;
3638+
// for typed AP schemas a type mismatch silently drops the entry (same as the catch-all arm).
3639+
if let Ok(ap_value) = serde_json::from_value(v.clone()) {
3640+
additional_properties.insert(k.clone(), ap_value);
3641+
}
36373642
match k.as_str() {
36383643
"agent_host_top99p_sum" => {
36393644
if v.is_null() {

0 commit comments

Comments
 (0)