Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Commit f50b7e4

Browse files
committed
Merge branch 'master' of github.com:ferdikoomen/openapi-typescript-codegen
2 parents 65645ca + df7fd04 commit f50b7e4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/templates/core/axios/getHeaders.hbs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,17 @@ const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, for
2626
headers['Authorization'] = `Basic ${credentials}`;
2727
}
2828

29+
if (options.body) {
30+
if (options.mediaType) {
31+
headers['Content-Type'] = options.mediaType;
32+
} else if (isBlob(options.body)) {
33+
headers['Content-Type'] = options.body.type || 'application/octet-stream';
34+
} else if (isString(options.body)) {
35+
headers['Content-Type'] = 'text/plain';
36+
} else if (!isFormData(options.body)) {
37+
headers['Content-Type'] = 'application/json';
38+
}
39+
}
40+
2941
return headers;
3042
};

src/templates/core/axios/request.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import type { OpenAPIConfig } from './OpenAPI';
2222
{{>functions/isBlob}}
2323

2424

25+
{{>functions/isFormData}}
26+
27+
2528
{{>functions/isSuccess}}
2629

2730

0 commit comments

Comments
 (0)