Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const serializeResponseObject = (
from: Ref,
responseObject: ResponseObject,
): Option> =>
pipe(
responseObject.content,
option.mapNullable(content => content['application/json']),
option.chain(media => media.schema),
option.map(schema =>
ReferenceObjectCodec.is(schema)
? pipe(fromString(schema.$ref), either.map(getSerializedRefType(from)))
: serializeSchemaObject(from)(schema),
),
);
export const serializePathItemObjectTags = (pathItemObject: PathItemObject): Option => {
const operations = [
pathItemObject.get,
pathItemObject.post,
pathItemObject.put,
pathItemObject.delete,
pathItemObject.options,
pathItemObject.head,
pathItemObject.patch,
];
return pipe(
nonEmptyArray.fromArray(array.compact(operations)),
option.map(operations => uniqString(flatten(array.compact(operations.map(operation => operation.tags))))),
option.chain(nonEmptyArray.fromArray),
option.map(tags => tags.join('').replace(/\s/g, '')),
);
};
const backgroundImage = pipe(
fills,
option.chain(nonEmptyArray.filter(fill => fill.fillType === 'Gradient')),
option.map(fills =>
pipe(
fills,
nonEmptyArray.map(fill => serializeGradient(fill.gradient)),
nonEmptyArray.nonEmptyArray.sequence(either.either),
either.map(gradients => `backgroundImage: '${gradients.join(', ')}'`),
),
),
sequenceOptionEither,
);
const backgroundBlendMode = pipe(
fills,
option.map(array.filterMap(fill => option.fromEither(getBackgroundBlendMode(fill.contextSettings.blendMode)))),
option.chain(array.last),
option.filter(mode => mode !== 'normal'),
option.map(mode => `backgroundBlendMode: '${mode}'`),
);
const mixBlendMode = pipe(
style.contextSettings,
option.chain(settings => option.fromEither(getMixBlendMode(settings.blendMode))),
option.filter(mode => mode !== 'normal'),
option.map(mode => `mixBlendMode: '${mode}'`),
);
const opacity = pipe(
style.contextSettings,
option.map(settings => settings.opacity),
option.filter(n => n !== 1),
option.map(opacity => `opacity: '${opacity}'`),
);
const groupPathsByTag = (pathsObject: PathsObject): Dictionary> => {
const keys = Object.keys(pathsObject);
const result: Record = {};
for (const key of keys) {
const path = pathsObject[key];
const tag = pipe(
serializePathItemObjectTags(path),
option.map(p => getControllerName(camelize(p, false))),
option.getOrElse(() => getControllerName('Unknown')),
);
result[tag] = {
...(result[tag] || {}),
[key]: path,
};
}
return result;
};
record.collect((name, value) => {
const isRequired = pipe(
schema.required,
option.map(includes(name)),
option.getOrElse(constFalse),
);
return pipe(
serializeSchemaObjectWithRecursion(from, value, false),
either.map(getSerializedOptionPropertyType(name, isRequired)),
);
}),
sequenceEither,
const border = pipe(
borders,
option.map(array.filterMap(border => option.fromEither(serializeBorder(border, style.borderOptions)))),
option.chain(array.last),
);
const boxShadow = pipe(
nonEmptyArray.fromArray([
...innerShadows.map(serializeInnerShadow),
...array.flatten(array.compact([pipe(shadows, option.map(array.map(serializeShadow)))])),
]),
option.map(shadows => `boxShadow: '${shadows.join(', ')}'`),
);
const textStyle = pipe(style.textStyle, option.map(serializeTextStyle));
return combineEither(backgroundImage, backgroundImage =>
array
.compact([
backgroundBlendMode,
backgroundColor,
backgroundImage,
mixBlendMode,
opacity,
border,
boxShadow,
textStyle,
])
.join(', '),
);
};
serializePaths => (name: string, swaggerObject: SwaggerObject): Either => {
const definitions = pipe(
swaggerObject.definitions,
option.map(definitions =>
pipe(
definitionsRef,
either.chain(from => serializeDefinitions(from, definitions)),
),
),
);
const parameters = pipe(
swaggerObject.parameters,
option.map(parameters =>
pipe(
parametersRef,
either.chain(ref => serializeParametersDefinitionsObject(ref, parameters)),
),
),
);
const responses = pipe(
option.map(fills =>
pipe(
fills,
nonEmptyArray.map(fill => serializeGradient(fill.gradient)),
nonEmptyArray.nonEmptyArray.sequence(either.either),
either.map(gradients => `backgroundImage: '${gradients.join(', ')}'`),
),
),
sequenceOptionEither,
);
const backgroundBlendMode = pipe(
fills,
option.map(array.filterMap(fill => option.fromEither(getBackgroundBlendMode(fill.contextSettings.blendMode)))),
option.chain(array.last),
option.filter(mode => mode !== 'normal'),
option.map(mode => `backgroundBlendMode: '${mode}'`),
);
const mixBlendMode = pipe(
style.contextSettings,
option.chain(settings => option.fromEither(getMixBlendMode(settings.blendMode))),
option.filter(mode => mode !== 'normal'),
option.map(mode => `mixBlendMode: '${mode}'`),
);
const opacity = pipe(
style.contextSettings,
option.map(settings => settings.opacity),
option.filter(n => n !== 1),
option.map(opacity => `opacity: '${opacity}'`),
);
const border = pipe(
borders,
const groupPathsByTag = (pathsObject: PathsObject): Dictionary => {
const keys = Object.keys(pathsObject);
const result: Record = {};
for (const key of keys) {
const path = pathsObject[key];
const tag = pipe(
serializePathItemObjectTags(path),
option.map(p => getControllerName(camelize(p, false))),
option.getOrElse(() => getControllerName('Unknown')),
);
result[tag] = {
...(result[tag] || {}),
[key]: path,
};
}
return result;
};
}
const serializedQueryParameter = pipe(
nonEmptyArray.fromArray(serializedQueryParameters),
option.map(parameters => {
const intercalated = intercalateSerializedTypes(serializedType(';', ',', [], []), parameters);
return pipe(intercalated, getSerializedObjectType());
}),
);
const serializedQueryString = pipe(
nonEmptyArray.fromArray(queryStringFragments),
option.map(queryStringFragments =>
intercalateSerializedFragmentsNEA(serializedFragment(',', [], []), queryStringFragments),
),
option.map(f =>
combineFragmentsK(f, c =>
serializedFragment(
`encodeURIComponent(compact([${c}]).join('&'))`,
[serializedDependency('compact', 'fp-ts/lib/Array')],
[],
),
),
),
);
return right({
pathParameters,
serializedPathParameters,
serializedQueryParameter,
serializedBodyParameter,
serializedQueryString,