diff --git a/ext/spec_0_3.json b/ext/spec_0_3.json deleted file mode 100644 index 2c362698..00000000 --- a/ext/spec_0_3.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "$ref": "#/definitions/event", - "definitions": { - "specversion": { - "type": "string", - "minLength": 1, - "const": "0.3" - }, - "datacontenttype": { - "type": "string" - }, - "data": { - "type": [ - "object", - "string" - ] - }, - "event": { - "properties": { - "specversion": { - "$ref": "#/definitions/specversion" - }, - "datacontenttype": { - "$ref": "#/definitions/datacontenttype" - }, - "data": { - "$ref": "#/definitions/data" - }, - "id": { - "$ref": "#/definitions/id" - }, - "time": { - "$ref": "#/definitions/time" - }, - "schemaurl": { - "$ref": "#/definitions/schemaurl" - }, - "subject": { - "$ref": "#/definitions/subject" - }, - "type": { - "$ref": "#/definitions/type" - }, - "extensions": { - "$ref": "#/definitions/extensions" - }, - "source": { - "$ref": "#/definitions/source" - } - }, - "required": [ - "specversion", - "id", - "type", - "source" - ], - "type": "object" - }, - "id": { - "type": "string", - "minLength": 1 - }, - "time": { - "format": "date-time", - "type": "string" - }, - "schemaurl": { - "type": "string", - "format": "uri-reference" - }, - "subject": { - "type": "string", - "minLength": 1 - }, - "type": { - "type": "string", - "minLength": 1 - }, - "extensions": { - "type": "object" - }, - "source": { - "format": "uri-reference", - "type": "string" - } - }, - "type": "object" -} diff --git a/ext/spec_1.json b/ext/spec_1.json deleted file mode 100644 index 50e1a607..00000000 --- a/ext/spec_1.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "$ref": "#/definitions/event", - "definitions": { - "specversion": { - "type": "string", - "minLength": 1, - "const": "1.0" - }, - "datacontenttype": { - "type": "string" - }, - "data": { - "type": ["object", "string"] - }, - "data_base64": { - "type": "string" - }, - "event": { - "properties": { - "specversion": { - "$ref": "#/definitions/specversion" - }, - "datacontenttype": { - "$ref": "#/definitions/datacontenttype" - }, - "data": { - "$ref": "#/definitions/data" - }, - "data_base64": { - "$ref": "#/definitions/data_base64" - }, - "id": { - "$ref": "#/definitions/id" - }, - "time": { - "$ref": "#/definitions/time" - }, - "dataschema": { - "$ref": "#/definitions/dataschema" - }, - "subject": { - "$ref": "#/definitions/subject" - }, - "type": { - "$ref": "#/definitions/type" - }, - "source": { - "$ref": "#/definitions/source" - } - }, - "required": ["specversion", "id", "type", "source"], - "type": "object" - }, - "id": { - "type": "string", - "minLength": 1 - }, - "time": { - "format": "date-time", - "type": "string" - }, - "dataschema": { - "type": "string", - "format": "uri" - }, - "subject": { - "type": "string", - "minLength": 1 - }, - "type": { - "type": "string", - "minLength": 1 - }, - "source": { - "format": "uri-reference", - "type": "string" - } - }, - "type": "object" -} diff --git a/lib/specs/spec_0_3.js b/lib/specs/spec_0_3.js index 66752952..f07e0fb1 100644 --- a/lib/specs/spec_0_3.js +++ b/lib/specs/spec_0_3.js @@ -25,7 +25,92 @@ SUPPORTED_CONTENT_ENCODING.base64 = { check: (data) => isBase64(data) }; -const schema = require("../../ext/spec_0_3.json"); +const schema = { + $ref: "#/definitions/event", + definitions: { + specversion: { + const: "0.3" + }, + datacontenttype: { + type: "string" + }, + data: { + type: [ + "object", + "string" + ] + }, + event: { + properties: { + specversion: { + $ref: "#/definitions/specversion" + }, + datacontenttype: { + $ref: "#/definitions/datacontenttype" + }, + data: { + $ref: "#/definitions/data" + }, + id: { + $ref: "#/definitions/id" + }, + time: { + $ref: "#/definitions/time" + }, + schemaurl: { + $ref: "#/definitions/schemaurl" + }, + subject: { + $ref: "#/definitions/subject" + }, + type: { + $ref: "#/definitions/type" + }, + extensions: { + $ref: "#/definitions/extensions" + }, + source: { + $ref: "#/definitions/source" + } + }, + required: [ + "specversion", + "id", + "type", + "source" + ], + type: "object" + }, + id: { + type: "string", + minLength: 1 + }, + time: { + format: "date-time", + type: "string" + }, + schemaurl: { + type: "string", + format: "uri-reference" + }, + subject: { + type: "string", + minLength: 1 + }, + type: { + type: "string", + minLength: 1 + }, + extensions: { + type: "object" + }, + source: { + format: "uri-reference", + type: "string" + } + }, + type: "object" +}; const ajv = new Ajv({ extendRefs: true diff --git a/lib/specs/spec_1.js b/lib/specs/spec_1.js index 89e13b49..6415d15e 100644 --- a/lib/specs/spec_1.js +++ b/lib/specs/spec_1.js @@ -27,7 +27,86 @@ const RESERVED_ATTRIBUTES = { data_base64: "data_base64" }; -const schema = require("../../ext/spec_1.json"); +const schema = { + $ref: "#/definitions/event", + definitions: { + specversion: { + type: "string", + minLength: 1, + const: "1.0" + }, + datacontenttype: { + type: "string" + }, + data: { + type: ["object", "string"] + }, + data_base64: { + type: "string" + }, + event: { + properties: { + specversion: { + $ref: "#/definitions/specversion" + }, + datacontenttype: { + $ref: "#/definitions/datacontenttype" + }, + data: { + $ref: "#/definitions/data" + }, + data_base64: { + $ref: "#/definitions/data_base64" + }, + id: { + $ref: "#/definitions/id" + }, + time: { + $ref: "#/definitions/time" + }, + dataschema: { + $ref: "#/definitions/dataschema" + }, + subject: { + $ref: "#/definitions/subject" + }, + type: { + $ref: "#/definitions/type" + }, + source: { + $ref: "#/definitions/source" + } + }, + required: ["specversion", "id", "type", "source"], + type: "object" + }, + id: { + type: "string", + minLength: 1 + }, + time: { + format: "date-time", + type: "string" + }, + dataschema: { + type: "string", + format: "uri" + }, + subject: { + type: "string", + minLength: 1 + }, + type: { + type: "string", + minLength: 1 + }, + source: { + format: "uri-reference", + type: "string" + } + }, + type: "object" +}; const ajv = new Ajv({ extendRefs: true