How to use the @stoplight/yaml.parse function in @stoplight/yaml

To help you get started, we’ve selected a few @stoplight/yaml 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
async parseResolveResult(opts) {
          try {
            opts.result = parse(opts.result);
          } catch {
            // happens
          }
          return opts;
        },
      },
github stoplightio / spectral / src / rulesets / reader.ts View on Github external
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;
github stoplightio / spectral / scripts / generate-assets.js View on Github external
parseResolveResult(opts) {
            opts.result = parse(opts.result);
            return opts;
          },
        })).result);
github stoplightio / prism / packages / http / src / getHttpOperations.ts View on Github external
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(
github stoplightio / prism / packages / http / src / resolvers / http-and-file.ts View on Github external
parseResolveResult: async opts => {
    opts.result = parse(opts.result);
    return opts;
  },
});
github stoplightio / prism / packages / http / src / getHttpOperations.ts View on Github external
  parseResolveResult: opts => Promise.resolve({ ...opts, result: parse(opts.result) }),
});

@stoplight/yaml

Useful functions when working with YAML.

Apache-2.0
Latest version published 8 months ago

Package Health Score

67 / 100
Full package analysis