Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
o?: Operation,
): Option<[MethodNames, Operation]> =>
o ? some([n, o]) : getFirstMethodInternal(m, p);
const getFirstMethodInternal = (m: MethodNames[], p: PathItem): Option<[MethodNames, Operation]> =>
m.length === 0 ? none : getFirstMethodInternal2(p, m[0], m.slice(1), p[m[0]]);
export const getFirstMethod = (p: PathItem): Option<[MethodNames, Operation]> =>
getFirstMethodInternal(allMethods, p);
/**
* Gets `some` random operation (the first one) from a path item
* or `none` if there are no operations
* @param p A path item
*/
export const operationOptional = new Optional(
a => getFirstMethod(a),
a => s => ({ ...s, [a[0]]: a[1]}),
);
/**
* Gets `some` header from a reference
* or `none` if the reference doesn't exist
* @param o an open api object
* @param d the name of the header reference
*/
export const getHeaderFromRef = (o: OpenAPIObject, d: string): Option<header> =>
getComponentFromRef(
o,
d,
a => (a.headers ? some(a.headers) : none),
internalGetHeaderFromRef,</header>
const getFirstMethodInternal = (
m: MethodNames[],
p: PathItem,
): Option<[MethodNames, Operation]> =>
m.length === 0 ? none : getFirstMethodInternal2(p, m[0], m.slice(1), p[m[0]]);
export const getFirstMethod = (p: PathItem): Option<[MethodNames, Operation]> =>
getFirstMethodInternal(allMethods, p);
/**
* Gets `some` random operation (the first one) from a path item
* or `none` if there are no operations
* @param p A path item
*/
export const operationOptional = new Optional<
PathItem,
[MethodNames, Operation]
>(a => getFirstMethod(a), a => s => ({ ...s, [a[0]]: a[1] }));
/**
* Gets `some` header from a reference
* or `none` if the reference doesn't exist
* @param o an open api object
* @param d the name of the header reference
*/
export const getHeaderFromRef = (o: OpenAPIObject, d: string): Option<header> =>
getComponentFromRef(
o,
d,
a => (a.headers ? some(a.headers) : none),
internalGetHeaderFromRef,</header>