Files
redocly-cli/benchmark/benches/validate-with-top-level-rule-report.bench.ts
2020-06-20 10:27:14 +03:00

36 lines
910 B
TypeScript

import { readFileSync } from 'fs';
import { join as pathJoin, resolve as pathResolve } from 'path';
import { validateDocument } from '../../src/validate';
import { parseYamlToDocument, makeConfigForRuleset } from '../../src/__tests__/utils';
export const name = 'Validate with single top-level rule and report';
export const count = 10;
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml'));
const rebillyDocument = parseYamlToDocument(
readFileSync(rebillyDefinitionRef, 'utf-8'),
rebillyDefinitionRef,
);
const config = makeConfigForRuleset({
test: () => {
return {
Schema(schema, ctx) {
if (schema.type === 'number') {
ctx.report({
message: 'type number is not allowed',
});
}
},
};
},
});
export function measureAsync() {
return validateDocument({
document: rebillyDocument,
config,
});
}