From 632364e290af36bb0f26df88a952b6072be6068f Mon Sep 17 00:00:00 2001 From: topce Date: Mon, 6 May 2019 16:03:11 +0200 Subject: [PATCH] fix multiple file upload (#2735) for typescript-angular client https://swagger.io/docs/specification/describing-request-body/file-upload/ --- .../resources/typescript-angular/api.service.mustache | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 109226f02b85..0ad35d6b1402 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 @@ -300,7 +300,13 @@ export class {{classname}} { }) {{/isCollectionFormatMulti}} {{^isCollectionFormatMulti}} - {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} as any || formParams{{/useHttpClient}}; + if (useForm) { + {{paramName}}.forEach((element) => { + {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', element){{#useHttpClient}} as any || formParams{{/useHttpClient}}; + }) + } else { + {{#useHttpClient}}formParams = {{/useHttpClient}}formParams.append('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS['{{collectionFormat}}'])){{#useHttpClient}} as any || formParams{{/useHttpClient}}; + } {{/isCollectionFormatMulti}} } {{/isListContainer}}