How to use @azure/oad - 1 common examples

To help you get started, we’ve selected a few @azure/oad 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 Azure / azure-rest-api-specs / scripts / breaking-change.ts View on Github external
async function runOad(oldSpec: string, newSpec: string) {
  if (oldSpec === null || oldSpec === undefined || typeof oldSpec.valueOf() !== 'string' || !oldSpec.trim().length) {
    throw new Error('oldSpec is a required parameter of type "string" and it cannot be an empty string.');
  }

  if (newSpec === null || newSpec === undefined || typeof newSpec.valueOf() !== 'string' || !newSpec.trim().length) {
    throw new Error('newSpec is a required parameter of type "string" and it cannot be an empty string.');
  }

  console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`);
  console.log(`Old Spec: "${oldSpec}"`);
  console.log(`New Spec: "${newSpec}"`);
  console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`);

  let result = await oad.compare(oldSpec, newSpec, { consoleLogLevel: 'warn' });
  console.log(result);

  if (!result) {
    return;
  }

  // fix up output from OAD, it does not output valid JSON
  result = '[' + result.replace(/}\s+{/gi,"},{") + ']'

  return JSON.parse(result);
}

@azure/oad

OpenApi Specification Diff tool

MIT
Latest version published 1 month ago

Package Health Score

76 / 100
Full package analysis

Popular @azure/oad functions