Skip to content

Commit 0a479f7

Browse files
macjohnnywing328
authored andcommitted
[typescript-angular] strict type checking (#218)
* strict type checking * strict type checking * generate samples for angular-typescript
1 parent 2392a09 commit 0a479f7

File tree

37 files changed

+222
-222
lines changed

37 files changed

+222
-222
lines changed

modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class {{classname}} {
226226
{{/produces}}
227227
];
228228
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
229-
if (httpHeaderAcceptSelected != undefined) {
229+
if (httpHeaderAcceptSelected !== undefined) {
230230
{{^useHttpClient}}
231231
headers.set('Accept', httpHeaderAcceptSelected);
232232
{{/useHttpClient}}
@@ -243,7 +243,7 @@ export class {{classname}} {
243243
];
244244
{{#bodyParam}}
245245
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
246-
if (httpContentTypeSelected != undefined) {
246+
if (httpContentTypeSelected !== undefined) {
247247
{{^useHttpClient}}
248248
headers.set('Content-Type', httpContentTypeSelected);
249249
{{/useHttpClient}}

modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Configuration {
3232
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
3333
*/
3434
public selectHeaderContentType (contentTypes: string[]): string | undefined {
35-
if (contentTypes.length == 0) {
35+
if (contentTypes.length === 0) {
3636
return undefined;
3737
}
3838

@@ -51,7 +51,7 @@ export class Configuration {
5151
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
5252
*/
5353
public selectHeaderAccept(accepts: string[]): string | undefined {
54-
if (accepts.length == 0) {
54+
if (accepts.length === 0) {
5555
return undefined;
5656
}
5757

@@ -74,6 +74,6 @@ export class Configuration {
7474
*/
7575
public isJsonMime(mime: string): boolean {
7676
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
77-
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
77+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
7878
}
7979
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-SNAPSHOT
1+
3.0.1-SNAPSHOT

samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export class PetService {
217217
let httpHeaderAccepts: string[] = [
218218
];
219219
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
220-
if (httpHeaderAcceptSelected != undefined) {
220+
if (httpHeaderAcceptSelected !== undefined) {
221221
headers.set('Accept', httpHeaderAcceptSelected);
222222
}
223223

@@ -227,7 +227,7 @@ export class PetService {
227227
'application/xml'
228228
];
229229
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
230-
if (httpContentTypeSelected != undefined) {
230+
if (httpContentTypeSelected !== undefined) {
231231
headers.set('Content-Type', httpContentTypeSelected);
232232
}
233233

@@ -274,7 +274,7 @@ export class PetService {
274274
let httpHeaderAccepts: string[] = [
275275
];
276276
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
277-
if (httpHeaderAcceptSelected != undefined) {
277+
if (httpHeaderAcceptSelected !== undefined) {
278278
headers.set('Accept', httpHeaderAcceptSelected);
279279
}
280280

@@ -327,7 +327,7 @@ export class PetService {
327327
'application/json'
328328
];
329329
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
330-
if (httpHeaderAcceptSelected != undefined) {
330+
if (httpHeaderAcceptSelected !== undefined) {
331331
headers.set('Accept', httpHeaderAcceptSelected);
332332
}
333333

@@ -381,7 +381,7 @@ export class PetService {
381381
'application/json'
382382
];
383383
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
384-
if (httpHeaderAcceptSelected != undefined) {
384+
if (httpHeaderAcceptSelected !== undefined) {
385385
headers.set('Accept', httpHeaderAcceptSelected);
386386
}
387387

@@ -427,7 +427,7 @@ export class PetService {
427427
'application/json'
428428
];
429429
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
430-
if (httpHeaderAcceptSelected != undefined) {
430+
if (httpHeaderAcceptSelected !== undefined) {
431431
headers.set('Accept', httpHeaderAcceptSelected);
432432
}
433433

@@ -473,7 +473,7 @@ export class PetService {
473473
let httpHeaderAccepts: string[] = [
474474
];
475475
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
476-
if (httpHeaderAcceptSelected != undefined) {
476+
if (httpHeaderAcceptSelected !== undefined) {
477477
headers.set('Accept', httpHeaderAcceptSelected);
478478
}
479479

@@ -483,7 +483,7 @@ export class PetService {
483483
'application/xml'
484484
];
485485
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
486-
if (httpContentTypeSelected != undefined) {
486+
if (httpContentTypeSelected !== undefined) {
487487
headers.set('Content-Type', httpContentTypeSelected);
488488
}
489489

@@ -528,7 +528,7 @@ export class PetService {
528528
let httpHeaderAccepts: string[] = [
529529
];
530530
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
531-
if (httpHeaderAcceptSelected != undefined) {
531+
if (httpHeaderAcceptSelected !== undefined) {
532532
headers.set('Accept', httpHeaderAcceptSelected);
533533
}
534534

@@ -601,7 +601,7 @@ export class PetService {
601601
'application/json'
602602
];
603603
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
604-
if (httpHeaderAcceptSelected != undefined) {
604+
if (httpHeaderAcceptSelected !== undefined) {
605605
headers.set('Accept', httpHeaderAcceptSelected);
606606
}
607607

samples/client/petstore/typescript-angular-v2/default/api/store.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class StoreService {
138138
let httpHeaderAccepts: string[] = [
139139
];
140140
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
141-
if (httpHeaderAcceptSelected != undefined) {
141+
if (httpHeaderAcceptSelected !== undefined) {
142142
headers.set('Accept', httpHeaderAcceptSelected);
143143
}
144144

@@ -178,7 +178,7 @@ export class StoreService {
178178
'application/json'
179179
];
180180
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
181-
if (httpHeaderAcceptSelected != undefined) {
181+
if (httpHeaderAcceptSelected !== undefined) {
182182
headers.set('Accept', httpHeaderAcceptSelected);
183183
}
184184

@@ -218,7 +218,7 @@ export class StoreService {
218218
'application/json'
219219
];
220220
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
221-
if (httpHeaderAcceptSelected != undefined) {
221+
if (httpHeaderAcceptSelected !== undefined) {
222222
headers.set('Accept', httpHeaderAcceptSelected);
223223
}
224224

@@ -258,15 +258,15 @@ export class StoreService {
258258
'application/json'
259259
];
260260
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
261-
if (httpHeaderAcceptSelected != undefined) {
261+
if (httpHeaderAcceptSelected !== undefined) {
262262
headers.set('Accept', httpHeaderAcceptSelected);
263263
}
264264

265265
// to determine the Content-Type header
266266
const consumes: string[] = [
267267
];
268268
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
269-
if (httpContentTypeSelected != undefined) {
269+
if (httpContentTypeSelected !== undefined) {
270270
headers.set('Content-Type', httpContentTypeSelected);
271271
}
272272

samples/client/petstore/typescript-angular-v2/default/api/user.service.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ export class UserService {
204204
let httpHeaderAccepts: string[] = [
205205
];
206206
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
207-
if (httpHeaderAcceptSelected != undefined) {
207+
if (httpHeaderAcceptSelected !== undefined) {
208208
headers.set('Accept', httpHeaderAcceptSelected);
209209
}
210210

211211
// to determine the Content-Type header
212212
const consumes: string[] = [
213213
];
214214
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
215-
if (httpContentTypeSelected != undefined) {
215+
if (httpContentTypeSelected !== undefined) {
216216
headers.set('Content-Type', httpContentTypeSelected);
217217
}
218218

@@ -247,15 +247,15 @@ export class UserService {
247247
let httpHeaderAccepts: string[] = [
248248
];
249249
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
250-
if (httpHeaderAcceptSelected != undefined) {
250+
if (httpHeaderAcceptSelected !== undefined) {
251251
headers.set('Accept', httpHeaderAcceptSelected);
252252
}
253253

254254
// to determine the Content-Type header
255255
const consumes: string[] = [
256256
];
257257
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
258-
if (httpContentTypeSelected != undefined) {
258+
if (httpContentTypeSelected !== undefined) {
259259
headers.set('Content-Type', httpContentTypeSelected);
260260
}
261261

@@ -290,15 +290,15 @@ export class UserService {
290290
let httpHeaderAccepts: string[] = [
291291
];
292292
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
293-
if (httpHeaderAcceptSelected != undefined) {
293+
if (httpHeaderAcceptSelected !== undefined) {
294294
headers.set('Accept', httpHeaderAcceptSelected);
295295
}
296296

297297
// to determine the Content-Type header
298298
const consumes: string[] = [
299299
];
300300
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
301-
if (httpContentTypeSelected != undefined) {
301+
if (httpContentTypeSelected !== undefined) {
302302
headers.set('Content-Type', httpContentTypeSelected);
303303
}
304304

@@ -333,7 +333,7 @@ export class UserService {
333333
let httpHeaderAccepts: string[] = [
334334
];
335335
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
336-
if (httpHeaderAcceptSelected != undefined) {
336+
if (httpHeaderAcceptSelected !== undefined) {
337337
headers.set('Accept', httpHeaderAcceptSelected);
338338
}
339339

@@ -373,7 +373,7 @@ export class UserService {
373373
'application/json'
374374
];
375375
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
376-
if (httpHeaderAcceptSelected != undefined) {
376+
if (httpHeaderAcceptSelected !== undefined) {
377377
headers.set('Accept', httpHeaderAcceptSelected);
378378
}
379379

@@ -425,7 +425,7 @@ export class UserService {
425425
'application/json'
426426
];
427427
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
428-
if (httpHeaderAcceptSelected != undefined) {
428+
if (httpHeaderAcceptSelected !== undefined) {
429429
headers.set('Accept', httpHeaderAcceptSelected);
430430
}
431431

@@ -460,7 +460,7 @@ export class UserService {
460460
let httpHeaderAccepts: string[] = [
461461
];
462462
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
463-
if (httpHeaderAcceptSelected != undefined) {
463+
if (httpHeaderAcceptSelected !== undefined) {
464464
headers.set('Accept', httpHeaderAcceptSelected);
465465
}
466466

@@ -502,15 +502,15 @@ export class UserService {
502502
let httpHeaderAccepts: string[] = [
503503
];
504504
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
505-
if (httpHeaderAcceptSelected != undefined) {
505+
if (httpHeaderAcceptSelected !== undefined) {
506506
headers.set('Accept', httpHeaderAcceptSelected);
507507
}
508508

509509
// to determine the Content-Type header
510510
const consumes: string[] = [
511511
];
512512
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
513-
if (httpContentTypeSelected != undefined) {
513+
if (httpContentTypeSelected !== undefined) {
514514
headers.set('Content-Type', httpContentTypeSelected);
515515
}
516516

samples/client/petstore/typescript-angular-v2/default/configuration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Configuration {
3232
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
3333
*/
3434
public selectHeaderContentType (contentTypes: string[]): string | undefined {
35-
if (contentTypes.length == 0) {
35+
if (contentTypes.length === 0) {
3636
return undefined;
3737
}
3838

@@ -51,7 +51,7 @@ export class Configuration {
5151
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
5252
*/
5353
public selectHeaderAccept(accepts: string[]): string | undefined {
54-
if (accepts.length == 0) {
54+
if (accepts.length === 0) {
5555
return undefined;
5656
}
5757

@@ -74,6 +74,6 @@ export class Configuration {
7474
*/
7575
public isJsonMime(mime: string): boolean {
7676
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
77-
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
77+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
7878
}
7979
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-SNAPSHOT
1+
3.0.1-SNAPSHOT

0 commit comments

Comments
 (0)