How to use the @stoplight/json-ref-resolver.Cache function in @stoplight/json-ref-resolver

To help you get started, we’ve selected a few @stoplight/json-ref-resolver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoplightio / spectral / src / rulesets / reader.ts View on Github external
export async function readRuleset(uris: string | string[], opts?: IRulesetReadOptions): Promise {
  const base: IRuleset = {
    rules: {},
    functions: {},
  };

  const processedRulesets = new Set();
  const processRuleset = createRulesetProcessor(processedRulesets, new Cache(), opts);

  for (const uri of Array.isArray(uris) ? new Set([...uris]) : [uris]) {
    processedRulesets.clear(); // makes sure each separate ruleset starts with clear list
    const resolvedRuleset = await processRuleset(uri, uri);
    if (resolvedRuleset === null) continue;
    Object.assign(base.rules, resolvedRuleset.rules);
    Object.assign(base.functions, resolvedRuleset.functions);
  }

  return base;
}

@stoplight/json-ref-resolver

Recursively resolve JSON pointers and remote authorities.

Apache-2.0
Latest version published 1 year ago

Package Health Score

56 / 100
Full package analysis