Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Unable to compose schema with references #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions spec/pack_validate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,27 @@ describe('module for a single validation function', function() {
assert.strictEqual(packedValidate('baz'), false);
});

it('should composition of referenced schemas and definitions', function() {
ajv = new Ajv({sourceCode: true, inlineRefs: false});
ajv.addSchema({ id: 'value', type: 'number' });

var schema = {
definitions: {
word: { type: 'string' }
},
oneOf: [
// swapping these lines fixes it:
{ $ref: 'value' },
{ $ref: '#/definitions/word' },
]
};

var packedValidate = packCompile(schema);

assert.strictEqual(packedValidate(42), true);
assert.strictEqual(packedValidate('foo'), true);
});

it('should support format keyword', function() {
var schema = { type: 'string', format: 'date' };
var packedValidate = packCompile(schema);
Expand Down