Skip to content

Commit

Permalink
Inline Spec File (#129)
Browse files Browse the repository at this point in the history
* fix: make application/json the default content type in binary mode (#118)

The Knative Kafka event source does not include a `Content-Type` header when
sending binary events. The CE HTTP binding specification doesn't address how
a receiver should handle this situation.

This commit makes `application/json` the default.

Fixes: #117
Ref: cloudevents/spec#614

Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* refactor: remove ext folder

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

* Revert "fix: make application/json the default content type in binary mode (#118)"

This reverts commit 9ccfaf2.

Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>

Co-authored-by: Lance Ball <lball@redhat.com>
  • Loading branch information
grant and lance authored May 6, 2020
1 parent 54f242b commit 106b943
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 170 deletions.
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

0 comments on commit 106b943

Please sign in to comment.