Skip to content

Commit 1fa1b30

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit 3677df7 of spec repo (#4482)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent dd03c66 commit 1fa1b30

6 files changed

Lines changed: 96 additions & 36 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:

packages/datadog-api-client-v1/models/ObjectSerializer.ts

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3339,31 +3339,52 @@ export class ObjectSerializer {
33393339

33403340
const instance = new typeMap[type]();
33413341
const attributesMap = typeMap[type].getAttributeTypeMap();
3342-
const attributesBaseNames = Object.keys(attributesMap).reduce(
3343-
(o, key) => Object.assign(o, { [attributesMap[key].baseName]: "" }),
3344-
{}
3345-
);
3342+
const keepAllInAdditional =
3343+
(typeMap[type] as any)._keepTypedInAdditionalProperties === true;
3344+
// Single pass: build attributesBaseNames (for extra-key detection) and, when needed,
3345+
// baseNameToAttr (for per-field typed deserialization preserving int64 precision).
3346+
const attributesBaseNames: { [key: string]: string } = {};
3347+
const baseNameToAttr: { [key: string]: any } = {};
3348+
for (const attrName in attributesMap) {
3349+
const baseName = attributesMap[attrName].baseName;
3350+
attributesBaseNames[baseName] = "";
3351+
if (keepAllInAdditional && attrName !== "additionalProperties") {
3352+
baseNameToAttr[baseName] = attributesMap[attrName];
3353+
}
3354+
}
33463355
const extraAttributes = Object.keys(data).filter(
3347-
(key) => !Object.prototype.hasOwnProperty.call(attributesBaseNames, key)
3356+
(key) =>
3357+
keepAllInAdditional ||
3358+
!Object.prototype.hasOwnProperty.call(attributesBaseNames, key)
33483359
);
33493360

33503361
if (extraAttributes.length > 0) {
33513362
if ("additionalProperties" in attributesMap) {
3352-
if (!instance.additionalProperties) {
3353-
instance.additionalProperties = {};
3354-
}
3355-
33563363
const additionalProperties: { [key: string]: any } = {};
3357-
for (const key of extraAttributes) {
3358-
additionalProperties[key] = data[key];
3364+
if (keepAllInAdditional) {
3365+
for (const key of extraAttributes) {
3366+
const attrInfo = baseNameToAttr[key];
3367+
// Use per-field type/format for typed attrs to preserve int64 precision.
3368+
additionalProperties[key] = attrInfo
3369+
? ObjectSerializer.deserialize(
3370+
data[key],
3371+
attrInfo.type,
3372+
attrInfo.format
3373+
)
3374+
: data[key];
3375+
}
3376+
instance.additionalProperties = additionalProperties;
3377+
} else {
3378+
for (const key of extraAttributes) {
3379+
additionalProperties[key] = data[key];
3380+
}
3381+
const attributeObj = attributesMap["additionalProperties"];
3382+
instance.additionalProperties = ObjectSerializer.deserialize(
3383+
additionalProperties,
3384+
attributeObj.type,
3385+
attributeObj.format
3386+
);
33593387
}
3360-
3361-
const attributeObj = attributesMap["additionalProperties"];
3362-
instance.additionalProperties = ObjectSerializer.deserialize(
3363-
additionalProperties,
3364-
attributeObj.type,
3365-
attributeObj.format
3366-
);
33673388
} else {
33683389
throw new Error(
33693390
`found extra attributes '${extraAttributes}' in ${type}`

packages/datadog-api-client-v1/models/UsageSummaryDate.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,11 @@ export class UsageSummaryDate {
12691269
*/
12701270
"_unparsed"?: boolean;
12711271

1272+
/**
1273+
* @ignore
1274+
*/
1275+
static readonly _keepTypedInAdditionalProperties = true;
1276+
12721277
/**
12731278
* @ignore
12741279
*/

packages/datadog-api-client-v1/models/UsageSummaryDateOrg.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,11 @@ export class UsageSummaryDateOrg {
12921292
*/
12931293
"_unparsed"?: boolean;
12941294

1295+
/**
1296+
* @ignore
1297+
*/
1298+
static readonly _keepTypedInAdditionalProperties = true;
1299+
12951300
/**
12961301
* @ignore
12971302
*/

packages/datadog-api-client-v1/models/UsageSummaryResponse.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,11 @@ export class UsageSummaryResponse {
13151315
*/
13161316
"_unparsed"?: boolean;
13171317

1318+
/**
1319+
* @ignore
1320+
*/
1321+
static readonly _keepTypedInAdditionalProperties = true;
1322+
13181323
/**
13191324
* @ignore
13201325
*/

packages/datadog-api-client-v2/models/ObjectSerializer.ts

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14839,31 +14839,52 @@ export class ObjectSerializer {
1483914839

1484014840
const instance = new typeMap[type]();
1484114841
const attributesMap = typeMap[type].getAttributeTypeMap();
14842-
const attributesBaseNames = Object.keys(attributesMap).reduce(
14843-
(o, key) => Object.assign(o, { [attributesMap[key].baseName]: "" }),
14844-
{}
14845-
);
14842+
const keepAllInAdditional =
14843+
(typeMap[type] as any)._keepTypedInAdditionalProperties === true;
14844+
// Single pass: build attributesBaseNames (for extra-key detection) and, when needed,
14845+
// baseNameToAttr (for per-field typed deserialization preserving int64 precision).
14846+
const attributesBaseNames: { [key: string]: string } = {};
14847+
const baseNameToAttr: { [key: string]: any } = {};
14848+
for (const attrName in attributesMap) {
14849+
const baseName = attributesMap[attrName].baseName;
14850+
attributesBaseNames[baseName] = "";
14851+
if (keepAllInAdditional && attrName !== "additionalProperties") {
14852+
baseNameToAttr[baseName] = attributesMap[attrName];
14853+
}
14854+
}
1484614855
const extraAttributes = Object.keys(data).filter(
14847-
(key) => !Object.prototype.hasOwnProperty.call(attributesBaseNames, key)
14856+
(key) =>
14857+
keepAllInAdditional ||
14858+
!Object.prototype.hasOwnProperty.call(attributesBaseNames, key)
1484814859
);
1484914860

1485014861
if (extraAttributes.length > 0) {
1485114862
if ("additionalProperties" in attributesMap) {
14852-
if (!instance.additionalProperties) {
14853-
instance.additionalProperties = {};
14854-
}
14855-
1485614863
const additionalProperties: { [key: string]: any } = {};
14857-
for (const key of extraAttributes) {
14858-
additionalProperties[key] = data[key];
14864+
if (keepAllInAdditional) {
14865+
for (const key of extraAttributes) {
14866+
const attrInfo = baseNameToAttr[key];
14867+
// Use per-field type/format for typed attrs to preserve int64 precision.
14868+
additionalProperties[key] = attrInfo
14869+
? ObjectSerializer.deserialize(
14870+
data[key],
14871+
attrInfo.type,
14872+
attrInfo.format
14873+
)
14874+
: data[key];
14875+
}
14876+
instance.additionalProperties = additionalProperties;
14877+
} else {
14878+
for (const key of extraAttributes) {
14879+
additionalProperties[key] = data[key];
14880+
}
14881+
const attributeObj = attributesMap["additionalProperties"];
14882+
instance.additionalProperties = ObjectSerializer.deserialize(
14883+
additionalProperties,
14884+
attributeObj.type,
14885+
attributeObj.format
14886+
);
1485914887
}
14860-
14861-
const attributeObj = attributesMap["additionalProperties"];
14862-
instance.additionalProperties = ObjectSerializer.deserialize(
14863-
additionalProperties,
14864-
attributeObj.type,
14865-
attributeObj.format
14866-
);
1486714888
} else {
1486814889
throw new Error(
1486914890
`found extra attributes '${extraAttributes}' in ${type}`

0 commit comments

Comments
 (0)