@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
25 lines (24 loc) • 737 B
JavaScript
import { cleanObject } from "@tsed/core";
/**
* Map input header to a standard open spec header
* @param headers
* @ignore
*/
export function mapHeaders(headers) {
return Object.keys(headers).reduce((newHeaders, key) => {
const value = headers[key];
let type = typeof value;
let options = {
example: value
};
if (type === "object") {
options = value;
options.example = options.value === undefined ? options.example : options.value;
delete options.value;
type = typeof options.example;
}
options.type = options.type || type;
newHeaders[key] = cleanObject(options);
return newHeaders;
}, {});
}