Skip to content

Commit ea2474d

Browse files
bvwellswing328
authored andcommitted
Fix strict class initialisation in auth classes (#7860)
1 parent 3b031ed commit ea2474d

File tree

10 files changed

+445
-37
lines changed

10 files changed

+445
-37
lines changed

modules/swagger-codegen/src/main/resources/typescript-node/api.mustache

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ export interface Authentication {
220220
}
221221

222222
export class HttpBasicAuth implements Authentication {
223-
public username: string;
224-
public password: string;
223+
public username: string = '';
224+
public password: string = '';
225+
225226
applyToRequest(requestOptions: localVarRequest.Options): void {
226227
requestOptions.auth = {
227228
username: this.username, password: this.password
@@ -230,7 +231,7 @@ export class HttpBasicAuth implements Authentication {
230231
}
231232

232233
export class ApiKeyAuth implements Authentication {
233-
public apiKey: string;
234+
public apiKey: string = '';
234235
235236
constructor(private location: string, private paramName: string) {
236237
}
@@ -245,7 +246,7 @@ export class ApiKeyAuth implements Authentication {
245246
}
246247

247248
export class OAuth implements Authentication {
248-
public accessToken: string;
249+
public accessToken: string = '';
249250
250251
applyToRequest(requestOptions: localVarRequest.Options): void {
251252
if (requestOptions && requestOptions.headers) {
@@ -255,8 +256,9 @@ export class OAuth implements Authentication {
255256
}
256257

257258
export class VoidAuth implements Authentication {
258-
public username: string;
259-
public password: string;
259+
public username: string = '';
260+
public password: string = '';
261+
260262
applyToRequest(_: localVarRequest.Options): void {
261263
// Do nothing
262264
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.1
1+
2.4.0-SNAPSHOT

samples/client/petstore/typescript-node/default/api.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ export interface Authentication {
428428
}
429429

430430
export class HttpBasicAuth implements Authentication {
431-
public username: string;
432-
public password: string;
431+
public username: string = '';
432+
public password: string = '';
433+
433434
applyToRequest(requestOptions: localVarRequest.Options): void {
434435
requestOptions.auth = {
435436
username: this.username, password: this.password
@@ -438,7 +439,7 @@ export class HttpBasicAuth implements Authentication {
438439
}
439440

440441
export class ApiKeyAuth implements Authentication {
441-
public apiKey: string;
442+
public apiKey: string = '';
442443

443444
constructor(private location: string, private paramName: string) {
444445
}
@@ -453,7 +454,7 @@ export class ApiKeyAuth implements Authentication {
453454
}
454455

455456
export class OAuth implements Authentication {
456-
public accessToken: string;
457+
public accessToken: string = '';
457458

458459
applyToRequest(requestOptions: localVarRequest.Options): void {
459460
if (requestOptions && requestOptions.headers) {
@@ -463,8 +464,9 @@ export class OAuth implements Authentication {
463464
}
464465

465466
export class VoidAuth implements Authentication {
466-
public username: string;
467-
public password: string;
467+
public username: string = '';
468+
public password: string = '';
469+
468470
applyToRequest(_: localVarRequest.Options): void {
469471
// Do nothing
470472
}
@@ -1507,7 +1509,7 @@ export class UserApi {
15071509
/**
15081510
*
15091511
* @summary Get user by user name
1510-
* @param username The name that needs to be fetched. Use user1 for testing.
1512+
* @param username The name that needs to be fetched. Use user1 for testing.
15111513
*/
15121514
public getUserByName (username: string) : Promise<{ response: http.ClientResponse; body: User; }> {
15131515
const localVarPath = this.basePath + '/user/{username}'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.1
1+
2.4.0-SNAPSHOT

samples/client/petstore/typescript-node/npm/api.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export declare class PetApi {
173173
response: http.ClientResponse;
174174
body?: any;
175175
}>;
176-
findPetsByStatus(status: Array<string>): Promise<{
176+
findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>): Promise<{
177177
response: http.ClientResponse;
178178
body: Array<Pet>;
179179
}>;

samples/client/petstore/typescript-node/npm/api.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/petstore/typescript-node/npm/api.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/client/petstore/typescript-node/npm/api.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ export interface Authentication {
428428
}
429429

430430
export class HttpBasicAuth implements Authentication {
431-
public username: string;
432-
public password: string;
431+
public username: string = '';
432+
public password: string = '';
433+
433434
applyToRequest(requestOptions: localVarRequest.Options): void {
434435
requestOptions.auth = {
435436
username: this.username, password: this.password
@@ -438,7 +439,7 @@ export class HttpBasicAuth implements Authentication {
438439
}
439440

440441
export class ApiKeyAuth implements Authentication {
441-
public apiKey: string;
442+
public apiKey: string = '';
442443

443444
constructor(private location: string, private paramName: string) {
444445
}
@@ -453,7 +454,7 @@ export class ApiKeyAuth implements Authentication {
453454
}
454455

455456
export class OAuth implements Authentication {
456-
public accessToken: string;
457+
public accessToken: string = '';
457458

458459
applyToRequest(requestOptions: localVarRequest.Options): void {
459460
if (requestOptions && requestOptions.headers) {
@@ -463,8 +464,9 @@ export class OAuth implements Authentication {
463464
}
464465

465466
export class VoidAuth implements Authentication {
466-
public username: string;
467-
public password: string;
467+
public username: string = '';
468+
public password: string = '';
469+
468470
applyToRequest(_: localVarRequest.Options): void {
469471
// Do nothing
470472
}
@@ -1507,7 +1509,7 @@ export class UserApi {
15071509
/**
15081510
*
15091511
* @summary Get user by user name
1510-
* @param username The name that needs to be fetched. Use user1 for testing.
1512+
* @param username The name that needs to be fetched. Use user1 for testing.
15111513
*/
15121514
public getUserByName (username: string) : Promise<{ response: http.ClientResponse; body: User; }> {
15131515
const localVarPath = this.basePath + '/user/{username}'

0 commit comments

Comments
 (0)