Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async parseResolveResult(opts) {
try {
opts.result = parse(opts.result);
} catch {
// happens
}
return opts;
},
},
return async function processRuleset(
baseUri: string,
uri: string,
severity?: FileRulesetSeverity,
): Promise {
const rulesetUri = await findFile(join(baseUri, '..'), uri);
if (processedRulesets.has(rulesetUri)) {
return null;
}
processedRulesets.add(rulesetUri);
const { result } = await httpAndFileResolver.resolve(
parse(
await readParsable(rulesetUri, {
timeout: readOpts && readOpts.timeout,
encoding: 'utf8',
}),
),
{
baseUri: rulesetUri,
dereferenceInline: false,
uriCache,
async parseResolveResult(opts) {
try {
opts.result = parse(opts.result);
} catch {
// happens
}
return opts;
parseResolveResult(opts) {
opts.result = parse(opts.result);
return opts;
},
})).result);
export default async function getHttpOperations(specContent: string, baseUri?: string): Promise {
const parsedContent = parse(specContent);
const { result: resolvedContent, errors } = await httpAndFileResolver.resolve(parsedContent, { baseUri });
if (errors.length) {
const uniqueErrors = uniq(errors.map(error => error.message)).join(EOL);
throw new Error(
`There's been an error while trying to resolve external references in your document: ${uniqueErrors}`
);
}
const isOas2 = get(parsedContent, 'swagger');
const transformOperationFn = isOas2 ? transformOas2Operation : transformOas3Operation;
const paths = keys(get(resolvedContent, 'paths'));
const methods = ['get', 'post', 'put', 'delete', 'options', 'head', 'patch', 'trace'];
return flatten(
parseResolveResult: async opts => {
opts.result = parse(opts.result);
return opts;
},
});
parseResolveResult: opts => Promise.resolve({ ...opts, result: parse(opts.result) }),
});