Skip to content

Commit

Permalink
Merge pull request #204 from hey-api/fix/pass-correct-content-type-wi…
Browse files Browse the repository at this point in the history
…th-axios-formdata

fix(axios): set content type to multipart/form-data when using form data
  • Loading branch information
mrlubos authored Apr 1, 2024
2 parents 49ffeda + f0baeba commit 3b69cc7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-rings-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

fix(axios): set content type to multipart/form-data when using form data
2 changes: 2 additions & 0 deletions src/templates/core/axios/getHeaders.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptio
} else if (!isFormData(options.body)) {
headers['Content-Type'] = 'application/json';
}
} else if (options.formData !== undefined) {
headers['Content-Type'] = options.mediaType;
}

return headers;
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/v3_axios/core/request.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export const getHeaders = async (
} else if (!isFormData(options.body)) {
headers['Content-Type'] = 'application/json';
}
} else if (options.formData !== undefined) {
headers['Content-Type'] = options.mediaType;
}
return headers;
Expand Down

0 comments on commit 3b69cc7

Please sign in to comment.