forked from playlyfe/themis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): implement canonical dereferencing of external json schema …
…fragments Fixes playlyfe#3
- Loading branch information
Johny Jose
committed
Jan 27, 2015
1 parent
d891610
commit 768ebe3
Showing
2 changed files
with
52 additions
and
3 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
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,39 @@ | ||
Themis = require('../src/themis'); | ||
|
||
describe('Issue #3: Crashing when pattern is incorrect in ref(erenced) schema', function() { | ||
|
||
it('should be able to dereference fragments of external schemas', function() { | ||
var schemas = [ | ||
{ | ||
"id": "types", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"definitions": { | ||
"uuid": { | ||
"type": "string", | ||
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "kitchensink", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"properties": { | ||
"id": { "$ref": "types#/definitions/uuid" } | ||
} | ||
} | ||
]; | ||
|
||
var validator = Themis.validator(schemas); | ||
|
||
var invalid_item = { | ||
"id": "incorrect value" | ||
}; | ||
var valid_item = { | ||
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" | ||
} | ||
validator(invalid_item, 'kitchensink').valid.should.be.false; | ||
validator(valid_item, 'kitchensink').valid.should.be.true; | ||
}); | ||
|
||
}); |