diff --git a/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache index b3697917496..5acab55f344 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-jquery/api.mustache @@ -103,7 +103,9 @@ export class {{classname}} { {{#formParams}} {{#isFile}} reqHasFile = true; + formParams = {{paramName}}; {{/isFile}} +{{^isFile}} {{#isListContainer}} if ({{paramName}}) { {{#isCollectionFormatMulti}} @@ -121,7 +123,7 @@ export class {{classname}} { formParams.append('{{baseName}}', {{paramName}}); } {{/isListContainer}} - +{{/isFile}} {{/formParams}} {{#headerParams}} {{#isListContainer}} diff --git a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts index 8b720012525..ef7f615f690 100644 --- a/samples/client/petstore/typescript-jquery/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-jquery/default/api/PetApi.ts @@ -433,11 +433,9 @@ export class PetApi { if (name !== null && name !== undefined) { formParams.append('name', name); } - if (status !== null && status !== undefined) { formParams.append('status', status); } - // to determine the Content-Type header let consumes: string[] = [ 'application/x-www-form-urlencoded' @@ -515,12 +513,8 @@ export class PetApi { if (additionalMetadata !== null && additionalMetadata !== undefined) { formParams.append('additionalMetadata', additionalMetadata); } - reqHasFile = true; - if (file !== null && file !== undefined) { - formParams.append('file', file); - } - + formParams = file; // to determine the Content-Type header let consumes: string[] = [ 'multipart/form-data' diff --git a/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts index 8b720012525..ef7f615f690 100644 --- a/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-jquery/npm/api/PetApi.ts @@ -433,11 +433,9 @@ export class PetApi { if (name !== null && name !== undefined) { formParams.append('name', name); } - if (status !== null && status !== undefined) { formParams.append('status', status); } - // to determine the Content-Type header let consumes: string[] = [ 'application/x-www-form-urlencoded' @@ -515,12 +513,8 @@ export class PetApi { if (additionalMetadata !== null && additionalMetadata !== undefined) { formParams.append('additionalMetadata', additionalMetadata); } - reqHasFile = true; - if (file !== null && file !== undefined) { - formParams.append('file', file); - } - + formParams = file; // to determine the Content-Type header let consumes: string[] = [ 'multipart/form-data'