-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathopenapi-diff.ts
33 lines (29 loc) · 941 Bytes
/
openapi-diff.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import yaml from 'js-yaml';
import jsonDiff from 'json-diff';
import fs from 'node:fs';
import https from 'node:https';
async function main() {
const openApiData = await new Promise((resolve, reject) =>
https.get(
`https://raw.githubusercontent.com/getsentry/sentry-api-schema/main/openapi-derefed.json`,
res => {
res.setEncoding('utf8');
let rawData = '';
res.on('data', chunk => (rawData += chunk));
res.on('end', () => {
try {
resolve(JSON.parse(rawData));
} catch (e) {
reject(e.message);
}
});
}
)
);
const readFile = fs.readFileSync('tests/apidocs/openapi-derefed.json', 'utf8');
// @ts-expect-error: Types do not match the version of js-yaml installed
const target = yaml.safeLoad(readFile);
// eslint-disable-next-line no-console
console.log(jsonDiff.diffString(openApiData, target));
}
main();