forked from getsentry/sentry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi-diff.ts
37 lines (31 loc) · 956 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
34
35
36
37
/* eslint-env node */
/* eslint import/no-nodejs-modules:0 */
/* eslint import/no-unresolved:0 */
import fs from 'fs';
import https from 'https';
import yaml from 'js-yaml';
import jsonDiff from 'json-diff';
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');
const target = yaml.safeLoad(readFile);
// eslint-disable-next-line no-console
console.log(jsonDiff.diffString(openApiData, target));
}
main();