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}}
|
{{#formParams}}
|
||||||
{{#isFile}}
|
{{#isFile}}
|
||||||
reqHasFile = true;
|
reqHasFile = true;
|
||||||
|
formParams = {{paramName}};
|
||||||
{{/isFile}}
|
{{/isFile}}
|
||||||
|
{{^isFile}}
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
if ({{paramName}}) {
|
if ({{paramName}}) {
|
||||||
{{#isCollectionFormatMulti}}
|
{{#isCollectionFormatMulti}}
|
||||||
@ -121,7 +123,7 @@ export class {{classname}} {
|
|||||||
formParams.append('{{baseName}}', <any>{{paramName}});
|
formParams.append('{{baseName}}', <any>{{paramName}});
|
||||||
}
|
}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
|
{{/isFile}}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
|
@ -433,11 +433,9 @@ export class PetApi {
|
|||||||
if (name !== null && name !== undefined) {
|
if (name !== null && name !== undefined) {
|
||||||
formParams.append('name', <any>name);
|
formParams.append('name', <any>name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status !== null && status !== undefined) {
|
if (status !== null && status !== undefined) {
|
||||||
formParams.append('status', <any>status);
|
formParams.append('status', <any>status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
let consumes: string[] = [
|
let consumes: string[] = [
|
||||||
'application/x-www-form-urlencoded'
|
'application/x-www-form-urlencoded'
|
||||||
@ -515,12 +513,8 @@ export class PetApi {
|
|||||||
if (additionalMetadata !== null && additionalMetadata !== undefined) {
|
if (additionalMetadata !== null && additionalMetadata !== undefined) {
|
||||||
formParams.append('additionalMetadata', <any>additionalMetadata);
|
formParams.append('additionalMetadata', <any>additionalMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
reqHasFile = true;
|
reqHasFile = true;
|
||||||
if (file !== null && file !== undefined) {
|
formParams = file;
|
||||||
formParams.append('file', <any>file);
|
|
||||||
}
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
let consumes: string[] = [
|
let consumes: string[] = [
|
||||||
'multipart/form-data'
|
'multipart/form-data'
|
||||||
|
@ -433,11 +433,9 @@ export class PetApi {
|
|||||||
if (name !== null && name !== undefined) {
|
if (name !== null && name !== undefined) {
|
||||||
formParams.append('name', <any>name);
|
formParams.append('name', <any>name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status !== null && status !== undefined) {
|
if (status !== null && status !== undefined) {
|
||||||
formParams.append('status', <any>status);
|
formParams.append('status', <any>status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
let consumes: string[] = [
|
let consumes: string[] = [
|
||||||
'application/x-www-form-urlencoded'
|
'application/x-www-form-urlencoded'
|
||||||
@ -515,12 +513,8 @@ export class PetApi {
|
|||||||
if (additionalMetadata !== null && additionalMetadata !== undefined) {
|
if (additionalMetadata !== null && additionalMetadata !== undefined) {
|
||||||
formParams.append('additionalMetadata', <any>additionalMetadata);
|
formParams.append('additionalMetadata', <any>additionalMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
reqHasFile = true;
|
reqHasFile = true;
|
||||||
if (file !== null && file !== undefined) {
|
formParams = file;
|
||||||
formParams.append('file', <any>file);
|
|
||||||
}
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
let consumes: string[] = [
|
let consumes: string[] = [
|
||||||
'multipart/form-data'
|
'multipart/form-data'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user