diff --git a/index.js b/index.js index 6a3143b3..9b8df936 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ runTest(4); runTest(6); function runTest(draft) { - var opts = {}; + var opts = {format: 'full'}; if (draft == 4) opts.meta = false; var ajv = new Ajv(opts); ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json')); diff --git a/package.json b/package.json index 28df9b4c..8cb62230 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme", "devDependencies": { - "ajv": "^5.0.4-beta.0", + "ajv": "^5.0.4-beta.1", "json-schema-test": "^1.3.0", "mocha": "^3.2.0" } diff --git a/tests/draft6/optional/format.json b/tests/draft6/optional/format.json index 80373bdf..677891cd 100644 --- a/tests/draft6/optional/format.json +++ b/tests/draft6/optional/format.json @@ -34,6 +34,11 @@ "data": "//foo.bar/?baz=qux#quux", "valid": false }, + { + "description": "an invalid relative URI Reference", + "data": "/abc", + "valid": false + }, { "description": "an invalid URI", "data": "\\\\WINDOWS\\fileshare", @@ -46,6 +51,75 @@ } ] }, + { + "description": "validation of URI References", + "schema": {"format": "uri-reference"}, + "tests": [ + { + "description": "a valid URI", + "data": "http://foo.bar/?baz=qux#quux", + "valid": true + }, + { + "description": "a valid protocol-relative URI Reference", + "data": "//foo.bar/?baz=qux#quux", + "valid": true + }, + { + "description": "a valid relative URI Reference", + "data": "/abc", + "valid": true + }, + { + "description": "an invalid URI Reference", + "data": "\\\\WINDOWS\\fileshare", + "valid": false + }, + { + "description": "a valid URI Reference", + "data": "abc", + "valid": true + }, + { + "description": "a valid URI fragment", + "data": "#fragment", + "valid": true + }, + { + "description": "an invalid URI fragment", + "data": "#frag\\ment", + "valid": false + } + ] + }, + { + "description": "format: uri-template", + "schema": { + "format": "uri-template" + }, + "tests": [ + { + "description": "a valid uri-template", + "data": "http://example.com/dictionary/{term:1}/{term}", + "valid": true + }, + { + "description": "an invalid uri-template", + "data": "http://example.com/dictionary/{term:1}/{term", + "valid": false + }, + { + "description": "a valid uri-template without variables", + "data": "http://example.com/dictionary", + "valid": true + }, + { + "description": "a valid relative uri-template", + "data": "dictionary/{term:1}/{term}", + "valid": true + } + ] + }, { "description": "validation of e-mail addresses", "schema": {"format": "email"}, @@ -144,5 +218,41 @@ "valid": false } ] + }, + { + "description": "validation of JSON-pointers", + "schema": {"format": "json-pointer"}, + "tests": [ + { + "description": "a valid JSON-pointer", + "data": "/foo/bar~0/baz~1/%a", + "valid": true + }, + { + "description": "empty string is valid", + "data": "", + "valid": true + }, + { + "description": "/ is valid", + "data": "/", + "valid": true + }, + { + "description": "not a valid JSON-pointer (~ not escaped)", + "data": "/foo/bar~", + "valid": false + }, + { + "description": "valid JSON-pointer with empty segment", + "data": "/foo//bar", + "valid": true + }, + { + "description": "valid JSON-pointer with the last empty segment", + "data": "/foo/bar/", + "valid": true + } + ] } ]