openapi-diff.ts 903 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* eslint-env node */
  2. import fs from 'fs';
  3. import https from 'https';
  4. import yaml from 'js-yaml';
  5. import jsonDiff from 'json-diff';
  6. async function main() {
  7. const openApiData = await new Promise((resolve, reject) =>
  8. https.get(
  9. `https://raw.githubusercontent.com/getsentry/sentry-api-schema/main/openapi-derefed.json`,
  10. res => {
  11. res.setEncoding('utf8');
  12. let rawData = '';
  13. res.on('data', chunk => (rawData += chunk));
  14. res.on('end', () => {
  15. try {
  16. resolve(JSON.parse(rawData));
  17. } catch (e) {
  18. reject(e.message);
  19. }
  20. });
  21. }
  22. )
  23. );
  24. const readFile = fs.readFileSync('tests/apidocs/openapi-derefed.json', 'utf8');
  25. const target = yaml.safeLoad(readFile);
  26. // biome-ignore lint/suspicious/noConsoleLog: Disable console
  27. console.log(jsonDiff.diffString(openApiData, target));
  28. }
  29. main();