Skip to content

Commit 71a9ae1

Browse files
api-clients-generation-pipeline[bot]therveci.datadog-api-spec
authored
Fix some typescript lints (#450)
* Reduce number of lints Add return type plus some over cleanups to reduce the numbers of lints produced by eslint. * Create a type for the data structure * Rename * Regenerate client from commit e880fa4 of spec repo Co-authored-by: Thomas Hervé <[email protected]> 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 <[email protected]>
1 parent e09adcb commit 71a9ae1

File tree

757 files changed

+5496
-6703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

757 files changed

+5496
-6703
lines changed

.apigentools-info

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.5.1.dev2",
7-
"regenerated": "2022-01-05 07:38:56.845159",
8-
"spec_repo_commit": "d72de97"
7+
"regenerated": "2022-01-05 10:21:37.035741",
8+
"spec_repo_commit": "e880fa4"
99
},
1010
"v2": {
1111
"apigentools_version": "1.5.1.dev2",
12-
"regenerated": "2022-01-05 07:38:56.875054",
13-
"spec_repo_commit": "d72de97"
12+
"regenerated": "2022-01-05 10:21:37.061134",
13+
"spec_repo_commit": "e880fa4"
1414
}
1515
}
1616
}

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ module.exports = {
2020
],
2121
"@typescript-eslint/no-empty-function": "off",
2222
"@typescript-eslint/no-empty-interface": "off",
23+
"@typescript-eslint/no-explicit-any": "off",
2324
},
2425
};

.generator/templates/auth/auth.mustache

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface SecurityAuthentication {
1818
*
1919
* @params context the request context which should use this authentication scheme
2020
*/
21-
applySecurityAuthentication(context: RequestContext): void | Promise<void>;
21+
applySecurityAuthentication(context: RequestContext): void;
2222
}
2323

2424
{{#useInversify}}
@@ -80,7 +80,7 @@ export class {{#lambda.pascalcase}}{{name}}{{/lambda.pascalcase}}Authentication
8080
return "{{name}}";
8181
}
8282

83-
public {{#isBasicBearer}}async {{/isBasicBearer}}applySecurityAuthentication(context: RequestContext) {
83+
public {{#isBasicBearer}}async {{/isBasicBearer}}applySecurityAuthentication(context: RequestContext): void {
8484
{{#isApiKey}}
8585
context.{{#isKeyInHeader}}setHeaderParam{{/isKeyInHeader}}{{#isKeyInQuery}}setQueryParam{{/isKeyInQuery}}{{#isKeyInCookie}}addCookie{{/isKeyInCookie}}("{{keyParamName}}", this.apiKey);
8686
{{/isApiKey}}

.generator/templates/configuration.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function getServer(conf: Configuration, endpoint: string): BaseServerConf
147147
*
148148
* @param serverVariables key/value object representing the server variables (site, name, protocol, ...)
149149
*/
150-
export function setServerVariables(conf: Configuration, serverVariables: { [key: string]: string }) {
150+
export function setServerVariables(conf: Configuration, serverVariables: { [key: string]: string }): void {
151151
if (conf.baseServer !== undefined) {
152152
conf.baseServer.setVariables(serverVariables);
153153
return ;

.generator/templates/http/http.mustache

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class RequestContext {
142142
* Replaces the url set in the constructor with this url.
143143
*
144144
*/
145-
public setUrl(url: string) {
145+
public setUrl(url: string): void {
146146
this.url = new URLParse(url, true);
147147
}
148148

@@ -155,7 +155,7 @@ export class RequestContext {
155155
*
156156
* @param body the body of the request
157157
*/
158-
public setBody(body: RequestBody) {
158+
public setBody(body: RequestBody): void {
159159
this.body = body;
160160
}
161161

@@ -171,7 +171,7 @@ export class RequestContext {
171171
return this.body;
172172
}
173173

174-
public setQueryParam(name: string, value: string) {
174+
public setQueryParam(name: string, value: string): void {
175175
let queryObj = this.url.query;
176176
queryObj[name] = value;
177177
this.url.set("query", queryObj);

.generator/templates/http/servers.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class BaseServerConfiguration {
1313
*
1414
* @param variableConfiguration a partial variable configuration for the variables contained in the url
1515
*/
16-
public setVariables(variableConfiguration: { [key: string]: string }) {
16+
public setVariables(variableConfiguration: { [key: string]: string }): void {
1717
Object.assign(this.variableConfiguration, variableConfiguration);
1818
}
1919

.generator/templates/model/ObjectSerializer.mustache

+18-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let oneOfMap: {[index: string]: string[]} = {
5858
};
5959

6060
export class ObjectSerializer {
61-
public static serialize(data: any, type: string, format: string) {
61+
public static serialize(data: any, type: string, format: string): any {
6262
if (data == undefined) {
6363
return data;
6464
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
@@ -141,7 +141,7 @@ export class ObjectSerializer {
141141
}
142142
}
143143
144-
public static deserialize(data: any, type: string, format: string = "") {
144+
public static deserialize(data: any, type: string, format: string = ""): any {
145145
if (data == undefined) {
146146
return data;
147147
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
@@ -246,17 +246,21 @@ export class ObjectSerializer {
246246
let selectedMediaType: string | undefined = undefined;
247247
let selectedRank: number = -Infinity;
248248
for (const mediaType of normalMediaTypes) {
249-
if (supportedMediaTypes[mediaType!] > selectedRank) {
249+
if (mediaType === undefined) {
250+
continue;
251+
}
252+
let supported = supportedMediaTypes[mediaType];
253+
if (supported !== undefined && supported > selectedRank) {
250254
selectedMediaType = mediaType;
251-
selectedRank = supportedMediaTypes[mediaType!];
255+
selectedRank = supported;
252256
}
253257
}
254258
255259
if (selectedMediaType === undefined) {
256260
throw new Error("None of the given media types are supported: " + mediaTypes.join(", "));
257261
}
258262
259-
return selectedMediaType!;
263+
return selectedMediaType;
260264
}
261265
262266
/**
@@ -273,7 +277,7 @@ export class ObjectSerializer {
273277
/**
274278
* Parse data from a string according to the given media type
275279
*/
276-
public static parse(rawData: string, mediaType: string | undefined) {
280+
public static parse(rawData: string, mediaType: string | undefined): any {
277281
try {
278282
return JSON.parse(rawData);
279283
} catch (error) {
@@ -290,3 +294,11 @@ export class UnparsedObject {
290294
}
291295
}
292296
297+
export type AttributeTypeMap = {
298+
[key: string]: {
299+
baseName: string;
300+
type: string;
301+
required?: boolean;
302+
format?: string;
303+
};
304+
}

.generator/templates/model/model.mustache

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { {{classname}} } from './{{filename}}{{extensionForDeno}}';
66
{{/tsImports}}
77
import { HttpFile } from '../http/http{{extensionForDeno}}';
8-
import { ObjectSerializer, UnparsedObject } from './ObjectSerializer';
8+
import { AttributeTypeMap, UnparsedObject } from './ObjectSerializer';
99

1010
{{#description}}
1111
/**
@@ -26,7 +26,7 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
2626
'unparsedObject'?:any;
2727

2828
{{^isArray}}
29-
static readonly attributeTypeMap: {[key: string]: {baseName: string, type: string, required?: boolean, format?: string}} = {
29+
static readonly attributeTypeMap: AttributeTypeMap = {
3030
{{#vars}}
3131
"{{name}}": {
3232
"baseName": "{{baseName}}",
@@ -38,7 +38,7 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
3838
{{/vars}}
3939
};
4040

41-
static getAttributeTypeMap() {
41+
static getAttributeTypeMap(): AttributeTypeMap {
4242
{{#parent}}
4343
return super.getAttributeTypeMap().concat({{classname}}.attributeTypeMap);
4444
{{/parent}}

packages/datadog-api-client-v1/auth/auth.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface SecurityAuthentication {
1414
*
1515
* @params context the request context which should use this authentication scheme
1616
*/
17-
applySecurityAuthentication(context: RequestContext): void | Promise<void>;
17+
applySecurityAuthentication(context: RequestContext): void;
1818
}
1919

2020
export interface TokenProvider {
@@ -36,7 +36,7 @@ export class AuthZAuthentication implements SecurityAuthentication {
3636
return "AuthZ";
3737
}
3838

39-
public applySecurityAuthentication(context: RequestContext) {
39+
public applySecurityAuthentication(context: RequestContext): void {
4040
context.setHeaderParam("Authorization", "Bearer " + this.accessToken);
4141
}
4242
}
@@ -56,7 +56,7 @@ export class ApiKeyAuthAuthentication implements SecurityAuthentication {
5656
return "apiKeyAuth";
5757
}
5858

59-
public applySecurityAuthentication(context: RequestContext) {
59+
public applySecurityAuthentication(context: RequestContext): void {
6060
context.setHeaderParam("DD-API-KEY", this.apiKey);
6161
}
6262
}
@@ -76,7 +76,7 @@ export class ApiKeyAuthQueryAuthentication implements SecurityAuthentication {
7676
return "apiKeyAuthQuery";
7777
}
7878

79-
public applySecurityAuthentication(context: RequestContext) {
79+
public applySecurityAuthentication(context: RequestContext): void {
8080
context.setQueryParam("api_key", this.apiKey);
8181
}
8282
}
@@ -96,7 +96,7 @@ export class AppKeyAuthAuthentication implements SecurityAuthentication {
9696
return "appKeyAuth";
9797
}
9898

99-
public applySecurityAuthentication(context: RequestContext) {
99+
public applySecurityAuthentication(context: RequestContext): void {
100100
context.setHeaderParam("DD-APPLICATION-KEY", this.apiKey);
101101
}
102102
}
@@ -116,7 +116,7 @@ export class AppKeyAuthQueryAuthentication implements SecurityAuthentication {
116116
return "appKeyAuthQuery";
117117
}
118118

119-
public applySecurityAuthentication(context: RequestContext) {
119+
public applySecurityAuthentication(context: RequestContext): void {
120120
context.setQueryParam("application_key", this.apiKey);
121121
}
122122
}

packages/datadog-api-client-v1/configuration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export function getServer(
166166
export function setServerVariables(
167167
conf: Configuration,
168168
serverVariables: { [key: string]: string }
169-
) {
169+
): void {
170170
if (conf.baseServer !== undefined) {
171171
conf.baseServer.setVariables(serverVariables);
172172
return;

packages/datadog-api-client-v1/http/http.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class RequestContext {
7878
* Replaces the url set in the constructor with this url.
7979
*
8080
*/
81-
public setUrl(url: string) {
81+
public setUrl(url: string): void {
8282
this.url = new URLParse(url, true);
8383
}
8484

@@ -91,7 +91,7 @@ export class RequestContext {
9191
*
9292
* @param body the body of the request
9393
*/
94-
public setBody(body: RequestBody) {
94+
public setBody(body: RequestBody): void {
9595
this.body = body;
9696
}
9797

@@ -107,7 +107,7 @@ export class RequestContext {
107107
return this.body;
108108
}
109109

110-
public setQueryParam(name: string, value: string) {
110+
public setQueryParam(name: string, value: string): void {
111111
const queryObj = this.url.query;
112112
queryObj[name] = value;
113113
this.url.set("query", queryObj);

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
* Do not edit the class manually.
99
*/
1010

11+
import { AttributeTypeMap } from "./ObjectSerializer";
12+
13+
/**
14+
* Error response object.
15+
*/
16+
1117
export class APIErrorResponse {
1218
/**
1319
* Array of errors returned by the API.
@@ -16,22 +22,15 @@ export class APIErrorResponse {
1622

1723
"unparsedObject"?: any;
1824

19-
static readonly attributeTypeMap: {
20-
[key: string]: {
21-
baseName: string;
22-
type: string;
23-
required?: boolean;
24-
format?: string;
25-
};
26-
} = {
25+
static readonly attributeTypeMap: AttributeTypeMap = {
2726
errors: {
2827
baseName: "errors",
2928
type: "Array<string>",
3029
required: true,
3130
},
3231
};
3332

34-
static getAttributeTypeMap() {
33+
static getAttributeTypeMap(): AttributeTypeMap {
3534
return APIErrorResponse.attributeTypeMap;
3635
}
3736

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
* Do not edit the class manually.
99
*/
1010

11+
import { AttributeTypeMap } from "./ObjectSerializer";
12+
13+
/**
14+
* Returns the AWS account associated with this integration.
15+
*/
16+
1117
export class AWSAccount {
1218
/**
1319
* Your AWS access key ID. Only required if your AWS account is a GovCloud or China account.
@@ -56,14 +62,7 @@ export class AWSAccount {
5662

5763
"unparsedObject"?: any;
5864

59-
static readonly attributeTypeMap: {
60-
[key: string]: {
61-
baseName: string;
62-
type: string;
63-
required?: boolean;
64-
format?: string;
65-
};
66-
} = {
65+
static readonly attributeTypeMap: AttributeTypeMap = {
6766
accessKeyId: {
6867
baseName: "access_key_id",
6968
type: "string",
@@ -110,7 +109,7 @@ export class AWSAccount {
110109
},
111110
};
112111

113-
static getAttributeTypeMap() {
112+
static getAttributeTypeMap(): AttributeTypeMap {
114113
return AWSAccount.attributeTypeMap;
115114
}
116115

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
* Do not edit the class manually.
99
*/
1010

11+
import { AttributeTypeMap } from "./ObjectSerializer";
12+
13+
/**
14+
* AWS account ID and Lambda ARN.
15+
*/
16+
1117
export class AWSAccountAndLambdaRequest {
1218
/**
1319
* Your AWS Account ID without dashes.
@@ -20,14 +26,7 @@ export class AWSAccountAndLambdaRequest {
2026

2127
"unparsedObject"?: any;
2228

23-
static readonly attributeTypeMap: {
24-
[key: string]: {
25-
baseName: string;
26-
type: string;
27-
required?: boolean;
28-
format?: string;
29-
};
30-
} = {
29+
static readonly attributeTypeMap: AttributeTypeMap = {
3130
accountId: {
3231
baseName: "account_id",
3332
type: "string",
@@ -40,7 +39,7 @@ export class AWSAccountAndLambdaRequest {
4039
},
4140
};
4241

43-
static getAttributeTypeMap() {
42+
static getAttributeTypeMap(): AttributeTypeMap {
4443
return AWSAccountAndLambdaRequest.attributeTypeMap;
4544
}
4645

0 commit comments

Comments
 (0)