Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function generateParamValue(spec: IHttpParam): E.Either {
return pipe(
generateHttpParam(spec),
E.fromOption(() => new Error(`Cannot generate value for: ${spec.name}`)),
E.chain(value => {
switch (spec.style) {
case HttpParamStyles.DeepObject:
return E.right(serializeWithDeepObjectStyle(spec.name, value));
case HttpParamStyles.PipeDelimited:
return pipe(
value,
E.fromPredicate(
Array.isArray,
() => new Error('Pipe delimited style is only applicable to array parameter')
),
E.map(v => serializeWithPipeDelimitedStyle(spec.name, v, spec.explode))
);