Skip to content

Commit 889b87f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Ensure clients can handle empty oneOf objects (#1830)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 71984dc commit 889b87f

File tree

5 files changed

+182
-4
lines changed

5 files changed

+182
-4
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": "2024-09-30 13:57:00.510111",
8-
"spec_repo_commit": "eb66b1cf"
7+
"regenerated": "2024-09-30 14:37:34.279249",
8+
"spec_repo_commit": "60bc9127"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-09-30 13:57:00.525119",
13-
"spec_repo_commit": "eb66b1cf"
12+
"regenerated": "2024-09-30 14:37:34.293454",
13+
"spec_repo_commit": "60bc9127"
1414
}
1515
}
1616
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2024-09-24T19:19:31.807Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Clients deserialize a dashboard with a empty time object",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "25f142c77556d0a07f60c9aea7b1aa17",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 550,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 559,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"layout_type\":\"ordered\",\"title\":\"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571\",\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 976,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 976,
45+
"text": "{\"id\":\"han-5zg-c32\",\"title\":\"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571\",\"description\":null,\"author_handle\":\"[email protected]\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/han-5zg-c32/test-clientsdeserializeadashboardwithaemptytimeobject-1727205571\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"},\"id\":4274057372149908}],\"notify_list\":null,\"created_at\":\"2024-09-24T19:19:32.071328+00:00\",\"modified_at\":\"2024-09-24T19:19:32.071328+00:00\",\"experience_type\":\"default\",\"restricted_roles\":[]}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 657,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2024-09-24T19:19:31.819Z",
61+
"time": 291
62+
},
63+
{
64+
"_id": "9350b5ff5d55807a27b71a985a5d0edd",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 520,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/dashboard/han-5zg-c32"
82+
},
83+
"response": {
84+
"bodySize": 39,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 39,
88+
"text": "{\"deleted_dashboard_id\":\"han-5zg-c32\"}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 656,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2024-09-24T19:19:32.127Z",
104+
"time": 172
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Clients deserialize a dashboard with a empty time object
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.DashboardsApi(configuration);
9+
10+
const params: v1.DashboardsApiCreateDashboardRequest = {
11+
body: {
12+
title: "Example-Dashboard",
13+
widgets: [
14+
{
15+
definition: {
16+
title: "Example Cloud Cost Query",
17+
titleSize: "16",
18+
titleAlign: "left",
19+
type: "timeseries",
20+
requests: [
21+
{
22+
formulas: [
23+
{
24+
formula: "query1",
25+
},
26+
],
27+
queries: [
28+
{
29+
dataSource: "cloud_cost",
30+
name: "query1",
31+
query:
32+
"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)",
33+
},
34+
],
35+
responseFormat: "timeseries",
36+
style: {
37+
palette: "dog_classic",
38+
lineType: "solid",
39+
lineWidth: "normal",
40+
},
41+
displayType: "bars",
42+
},
43+
],
44+
time: {},
45+
},
46+
},
47+
],
48+
layoutType: "ordered",
49+
},
50+
};
51+
52+
apiInstance
53+
.createDashboard(params)
54+
.then((data: v1.Dashboard) => {
55+
console.log(
56+
"API called successfully. Returned data: " + JSON.stringify(data)
57+
);
58+
})
59+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ Feature: Dashboards
99
And a valid "appKeyAuth" key in the system
1010
And an instance of "Dashboards" API
1111

12+
@replay-only @team:DataDog/dashboards-backend
13+
Scenario: Clients deserialize a dashboard with a empty time object
14+
Given new "CreateDashboard" request
15+
And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "Example Cloud Cost Query", "title_size": "16", "title_align": "left", "type": "timeseries", "requests": [ { "formulas": [ { "formula": "query1" } ], "queries": [ { "data_source": "cloud_cost", "name": "query1", "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)" } ], "response_format": "timeseries", "style": { "palette": "dog_classic", "line_type": "solid", "line_width": "normal" }, "display_type": "bars" } ], "time": {} } } ], "layout_type": "ordered" }
16+
When the request is sent
17+
Then the response status is 200 OK
18+
And the response "widgets[0].definition.time" is equal to {}
19+
1220
@team:DataDog/dashboards-backend
1321
Scenario: Create a distribution widget using a histogram request containing a formulas and functions APM Stats query
1422
Given new "CreateDashboard" request

0 commit comments

Comments
 (0)