Merge branch 'master' of github.com:ferdikoomen/openapi-typescript-codegen

This commit is contained in:
Ferdi Koomen 2022-05-31 10:52:33 +02:00
commit f50b7e4a6f
2 changed files with 15 additions and 0 deletions

View File

@ -26,5 +26,17 @@ const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, for
headers['Authorization'] = `Basic ${credentials}`;
}
if (options.body) {
if (options.mediaType) {
headers['Content-Type'] = options.mediaType;
} else if (isBlob(options.body)) {
headers['Content-Type'] = options.body.type || 'application/octet-stream';
} else if (isString(options.body)) {
headers['Content-Type'] = 'text/plain';
} else if (!isFormData(options.body)) {
headers['Content-Type'] = 'application/json';
}
}
return headers;
};

View File

@ -22,6 +22,9 @@ import type { OpenAPIConfig } from './OpenAPI';
{{>functions/isBlob}}
{{>functions/isFormData}}
{{>functions/isSuccess}}