Skip to content

Inline Spec File #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
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
88 changes: 0 additions & 88 deletions ext/spec_0_3.json

This file was deleted.

80 changes: 0 additions & 80 deletions ext/spec_1.json

This file was deleted.

87 changes: 86 additions & 1 deletion lib/specs/spec_0_3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
81 changes: 80 additions & 1 deletion lib/specs/spec_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down