Skip to content

Commit

Permalink
fix(typescript-axios): Correct the content type for a list of objects…
Browse files Browse the repository at this point in the history
… in form-data when contentType is present (#18505)

* fix content type for list of objects in form-data

* updated the samples
  • Loading branch information
Kavan72 committed May 3, 2024
1 parent 06b00e6 commit 73f2d82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,14 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur
{{#isArray}}
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{#contentType}}
localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "{{contentType}}", }));
{{/contentType}}
{{^contentType}}
{{paramName}}.forEach((element) => {
localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', element as any);
localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', element as any);
})
{{/contentType}}
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));
Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/typescript-axios/build/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ export const BodyApiAxiosParamCreator = function (configuration?: Configuration)

if (files) {
files.forEach((element) => {
localVarFormParams.append('files', element as any);
localVarFormParams.append('files', element as any);
})
}

Expand Down

0 comments on commit 73f2d82

Please sign in to comment.