From bd46ea3d8b141dc16146dc41e1843a0e3e005b1a Mon Sep 17 00:00:00 2001 From: Esteban Marin Date: Wed, 13 Feb 2019 15:43:05 +0100 Subject: [PATCH 1/2] #2147: fix compiler error in angular typescript codegen --- .../resources/typescript-angular/api.service.mustache | 6 +++--- .../client/petstore/typescript-angular-v2/npm/encoder.ts | 4 +--- .../typescript-angular-v4.3/npm/api/pet.service.ts | 8 ++++---- .../builds/default/api/pet.service.ts | 8 ++++---- .../builds/with-npm/api/pet.service.ts | 8 ++++---- .../builds/default/api/pet.service.ts | 8 ++++---- .../builds/with-npm/api/pet.service.ts | 8 ++++---- .../builds/default/api/pet.service.ts | 8 ++++---- .../builds/default/api/pet.service.ts | 8 ++++---- .../builds/with-npm/api/pet.service.ts | 8 ++++---- 10 files changed, 36 insertions(+), 38 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache index df550e704840..109226f02b85 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache @@ -296,17 +296,17 @@ export class {{classname}} { if ({{paramName}}) { {{#isCollectionFormatMulti}} {{paramName}}.forEach((element) => { - {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', element){{#useHttpClient}} || formParams{{/useHttpClient}}; + {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', element){{#useHttpClient}} as any || formParams{{/useHttpClient}}; }) {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} || formParams{{/useHttpClient}}; + {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} as any || formParams{{/useHttpClient}}; {{/isCollectionFormatMulti}} } {{/isListContainer}} {{^isListContainer}} if ({{paramName}} !== undefined) { - {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}){{#useHttpClient}} || formParams{{/useHttpClient}}; + {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}){{#useHttpClient}} as any || formParams{{/useHttpClient}}; } {{/isListContainer}} {{/formParams}} diff --git a/samples/client/petstore/typescript-angular-v2/npm/encoder.ts b/samples/client/petstore/typescript-angular-v2/npm/encoder.ts index 71f99f9c7041..6fcda7b246dd 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/encoder.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/encoder.ts @@ -8,9 +8,7 @@ export class CustomQueryEncoderHelper extends QueryEncoder { encodeKey(k: string): string { k = super.encodeKey(k); - return k.replace(/\+/gi, '%2B') - .replace(/%5B/, "[").replace(/%5D/, "]") - ; + return k.replace(/\+/gi, '%2B'); } encodeValue(v: string): string { v = super.encodeValue(v); diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts index 62241086b11a..5743def7fa6b 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts @@ -425,10 +425,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -498,10 +498,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts index 90b3c94edb0a..3918742abe52 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts @@ -425,10 +425,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -498,10 +498,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts index 90b3c94edb0a..3918742abe52 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts @@ -425,10 +425,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -498,10 +498,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts index 38eb9aebb525..c6c4a85ad324 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts @@ -427,10 +427,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -500,10 +500,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts index 38eb9aebb525..c6c4a85ad324 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts @@ -427,10 +427,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -500,10 +500,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts index 90b3c94edb0a..3918742abe52 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts @@ -425,10 +425,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -498,10 +498,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts index 38eb9aebb525..c6c4a85ad324 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts @@ -427,10 +427,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -500,10 +500,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts index 38eb9aebb525..c6c4a85ad324 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts @@ -427,10 +427,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -500,10 +500,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, From b663f5c975c62405d5b21fb10f61084fdf05f175 Mon Sep 17 00:00:00 2001 From: Esteban Marin Date: Wed, 13 Feb 2019 16:49:35 +0100 Subject: [PATCH 2/2] #2147: generate samples --- .../builds/with-npm/api/pet.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts index 90b3c94edb0a..3918742abe52 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts @@ -425,10 +425,10 @@ export class PetService { } if (name !== undefined) { - formParams = formParams.append('name', name) || formParams; + formParams = formParams.append('name', name) as any || formParams; } if (status !== undefined) { - formParams = formParams.append('status', status) || formParams; + formParams = formParams.append('status', status) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}`, @@ -498,10 +498,10 @@ export class PetService { } if (additionalMetadata !== undefined) { - formParams = formParams.append('additionalMetadata', additionalMetadata) || formParams; + formParams = formParams.append('additionalMetadata', additionalMetadata) as any || formParams; } if (file !== undefined) { - formParams = formParams.append('file', file) || formParams; + formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.post(`${this.configuration.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,