Skip to content

Commit 138026d

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Unskip dashboard test for typescript client (#863)
* escape reserved keywords in bdd * Regenerate client from commit e6eb3136 of spec repo Co-authored-by: Sherzod Karimov <[email protected]> Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: skarimo <[email protected]>
1 parent 3af2d25 commit 138026d

File tree

3 files changed

+76
-7
lines changed

3 files changed

+76
-7
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.4",
7-
"regenerated": "2022-09-29 15:48:27.293105",
8-
"spec_repo_commit": "e57e3c55"
7+
"regenerated": "2022-09-30 11:29:35.529283",
8+
"spec_repo_commit": "e6eb3136"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-09-29 15:48:27.304947",
13-
"spec_repo_commit": "e57e3c55"
12+
"regenerated": "2022-09-30 11:29:35.549126",
13+
"spec_repo_commit": "e6eb3136"
1414
}
1515
}
1616
}

features/support/templating.ts

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,70 @@ const templateFunctions: { [key: string]: any } = {
1515
timestamp: relativeTime(false),
1616
};
1717

18+
const reservedKeywords: string[] = [
19+
"abstract",
20+
"await",
21+
"boolean",
22+
"break",
23+
"byte",
24+
"case",
25+
"catch",
26+
"char",
27+
"class",
28+
"const",
29+
"continue",
30+
"debugger",
31+
"default",
32+
"delete",
33+
"do",
34+
"double",
35+
"else",
36+
"enum",
37+
"export",
38+
"extends",
39+
"false",
40+
"final",
41+
"finally",
42+
"float",
43+
"for",
44+
"function",
45+
"goto",
46+
"if",
47+
"implements",
48+
"import",
49+
"in",
50+
"instanceof",
51+
"int",
52+
"interface",
53+
"let",
54+
"long",
55+
"native",
56+
"new",
57+
"null",
58+
"package",
59+
"private",
60+
"protected",
61+
"public",
62+
"return",
63+
"short",
64+
"static",
65+
"super",
66+
"switch",
67+
"synchronized",
68+
"this",
69+
"throw",
70+
"transient",
71+
"true",
72+
"try",
73+
"typeof",
74+
"var",
75+
"void",
76+
"volatile",
77+
"while",
78+
"with",
79+
"yield",
80+
];
81+
1882
function relativeTime(iso: boolean): any {
1983
const timeRE = /now( *([+-]) *(\d+)([smhdMy]))?/;
2084
return (data: any, arg: string): string => {
@@ -68,7 +132,10 @@ function pathLookup(data: any, dottedPath: string): any {
68132
result = value[part];
69133
} else if (part.toAttributeName() in value) {
70134
result = value[part.toAttributeName()];
71-
} else if ("unparsedObject" in value && part in value["unparsedObject"]) {
135+
} else if (
136+
"unparsedObject" in value &&
137+
part in value["unparsedObject"]
138+
) {
72139
result = value["unparsedObject"][part];
73140
} else {
74141
throw new Error(
@@ -105,11 +172,13 @@ String.prototype.toOperationName = function (): string {
105172
};
106173

107174
String.prototype.toAttributeName = function (): string {
108-
return String(this)
175+
const attrName: string = String(this)
109176
.replace(/[^A-Za-z0-9]+(.)/g, function (...matches) {
110177
return matches[1].toUpperCase();
111178
})
112179
.replace(/[^A-Za-z0-9]+/g, "");
180+
181+
return reservedKeywords.includes(attrName) ? `_${attrName}` : attrName;
113182
};
114183

115184
function getProperty<T, K extends keyof T>(obj: T, name: string): T[K] {

features/v1/dashboards.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ Feature: Dashboards
444444
And the response "widgets[0].definition.requests[0].queries[0].aggregator" is equal to "sum"
445445
And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "query1"
446446

447-
@skip-typescript @team:DataDog/dashboards
447+
@team:DataDog/dashboards
448448
Scenario: Create a new dashboard with template variable defaults and default returns "Bad Request" response
449449
Given new "CreateDashboard" request
450450
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host"], "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]}

0 commit comments

Comments
 (0)