Skip to content

Commit 106b943

Browse files
grantlance
andauthored
Inline Spec File (#129)
* 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 <[email protected]> Signed-off-by: Grant Timmerman <[email protected]> * refactor: remove ext folder Signed-off-by: Grant Timmerman <[email protected]> * Revert "fix: make application/json the default content type in binary mode (#118)" This reverts commit 9ccfaf2. Signed-off-by: Grant Timmerman <[email protected]> Co-authored-by: Lance Ball <[email protected]>
1 parent 54f242b commit 106b943

File tree

4 files changed

+166
-170
lines changed

4 files changed

+166
-170
lines changed

ext/spec_0_3.json

Lines changed: 0 additions & 88 deletions
This file was deleted.

ext/spec_1.json

Lines changed: 0 additions & 80 deletions
This file was deleted.

lib/specs/spec_0_3.js

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,92 @@ SUPPORTED_CONTENT_ENCODING.base64 = {
2525
check: (data) => isBase64(data)
2626
};
2727

28-
const schema = require("../../ext/spec_0_3.json");
28+
const schema = {
29+
$ref: "#/definitions/event",
30+
definitions: {
31+
specversion: {
32+
const: "0.3"
33+
},
34+
datacontenttype: {
35+
type: "string"
36+
},
37+
data: {
38+
type: [
39+
"object",
40+
"string"
41+
]
42+
},
43+
event: {
44+
properties: {
45+
specversion: {
46+
$ref: "#/definitions/specversion"
47+
},
48+
datacontenttype: {
49+
$ref: "#/definitions/datacontenttype"
50+
},
51+
data: {
52+
$ref: "#/definitions/data"
53+
},
54+
id: {
55+
$ref: "#/definitions/id"
56+
},
57+
time: {
58+
$ref: "#/definitions/time"
59+
},
60+
schemaurl: {
61+
$ref: "#/definitions/schemaurl"
62+
},
63+
subject: {
64+
$ref: "#/definitions/subject"
65+
},
66+
type: {
67+
$ref: "#/definitions/type"
68+
},
69+
extensions: {
70+
$ref: "#/definitions/extensions"
71+
},
72+
source: {
73+
$ref: "#/definitions/source"
74+
}
75+
},
76+
required: [
77+
"specversion",
78+
"id",
79+
"type",
80+
"source"
81+
],
82+
type: "object"
83+
},
84+
id: {
85+
type: "string",
86+
minLength: 1
87+
},
88+
time: {
89+
format: "date-time",
90+
type: "string"
91+
},
92+
schemaurl: {
93+
type: "string",
94+
format: "uri-reference"
95+
},
96+
subject: {
97+
type: "string",
98+
minLength: 1
99+
},
100+
type: {
101+
type: "string",
102+
minLength: 1
103+
},
104+
extensions: {
105+
type: "object"
106+
},
107+
source: {
108+
format: "uri-reference",
109+
type: "string"
110+
}
111+
},
112+
type: "object"
113+
};
29114

30115
const ajv = new Ajv({
31116
extendRefs: true

lib/specs/spec_1.js

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,86 @@ const RESERVED_ATTRIBUTES = {
2727
data_base64: "data_base64"
2828
};
2929

30-
const schema = require("../../ext/spec_1.json");
30+
const schema = {
31+
$ref: "#/definitions/event",
32+
definitions: {
33+
specversion: {
34+
type: "string",
35+
minLength: 1,
36+
const: "1.0"
37+
},
38+
datacontenttype: {
39+
type: "string"
40+
},
41+
data: {
42+
type: ["object", "string"]
43+
},
44+
data_base64: {
45+
type: "string"
46+
},
47+
event: {
48+
properties: {
49+
specversion: {
50+
$ref: "#/definitions/specversion"
51+
},
52+
datacontenttype: {
53+
$ref: "#/definitions/datacontenttype"
54+
},
55+
data: {
56+
$ref: "#/definitions/data"
57+
},
58+
data_base64: {
59+
$ref: "#/definitions/data_base64"
60+
},
61+
id: {
62+
$ref: "#/definitions/id"
63+
},
64+
time: {
65+
$ref: "#/definitions/time"
66+
},
67+
dataschema: {
68+
$ref: "#/definitions/dataschema"
69+
},
70+
subject: {
71+
$ref: "#/definitions/subject"
72+
},
73+
type: {
74+
$ref: "#/definitions/type"
75+
},
76+
source: {
77+
$ref: "#/definitions/source"
78+
}
79+
},
80+
required: ["specversion", "id", "type", "source"],
81+
type: "object"
82+
},
83+
id: {
84+
type: "string",
85+
minLength: 1
86+
},
87+
time: {
88+
format: "date-time",
89+
type: "string"
90+
},
91+
dataschema: {
92+
type: "string",
93+
format: "uri"
94+
},
95+
subject: {
96+
type: "string",
97+
minLength: 1
98+
},
99+
type: {
100+
type: "string",
101+
minLength: 1
102+
},
103+
source: {
104+
format: "uri-reference",
105+
type: "string"
106+
}
107+
},
108+
type: "object"
109+
};
31110

32111
const ajv = new Ajv({
33112
extendRefs: true

0 commit comments

Comments
 (0)