Skip to content

Commit fce8d6d

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Make assertion target be int or string (#2859)
* fix value generation * add support for double and other edge cases * Regenerate client from commit 11a9dcb4 of spec repo --------- Co-authored-by: Sherzod Karimov <sherzod.karimov@datadoghq.com> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 63ce0a5 commit fce8d6d

20 files changed

+415
-73
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-05-20 07:21:26.115507",
8-
"spec_repo_commit": "fec20f97"
7+
"regenerated": "2025-05-23 12:48:19.641798",
8+
"spec_repo_commit": "11a9dcb4"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-20 07:21:26.131253",
13-
"spec_repo_commit": "fec20f97"
12+
"regenerated": "2025-05-23 12:48:19.657459",
13+
"spec_repo_commit": "11a9dcb4"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14221,8 +14221,8 @@ components:
1422114221
operator:
1422214222
$ref: '#/components/schemas/SyntheticsAssertionBodyHashOperator'
1422314223
target:
14224+
$ref: '#/components/schemas/SyntheticsAssertionTargetValue'
1422414225
description: Value used by the operator.
14225-
example: 123456
1422614226
type:
1422714227
$ref: '#/components/schemas/SyntheticsAssertionBodyHashType'
1422814228
required:
@@ -14278,6 +14278,7 @@ components:
1427814278
description: The specific operator to use on the path.
1427914279
type: string
1428014280
targetValue:
14281+
$ref: '#/components/schemas/SyntheticsAssertionTargetValue'
1428114282
description: The path target value to compare to.
1428214283
type: object
1428314284
SyntheticsAssertionJSONSchemaMetaSchema:
@@ -14385,8 +14386,8 @@ components:
1438514386
description: The associated assertion property.
1438614387
type: string
1438714388
target:
14389+
$ref: '#/components/schemas/SyntheticsAssertionTargetValue'
1438814390
description: Value used by the operator.
14389-
example: 123456
1439014391
timingsScope:
1439114392
$ref: '#/components/schemas/SyntheticsAssertionTimingsScope'
1439214393
type:
@@ -14396,6 +14397,20 @@ components:
1439614397
- operator
1439714398
- target
1439814399
type: object
14400+
SyntheticsAssertionTargetValue:
14401+
description: Value used by the operator in assertions. Can be either a number
14402+
or string.
14403+
oneOf:
14404+
- $ref: '#/components/schemas/SyntheticsAssertionTargetValueNumber'
14405+
- $ref: '#/components/schemas/SyntheticsAssertionTargetValueString'
14406+
SyntheticsAssertionTargetValueNumber:
14407+
description: Numeric value used by the operator in assertions.
14408+
format: double
14409+
type: number
14410+
SyntheticsAssertionTargetValueString:
14411+
description: String value used by the operator in assertions. Supports templated
14412+
variables.
14413+
type: string
1439914414
SyntheticsAssertionTimingsScope:
1440014415
description: Timings scope for response time assertions.
1440114416
enum:
@@ -14480,6 +14495,7 @@ components:
1448014495
description: The specific operator to use on the path.
1448114496
type: string
1448214497
targetValue:
14498+
$ref: '#/components/schemas/SyntheticsAssertionTargetValue'
1448314499
description: The path target value to compare to.
1448414500
xPath:
1448514501
description: The X path to assert.

.generator/src/generator/formatter.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,25 @@ def format_data_with_schema(
383383
else:
384384

385385
def format_number(x):
386-
if isinstance(x, bool):
386+
if isinstance(x, bool | str):
387387
raise TypeError(f"{x} is not supported type {schema}")
388388
return str(x)
389389

390390
def format_double(x):
391-
if isinstance(x, bool):
391+
if isinstance(x, bool | str):
392392
raise TypeError(f"{x} is not supported type {schema}")
393393
return float(x)
394394

395+
def format_int(x):
396+
if isinstance(x, bool | str):
397+
raise TypeError(f"{x} is not supported type {schema}")
398+
return str(x)
399+
400+
def format_int64(x):
401+
if isinstance(x, bool | str):
402+
raise TypeError(f"{x} is not supported type {schema}")
403+
return str(x) + "L"
404+
395405
def format_string(x):
396406
if isinstance(x, bool):
397407
raise TypeError(f"{x} is not supported type {schema}")
@@ -425,8 +435,8 @@ def open_file(x):
425435
return f"new File({format_string(x)})"
426436

427437
formatters = {
428-
"int32": lambda x: str(int(x)),
429-
"int64": lambda x: str(int(x)) + "L",
438+
"int32": format_int,
439+
"int64": format_int64,
430440
"double": format_double,
431441
"date-time": format_datetime,
432442
"number": format_number,

examples/v1/synthetics/CreateSyntheticsAPITest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.datadog.api.client.v1.model.SyntheticsAssertion;
1010
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
1111
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
12+
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
1213
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
1314
import com.datadog.api.client.v1.model.SyntheticsBrowserTestRumSettings;
1415
import com.datadog.api.client.v1.model.SyntheticsTestCiOptions;
@@ -40,7 +41,7 @@ public static void main(String[] args) {
4041
new SyntheticsAssertion(
4142
new SyntheticsAssertionTarget()
4243
.operator(SyntheticsAssertionOperator.LESS_THAN)
43-
.target(1000)
44+
.target(new SyntheticsAssertionTargetValue(1000.0))
4445
.type(SyntheticsAssertionType.RESPONSE_TIME))))
4546
.request(new SyntheticsTestRequest().method("GET").url("https://example.com")))
4647
.locations(Collections.singletonList("aws:eu-west-3"))

examples/v1/synthetics/CreateSyntheticsAPITest_1072503741.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.datadog.api.client.v1.model.SyntheticsAssertion;
1010
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
1111
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
12+
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
1213
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
1314
import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType;
1415
import com.datadog.api.client.v1.model.SyntheticsTestOptions;
@@ -30,7 +31,7 @@ public static void main(String[] args) {
3031
new SyntheticsAssertion(
3132
new SyntheticsAssertionTarget()
3233
.operator(SyntheticsAssertionOperator.IS_IN_MORE_DAYS_THAN)
33-
.target(10)
34+
.target(new SyntheticsAssertionTargetValue(10.0))
3435
.type(SyntheticsAssertionType.CERTIFICATE))))
3536
.request(
3637
new SyntheticsTestRequest()

examples/v1/synthetics/CreateSyntheticsAPITest_1241981394.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.datadog.api.client.v1.model.SyntheticsAssertionJSONPathTargetTarget;
1313
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
1414
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
15+
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
1516
import com.datadog.api.client.v1.model.SyntheticsAssertionTimingsScope;
1617
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
1718
import com.datadog.api.client.v1.model.SyntheticsAssertionXPathOperator;
@@ -52,12 +53,12 @@ public static void main(String[] args) {
5253
new SyntheticsAssertionTarget()
5354
.operator(SyntheticsAssertionOperator.IS)
5455
.property("{{ PROPERTY }}")
55-
.target("text/html")
56+
.target(new SyntheticsAssertionTargetValue("text/html"))
5657
.type(SyntheticsAssertionType.HEADER)),
5758
new SyntheticsAssertion(
5859
new SyntheticsAssertionTarget()
5960
.operator(SyntheticsAssertionOperator.LESS_THAN)
60-
.target(2000)
61+
.target(new SyntheticsAssertionTargetValue(2000.0))
6162
.type(SyntheticsAssertionType.RESPONSE_TIME)
6263
.timingsScope(SyntheticsAssertionTimingsScope.WITHOUT_DNS)),
6364
new SyntheticsAssertion(
@@ -68,15 +69,15 @@ public static void main(String[] args) {
6869
new SyntheticsAssertionJSONPathTargetTarget()
6970
.jsonPath("topKey")
7071
.operator("isNot")
71-
.targetValue("0"))
72+
.targetValue(new SyntheticsAssertionTargetValue("0")))
7273
.type(SyntheticsAssertionType.BODY)),
7374
new SyntheticsAssertion(
7475
new SyntheticsAssertionXPathTarget()
7576
.operator(SyntheticsAssertionXPathOperator.VALIDATES_X_PATH)
7677
.target(
7778
new SyntheticsAssertionXPathTargetTarget()
7879
.xPath("target-xpath")
79-
.targetValue("0")
80+
.targetValue(new SyntheticsAssertionTargetValue("0"))
8081
.operator("contains"))
8182
.type(SyntheticsAssertionType.BODY))))
8283
.configVariables(

examples/v1/synthetics/CreateSyntheticsAPITest_1279271422.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.datadog.api.client.v1.model.SyntheticsAssertion;
1515
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
1616
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
17+
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
1718
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
1819
import com.datadog.api.client.v1.model.SyntheticsConfigVariable;
1920
import com.datadog.api.client.v1.model.SyntheticsConfigVariableType;
@@ -59,7 +60,9 @@ public static void main(String[] args) {
5960
new SyntheticsAssertionTarget()
6061
.operator(SyntheticsAssertionOperator.IS)
6162
.type(SyntheticsAssertionType.STATUS_CODE)
62-
.target(200))))
63+
.target(
64+
new SyntheticsAssertionTargetValue(
65+
200.0)))))
6366
.exitIfSucceed(true)
6467
.extractedValues(
6568
Collections.singletonList(
@@ -106,7 +109,9 @@ public static void main(String[] args) {
106109
new SyntheticsAssertionTarget()
107110
.operator(SyntheticsAssertionOperator.LESS_THAN)
108111
.type(SyntheticsAssertionType.RESPONSE_TIME)
109-
.target(1000))))
112+
.target(
113+
new SyntheticsAssertionTargetValue(
114+
1000.0)))))
110115
.request(
111116
new SyntheticsTestRequest()
112117
.host("grpcbin.test.k6.io")

examples/v1/synthetics/CreateSyntheticsAPITest_1402674167.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.datadog.api.client.v1.model.SyntheticsAssertion;
1010
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
1111
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
12+
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
1213
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
1314
import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType;
1415
import com.datadog.api.client.v1.model.SyntheticsTestOptions;
@@ -33,17 +34,17 @@ public static void main(String[] args) {
3334
new SyntheticsAssertion(
3435
new SyntheticsAssertionTarget()
3536
.operator(SyntheticsAssertionOperator.IS)
36-
.target(1)
37+
.target(new SyntheticsAssertionTargetValue(1.0))
3738
.type(SyntheticsAssertionType.GRPC_HEALTHCHECK_STATUS)),
3839
new SyntheticsAssertion(
3940
new SyntheticsAssertionTarget()
4041
.operator(SyntheticsAssertionOperator.IS)
41-
.target("proto target")
42+
.target(new SyntheticsAssertionTargetValue("proto target"))
4243
.type(SyntheticsAssertionType.GRPC_PROTO)),
4344
new SyntheticsAssertion(
4445
new SyntheticsAssertionTarget()
4546
.operator(SyntheticsAssertionOperator.IS)
46-
.target("123")
47+
.target(new SyntheticsAssertionTargetValue("123"))
4748
.property("property")
4849
.type(SyntheticsAssertionType.GRPC_METADATA))))
4950
.request(

examples/v1/synthetics/CreateSyntheticsAPITest_1487281163.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.datadog.api.client.v1.model.SyntheticsAssertionJavascriptType;
2222
import com.datadog.api.client.v1.model.SyntheticsAssertionOperator;
2323
import com.datadog.api.client.v1.model.SyntheticsAssertionTarget;
24+
import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue;
2425
import com.datadog.api.client.v1.model.SyntheticsAssertionTimingsScope;
2526
import com.datadog.api.client.v1.model.SyntheticsAssertionType;
2627
import com.datadog.api.client.v1.model.SyntheticsAssertionXPathOperator;
@@ -59,12 +60,12 @@ public static void main(String[] args) {
5960
new SyntheticsAssertionTarget()
6061
.operator(SyntheticsAssertionOperator.IS)
6162
.property("{{ PROPERTY }}")
62-
.target("text/html")
63+
.target(new SyntheticsAssertionTargetValue("text/html"))
6364
.type(SyntheticsAssertionType.HEADER)),
6465
new SyntheticsAssertion(
6566
new SyntheticsAssertionTarget()
6667
.operator(SyntheticsAssertionOperator.LESS_THAN)
67-
.target(2000)
68+
.target(new SyntheticsAssertionTargetValue(2000.0))
6869
.type(SyntheticsAssertionType.RESPONSE_TIME)
6970
.timingsScope(SyntheticsAssertionTimingsScope.WITHOUT_DNS)),
7071
new SyntheticsAssertion(
@@ -75,7 +76,7 @@ public static void main(String[] args) {
7576
new SyntheticsAssertionJSONPathTargetTarget()
7677
.jsonPath("topKey")
7778
.operator("isNot")
78-
.targetValue("0"))
79+
.targetValue(new SyntheticsAssertionTargetValue("0")))
7980
.type(SyntheticsAssertionType.BODY)),
8081
new SyntheticsAssertion(
8182
new SyntheticsAssertionJSONPathTarget()
@@ -86,7 +87,7 @@ public static void main(String[] args) {
8687
.elementsOperator("atLeastOneElementMatches")
8788
.jsonPath("topKey")
8889
.operator("isNot")
89-
.targetValue("0"))
90+
.targetValue(new SyntheticsAssertionTargetValue("0")))
9091
.type(SyntheticsAssertionType.BODY)),
9192
new SyntheticsAssertion(
9293
new SyntheticsAssertionJSONSchemaTarget()
@@ -107,13 +108,13 @@ public static void main(String[] args) {
107108
.target(
108109
new SyntheticsAssertionXPathTargetTarget()
109110
.xPath("target-xpath")
110-
.targetValue("0")
111+
.targetValue(new SyntheticsAssertionTargetValue("0"))
111112
.operator("contains"))
112113
.type(SyntheticsAssertionType.BODY)),
113114
new SyntheticsAssertion(
114115
new SyntheticsAssertionBodyHashTarget()
115116
.operator(SyntheticsAssertionBodyHashOperator.MD5)
116-
.target("a")
117+
.target(new SyntheticsAssertionTargetValue("a"))
117118
.type(SyntheticsAssertionBodyHashType.BODY_HASH)),
118119
new SyntheticsAssertion(
119120
new SyntheticsAssertionJavascript()

0 commit comments

Comments
 (0)