Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: addKeyword and schema without ID, closes #1001
- Loading branch information
1 parent
bc993de
commit ab841b4
Showing
4 changed files
with
59 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
var metaSchema = require('./refs/json-schema-draft-07.json'); | ||
|
||
module.exports = { | ||
$id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js', | ||
definitions: { | ||
simpleTypes: metaSchema.definitions.simpleTypes | ||
}, | ||
type: 'object', | ||
dependencies: { | ||
schema: ['validate'], | ||
$data: ['validate'], | ||
statements: ['inline'], | ||
valid: {not: {required: ['macro']}} | ||
}, | ||
properties: { | ||
type: metaSchema.properties.type, | ||
schema: {type: 'boolean'}, | ||
statements: {type: 'boolean'}, | ||
dependencies: { | ||
type: 'array', | ||
items: {type: 'string'} | ||
}, | ||
metaSchema: {type: 'object'}, | ||
modifying: {type: 'boolean'}, | ||
valid: {type: 'boolean'}, | ||
$data: {type: 'boolean'}, | ||
async: {type: 'boolean'}, | ||
errors: { | ||
anyOf: [ | ||
{type: 'boolean'}, | ||
{const: 'full'} | ||
] | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule JSON-Schema-Test-Suite
updated
from 15ba99 to eadeac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
var Ajv = require('../ajv'); | ||
require('../chai').should(); | ||
|
||
|
||
describe('issue #1001: addKeyword breaks schema without ID', function() { | ||
it('should allow using schemas without ID with addKeyword', function() { | ||
var schema = { | ||
definitions: { | ||
foo: {} | ||
} | ||
}; | ||
|
||
var ajv = new Ajv(); | ||
ajv.addSchema(schema); | ||
ajv.addKeyword('myKeyword', {}); | ||
ajv.getSchema('#/definitions/foo') .should.be.a('function'); | ||
}); | ||
}); |