Skip to content

Commit e01a786

Browse files
macjohnnywing328
authored andcommitted
#2147: fix compiler error in angular typescript codegen (#2149)
* #2147: fix compiler error in angular typescript codegen * #2147: generate samples
1 parent 804b589 commit e01a786

File tree

11 files changed

+40
-42
lines changed

11 files changed

+40
-42
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,17 @@ export class {{classname}} {
296296
if ({{paramName}}) {
297297
{{#isCollectionFormatMulti}}
298298
{{paramName}}.forEach((element) => {
299-
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>element){{#useHttpClient}} || formParams{{/useHttpClient}};
299+
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>element){{#useHttpClient}} as any || formParams{{/useHttpClient}};
300300
})
301301
{{/isCollectionFormatMulti}}
302302
{{^isCollectionFormatMulti}}
303-
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} || formParams{{/useHttpClient}};
303+
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} as any || formParams{{/useHttpClient}};
304304
{{/isCollectionFormatMulti}}
305305
}
306306
{{/isListContainer}}
307307
{{^isListContainer}}
308308
if ({{paramName}} !== undefined) {
309-
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>{{paramName}}){{#useHttpClient}} || formParams{{/useHttpClient}};
309+
{{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', <any>{{paramName}}){{#useHttpClient}} as any || formParams{{/useHttpClient}};
310310
}
311311
{{/isListContainer}}
312312
{{/formParams}}

samples/client/petstore/typescript-angular-v2/npm/encoder.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
export class CustomQueryEncoderHelper extends QueryEncoder {
99
encodeKey(k: string): string {
1010
k = super.encodeKey(k);
11-
return k.replace(/\+/gi, '%2B')
12-
.replace(/%5B/, "[").replace(/%5D/, "]")
13-
;
11+
return k.replace(/\+/gi, '%2B');
1412
}
1513
encodeValue(v: string): string {
1614
v = super.encodeValue(v);

samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ export class PetService {
425425
}
426426

427427
if (name !== undefined) {
428-
formParams = formParams.append('name', <any>name) || formParams;
428+
formParams = formParams.append('name', <any>name) as any || formParams;
429429
}
430430
if (status !== undefined) {
431-
formParams = formParams.append('status', <any>status) || formParams;
431+
formParams = formParams.append('status', <any>status) as any || formParams;
432432
}
433433

434434
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -498,10 +498,10 @@ export class PetService {
498498
}
499499

500500
if (additionalMetadata !== undefined) {
501-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
501+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
502502
}
503503
if (file !== undefined) {
504-
formParams = formParams.append('file', <any>file) || formParams;
504+
formParams = formParams.append('file', <any>file) as any || formParams;
505505
}
506506

507507
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ export class PetService {
425425
}
426426

427427
if (name !== undefined) {
428-
formParams = formParams.append('name', <any>name) || formParams;
428+
formParams = formParams.append('name', <any>name) as any || formParams;
429429
}
430430
if (status !== undefined) {
431-
formParams = formParams.append('status', <any>status) || formParams;
431+
formParams = formParams.append('status', <any>status) as any || formParams;
432432
}
433433

434434
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -498,10 +498,10 @@ export class PetService {
498498
}
499499

500500
if (additionalMetadata !== undefined) {
501-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
501+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
502502
}
503503
if (file !== undefined) {
504-
formParams = formParams.append('file', <any>file) || formParams;
504+
formParams = formParams.append('file', <any>file) as any || formParams;
505505
}
506506

507507
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ export class PetService {
425425
}
426426

427427
if (name !== undefined) {
428-
formParams = formParams.append('name', <any>name) || formParams;
428+
formParams = formParams.append('name', <any>name) as any || formParams;
429429
}
430430
if (status !== undefined) {
431-
formParams = formParams.append('status', <any>status) || formParams;
431+
formParams = formParams.append('status', <any>status) as any || formParams;
432432
}
433433

434434
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -498,10 +498,10 @@ export class PetService {
498498
}
499499

500500
if (additionalMetadata !== undefined) {
501-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
501+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
502502
}
503503
if (file !== undefined) {
504-
formParams = formParams.append('file', <any>file) || formParams;
504+
formParams = formParams.append('file', <any>file) as any || formParams;
505505
}
506506

507507
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ export class PetService {
427427
}
428428

429429
if (name !== undefined) {
430-
formParams = formParams.append('name', <any>name) || formParams;
430+
formParams = formParams.append('name', <any>name) as any || formParams;
431431
}
432432
if (status !== undefined) {
433-
formParams = formParams.append('status', <any>status) || formParams;
433+
formParams = formParams.append('status', <any>status) as any || formParams;
434434
}
435435

436436
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -500,10 +500,10 @@ export class PetService {
500500
}
501501

502502
if (additionalMetadata !== undefined) {
503-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
503+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
504504
}
505505
if (file !== undefined) {
506-
formParams = formParams.append('file', <any>file) || formParams;
506+
formParams = formParams.append('file', <any>file) as any || formParams;
507507
}
508508

509509
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ export class PetService {
427427
}
428428

429429
if (name !== undefined) {
430-
formParams = formParams.append('name', <any>name) || formParams;
430+
formParams = formParams.append('name', <any>name) as any || formParams;
431431
}
432432
if (status !== undefined) {
433-
formParams = formParams.append('status', <any>status) || formParams;
433+
formParams = formParams.append('status', <any>status) as any || formParams;
434434
}
435435

436436
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -500,10 +500,10 @@ export class PetService {
500500
}
501501

502502
if (additionalMetadata !== undefined) {
503-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
503+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
504504
}
505505
if (file !== undefined) {
506-
formParams = formParams.append('file', <any>file) || formParams;
506+
formParams = formParams.append('file', <any>file) as any || formParams;
507507
}
508508

509509
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ export class PetService {
425425
}
426426

427427
if (name !== undefined) {
428-
formParams = formParams.append('name', <any>name) || formParams;
428+
formParams = formParams.append('name', <any>name) as any || formParams;
429429
}
430430
if (status !== undefined) {
431-
formParams = formParams.append('status', <any>status) || formParams;
431+
formParams = formParams.append('status', <any>status) as any || formParams;
432432
}
433433

434434
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -498,10 +498,10 @@ export class PetService {
498498
}
499499

500500
if (additionalMetadata !== undefined) {
501-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
501+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
502502
}
503503
if (file !== undefined) {
504-
formParams = formParams.append('file', <any>file) || formParams;
504+
formParams = formParams.append('file', <any>file) as any || formParams;
505505
}
506506

507507
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ export class PetService {
425425
}
426426

427427
if (name !== undefined) {
428-
formParams = formParams.append('name', <any>name) || formParams;
428+
formParams = formParams.append('name', <any>name) as any || formParams;
429429
}
430430
if (status !== undefined) {
431-
formParams = formParams.append('status', <any>status) || formParams;
431+
formParams = formParams.append('status', <any>status) as any || formParams;
432432
}
433433

434434
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -498,10 +498,10 @@ export class PetService {
498498
}
499499

500500
if (additionalMetadata !== undefined) {
501-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
501+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
502502
}
503503
if (file !== undefined) {
504-
formParams = formParams.append('file', <any>file) || formParams;
504+
formParams = formParams.append('file', <any>file) as any || formParams;
505505
}
506506

507507
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ export class PetService {
427427
}
428428

429429
if (name !== undefined) {
430-
formParams = formParams.append('name', <any>name) || formParams;
430+
formParams = formParams.append('name', <any>name) as any || formParams;
431431
}
432432
if (status !== undefined) {
433-
formParams = formParams.append('status', <any>status) || formParams;
433+
formParams = formParams.append('status', <any>status) as any || formParams;
434434
}
435435

436436
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -500,10 +500,10 @@ export class PetService {
500500
}
501501

502502
if (additionalMetadata !== undefined) {
503-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
503+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
504504
}
505505
if (file !== undefined) {
506-
formParams = formParams.append('file', <any>file) || formParams;
506+
formParams = formParams.append('file', <any>file) as any || formParams;
507507
}
508508

509509
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ export class PetService {
427427
}
428428

429429
if (name !== undefined) {
430-
formParams = formParams.append('name', <any>name) || formParams;
430+
formParams = formParams.append('name', <any>name) as any || formParams;
431431
}
432432
if (status !== undefined) {
433-
formParams = formParams.append('status', <any>status) || formParams;
433+
formParams = formParams.append('status', <any>status) as any || formParams;
434434
}
435435

436436
return this.httpClient.post<any>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`,
@@ -500,10 +500,10 @@ export class PetService {
500500
}
501501

502502
if (additionalMetadata !== undefined) {
503-
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) || formParams;
503+
formParams = formParams.append('additionalMetadata', <any>additionalMetadata) as any || formParams;
504504
}
505505
if (file !== undefined) {
506-
formParams = formParams.append('file', <any>file) || formParams;
506+
formParams = formParams.append('file', <any>file) as any || formParams;
507507
}
508508

509509
return this.httpClient.post<ApiResponse>(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,

0 commit comments

Comments
 (0)