Sets content type correctly on request
This commit is contained in:
Родитель
0e1a460c89
Коммит
0cc12ed317
|
@ -643,6 +643,21 @@ class SpecValidator {
|
|||
} else if (location === 'body') {
|
||||
options.body = parameterValue;
|
||||
options.disableJsonStringifyOnBody = true;
|
||||
if (operation.consumes) {
|
||||
if (!options.headers) options.headers = {};
|
||||
|
||||
function isOctetStream(consumes) {
|
||||
return consumes.some((contentType) => {
|
||||
return contentType === 'application/octet-stream';
|
||||
});
|
||||
}
|
||||
|
||||
if (parameter.schema.format === 'file' && isOctetStream(operation.consumes)) {
|
||||
options.headers['Content-Type'] = 'application/octet-stream';
|
||||
} else {
|
||||
options.headers['Content-Type'] = operation.consumes[0];
|
||||
}
|
||||
}
|
||||
} else if (location === 'header') {
|
||||
if (!options.headers) options.headers = {};
|
||||
options.headers[parameter.name] = parameterValue;
|
||||
|
|
Загрузка…
Ссылка в новой задаче