forked from loafle/openapi-generator-original
[Typescript-Jquery] Fix file upload (#6262)
* Fix a bug with the file upload that was not working * Prevent unnecessary append to the FormData
This commit is contained in:
parent
e94ba4c36d
commit
00b46e8a94
@ -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}}', <any>{{paramName}});
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{#headerParams}}
|
||||
{{#isListContainer}}
|
||||
|
@ -433,11 +433,9 @@ export class PetApi {
|
||||
if (name !== null && name !== undefined) {
|
||||
formParams.append('name', <any>name);
|
||||
}
|
||||
|
||||
if (status !== null && status !== undefined) {
|
||||
formParams.append('status', <any>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', <any>additionalMetadata);
|
||||
}
|
||||
|
||||
reqHasFile = true;
|
||||
if (file !== null && file !== undefined) {
|
||||
formParams.append('file', <any>file);
|
||||
}
|
||||
|
||||
formParams = file;
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
|
@ -433,11 +433,9 @@ export class PetApi {
|
||||
if (name !== null && name !== undefined) {
|
||||
formParams.append('name', <any>name);
|
||||
}
|
||||
|
||||
if (status !== null && status !== undefined) {
|
||||
formParams.append('status', <any>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', <any>additionalMetadata);
|
||||
}
|
||||
|
||||
reqHasFile = true;
|
||||
if (file !== null && file !== undefined) {
|
||||
formParams.append('file', <any>file);
|
||||
}
|
||||
|
||||
formParams = file;
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'multipart/form-data'
|
||||
|
Loading…
x
Reference in New Issue
Block a user