Skip to content

Commit

Permalink
fix(axios): properly type content-type headers assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Apr 2, 2024
1 parent 9e17887 commit 9b617ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-actors-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

fix(axios): properly type content-type headers assignment
4 changes: 3 additions & 1 deletion src/templates/core/axios/getHeaders.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptio
headers['Content-Type'] = 'application/json';
}
} else if (options.formData !== undefined) {
headers['Content-Type'] = options.mediaType;
if (options.mediaType) {
headers['Content-Type'] = options.mediaType;
}
}

return headers;
Expand Down
4 changes: 3 additions & 1 deletion test/__snapshots__/v3_axios/core/request.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export const getHeaders = async (
headers['Content-Type'] = 'application/json';
}
} else if (options.formData !== undefined) {
headers['Content-Type'] = options.mediaType;
if (options.mediaType) {
headers['Content-Type'] = options.mediaType;
}
}
return headers;
Expand Down

0 comments on commit 9b617ca

Please sign in to comment.