diff --git a/lib/afterRequest.json b/lib/afterRequest.json index 5f52581..10f37d3 100644 --- a/lib/afterRequest.json +++ b/lib/afterRequest.json @@ -2,7 +2,6 @@ "$id": "afterRequest.json#", "$schema": "http://json-schema.org/draft-06/schema#", "type": "object", - "optional": true, "required": [ "lastAccess", "eTag", diff --git a/lib/beforeRequest.json b/lib/beforeRequest.json index c7b5c10..afad6d0 100644 --- a/lib/beforeRequest.json +++ b/lib/beforeRequest.json @@ -2,7 +2,6 @@ "$id": "beforeRequest.json#", "$schema": "http://json-schema.org/draft-06/schema#", "type": "object", - "optional": true, "required": [ "lastAccess", "eTag", diff --git a/lib/entry.json b/lib/entry.json index 18025f4..f6e0ead 100644 --- a/lib/entry.json +++ b/lib/entry.json @@ -2,7 +2,6 @@ "$id": "entry.json#", "$schema": "http://json-schema.org/draft-06/schema#", "type": "object", - "optional": true, "required": [ "startedDateTime", "time", @@ -22,7 +21,7 @@ }, "time": { "type": "number", - "min": 0 + "minimum": 0 }, "request": { "$ref": "request.json#" @@ -37,10 +36,9 @@ "$ref": "timings.json#" }, "serverIPAddress": { - "type": "string", "oneOf": [ - { "format": "ipv4" }, - { "format": "ipv6" } + { "type": "string", "format": "ipv4" }, + { "type": "string", "format": "ipv6" } ] }, "connection": { diff --git a/lib/index.js b/lib/index.js index 244c08e..a92a39a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -14,6 +14,7 @@ module.exports = { log: require('./log.json'), page: require('./page.json'), pageTimings: require('./pageTimings.json'), + param: require('./param.json'), postData: require('./postData.json'), query: require('./query.json'), request: require('./request.json'), diff --git a/lib/page.json b/lib/page.json index e24a3ce..963b561 100644 --- a/lib/page.json +++ b/lib/page.json @@ -2,7 +2,6 @@ "$id": "page.json#", "$schema": "http://json-schema.org/draft-06/schema#", "type": "object", - "optional": true, "required": [ "startedDateTime", "id", @@ -16,8 +15,7 @@ "pattern": "^(\\d{4})(-)?(\\d\\d)(-)?(\\d\\d)(T)?(\\d\\d)(:)?(\\d\\d)(:)?(\\d\\d)(\\.\\d+)?(Z|([+-])(\\d\\d)(:)?(\\d\\d))" }, "id": { - "type": "string", - "unique": true + "type": "string" }, "title": { "type": "string" diff --git a/lib/pageTimings.json b/lib/pageTimings.json index 130411f..3fe9b19 100644 --- a/lib/pageTimings.json +++ b/lib/pageTimings.json @@ -5,11 +5,11 @@ "properties": { "onContentLoad": { "type": "number", - "min": -1 + "minimum": -1 }, "onLoad": { "type": "number", - "min": -1 + "minimum": -1 }, "comment": { "type": "string" diff --git a/lib/param.json b/lib/param.json new file mode 100644 index 0000000..22352dd --- /dev/null +++ b/lib/param.json @@ -0,0 +1,25 @@ +{ + "$id": "param.json#", + "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "comment": { + "type": "string" + } + } +} diff --git a/lib/postData.json b/lib/postData.json index 3aa6294..f068ccb 100644 --- a/lib/postData.json +++ b/lib/postData.json @@ -2,7 +2,6 @@ "$id": "postData.json#", "$schema": "http://json-schema.org/draft-06/schema#", "type": "object", - "optional": true, "required": [ "mimeType" ], @@ -15,25 +14,8 @@ }, "params": { "type": "array", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "contentType": { - "type": "string" - }, - "comment": { - "type": "string" - } + "items": { + "$ref": "param.json#" } }, "comment": { diff --git a/lib/timings.json b/lib/timings.json index 5fe7dc7..052dd4e 100644 --- a/lib/timings.json +++ b/lib/timings.json @@ -1,6 +1,7 @@ { "$id": "timings.json#", "$schema": "http://json-schema.org/draft-06/schema#", + "type": "object", "required": [ "send", "wait", @@ -9,31 +10,31 @@ "properties": { "dns": { "type": "number", - "min": -1 + "minimum": -1 }, "connect": { "type": "number", - "min": -1 + "minimum": -1 }, "blocked": { "type": "number", - "min": -1 + "minimum": -1 }, "send": { "type": "number", - "min": -1 + "minimum": -1 }, "wait": { "type": "number", - "min": -1 + "minimum": -1 }, "receive": { "type": "number", - "min": -1 + "minimum": -1 }, "ssl": { "type": "number", - "min": -1 + "minimum": -1 }, "comment": { "type": "string" diff --git a/package.json b/package.json index 8064413..4beb010 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ } }, "devDependencies": { - "ajv": "^5.0.0", + "ajv": "^6.5.2", "codeclimate-test-reporter": "^0.4.0", "cz-conventional-changelog": "^1.2.0", "echint": "^2.1.0", diff --git a/test/index.js b/test/index.js index 7a1fcb8..069dbb9 100644 --- a/test/index.js +++ b/test/index.js @@ -6,6 +6,9 @@ const tap = require('tap') tap.test('har-schema', (assert) => { const ajv = new Ajv() + const metaSchema = require('ajv/lib/refs/json-schema-draft-06.json') + metaSchema.additionalProperties = false + ajv.addMetaSchema(metaSchema) const keys = Object.keys(schemas) assert.plan(keys.length * 2)