fix: the unknown keyword in the schema without known keywords inside compound schema (e.g. anyOf) is ignored with strictKeywords option
parent
669bf96c79
commit
53b5682cb7
|
@ -63,7 +63,9 @@
|
|||
|
||||
|
||||
{{## def.nonEmptySchema:_schema:
|
||||
it.util.schemaHasRules(_schema, it.RULES.all)
|
||||
(it.opts.strictKeywords
|
||||
? typeof _schema == 'object' && Object.keys(_schema).length > 0
|
||||
: it.util.schemaHasRules(_schema, it.RULES.all))
|
||||
#}}
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,19 @@ describe('strictKeywords option', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('unknown keyword inside schema that has no known keyword in compound keyword', function() {
|
||||
it('should throw an error given an unknown keyword when strictKeywords is true', function() {
|
||||
var ajv = new Ajv({strictKeywords: true});
|
||||
var schema = {
|
||||
anyOf: [
|
||||
{
|
||||
unknownKeyword: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
should.throw(function() { ajv.compile(schema); });
|
||||
});
|
||||
});
|
||||
|
||||
function getLogger(output) {
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue