forked from openzipkin/zipkin-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.js
31 lines (25 loc) · 795 Bytes
/
validate.js
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
'use strict';
const Sway = require('sway');
const read = require('fs').readFileSync;
const load = require('js-yaml').load;
const yamls = ['./zipkin-api.yaml', './zipkin2-api.yaml'];
yamls.forEach(yaml => {
const zipkinAPI = read(yaml).toString();
Sway.create({definition: load(zipkinAPI)}).then(api => {
const result = api.validate();
if (result.errors.length) {
console.error(`Validation failed for ${yaml}`)
console.error(JSON.stringify(result.errors));
return;
}
if (result.warnings.length) {
console.warn(`Warnings in ${yaml}:`)
console.warn(JSON.stringify(result.warnings));
}
console.log(`Validation of ${yaml} passed`);
})
.catch(error=> {
console.error(`Error loading ${yaml}`);
console.error(error);
});
});