Skip to content
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
4 changes: 2 additions & 2 deletions src/event/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const schemaV1 = {
type: "string",
},
data: {
type: ["object", "string"],
type: ["object", "string", "array", "number", "boolean", "null"],
},
data_base64: {
type: "string",
Expand Down Expand Up @@ -89,7 +89,7 @@ export const schemaV03 = {
type: "string",
},
data: {
type: ["object", "string"],
type: ["object", "string", "array", "number", "boolean", "null"],
},
event: {
properties: {
Expand Down
32 changes: 32 additions & 0 deletions test/integration/cloud_event_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,38 @@ describe("A 1.0 CloudEvent", () => {
expect(ce.data).to.deep.equal({ lunch: "tacos" });
});

it("can be constructed with data as an Array", () => {
const ce = new CloudEvent({
...fixture,
data: [{ lunch: "tacos" }, { supper: "sushi" }],
});
expect(ce.data).to.deep.equal([{ lunch: "tacos" }, { supper: "sushi" }]);
});

it("can be constructed with data as a number", () => {
const ce = new CloudEvent({
...fixture,
data: 100,
});
expect(ce.data).to.equal(100);
});

it("can be constructed with null data", () => {
const ce = new CloudEvent({
...fixture,
data: null,
});
expect(ce.data).to.equal(null);
});

it("can be constructed with data as a boolean", () => {
const ce = new CloudEvent({
...fixture,
data: true,
});
expect(ce.data).to.be.true;
});

it("can be constructed with extensions", () => {
const extensions = {
extensionkey: "extension-value",
Expand Down