Please add Schema.examples, and perhaps validateExamples(schema) to validate each example against the schema, similar to this code from my Jasmine tests.
type Schema = JsonSchema.Schema // & { examples : [] };
let Validator = require('jsonschema').Validator;
let validator = new Validator();
function validateExamples(schema : Schema) {
(schema as any).examples.map((e : any) => {
const result = validator.validate(e, schema);
expect(result.errors).toEqual([]);
if (result.errors.length) { console.log('validate()', e, result); }
});
}
JSON Schema draft 6 adds an
examples
array "to provide an array of examples that validate against the schema": https://json-schema.org/understanding-json-schema/reference/generic.html#annotationsPlease add
Schema.examples
, and perhapsvalidateExamples(schema)
to validate each example against the schema, similar to this code from my Jasmine tests.