From a1562811288ea81e852b7a2c345b18b147c9acce Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Tue, 15 Nov 2022 10:42:06 +0000 Subject: [PATCH] Remove the version enums from schemas Including the spec version enums in schemas is problematic, because every time the spec is updated it implies that all the event schemas must be updated as well which in turn requires the event type versions to be updated too, which is confusing since not all events are updated when a new spec version is made. To solve that issue, we remove the enum from the version property, a let it be a non-empty string. The SDKs can use the event type and version to download the schema and validate events. When a new spec release is made, the $id in the schema of all events still have to be updated, but that should not cause the version on the event type to be updated. Fixes #87 Signed-off-by: Andrea Frittoli --- primer.md | 8 ++++++++ schemas/artifactpackaged.json | 6 +----- schemas/artifactpublished.json | 6 +----- schemas/branchcreated.json | 5 +---- schemas/branchdeleted.json | 5 +---- schemas/buildfinished.json | 6 +----- schemas/buildqueued.json | 6 +----- schemas/buildstarted.json | 6 +----- schemas/changeabandoned.json | 5 +---- schemas/changecreated.json | 5 +---- schemas/changemerged.json | 5 +---- schemas/changereviewed.json | 5 +---- schemas/changeupdated.json | 5 +---- schemas/environmentcreated.json | 6 +----- schemas/environmentdeleted.json | 6 +----- schemas/environmentmodified.json | 6 +----- schemas/pipelinerunfinished.json | 6 +----- schemas/pipelinerunqueued.json | 6 +----- schemas/pipelinerunstarted.json | 6 +----- schemas/repositorycreated.json | 6 +----- schemas/repositorydeleted.json | 6 +----- schemas/repositorymodified.json | 6 +----- schemas/servicedeployed.json | 6 +----- schemas/servicepublished.json | 6 +----- schemas/serviceremoved.json | 6 +----- schemas/servicerolledback.json | 6 +----- schemas/serviceupgraded.json | 6 +----- schemas/taskrunfinished.json | 6 +----- schemas/taskrunstarted.json | 6 +----- schemas/testcasefinished.json | 6 +----- schemas/testcasequeued.json | 6 +----- schemas/testcasestarted.json | 6 +----- schemas/testsuitefinished.json | 6 +----- schemas/testsuitestarted.json | 6 +----- 34 files changed, 41 insertions(+), 158 deletions(-) diff --git a/primer.md b/primer.md index 7381983c..84117053 100644 --- a/primer.md +++ b/primer.md @@ -209,6 +209,14 @@ format `vMajor.Minor.Patch`. While a version of the specification is work in progress, its version is tagged with an extra `-draft` at the end, for instance 0.1.0-draft. +The version is in each schema as part of the schema id and it's included in +each event in the "version" field. The version field does not include enum nor +default values in the schema because that would require changing the event +version every time the spec version is changed. Examples: + +- Schema: `"$id": "https://cdevents.dev/0.1.1/schema/artifact-packaged-event",` +- Event: `"version": "0.1.1"` + ### Development of a new version The specification on the main branch is versioned with the number of the next diff --git a/schemas/artifactpackaged.json b/schemas/artifactpackaged.json index 83c37321..da8782b2 100644 --- a/schemas/artifactpackaged.json +++ b/schemas/artifactpackaged.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/artifactpublished.json b/schemas/artifactpublished.json index f604ec67..0521572a 100644 --- a/schemas/artifactpublished.json +++ b/schemas/artifactpublished.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/branchcreated.json b/schemas/branchcreated.json index 6b25fbc1..41135cc0 100644 --- a/schemas/branchcreated.json +++ b/schemas/branchcreated.json @@ -6,10 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/branchdeleted.json b/schemas/branchdeleted.json index 782adf3e..4d964ca5 100644 --- a/schemas/branchdeleted.json +++ b/schemas/branchdeleted.json @@ -6,10 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/buildfinished.json b/schemas/buildfinished.json index ddde855f..e048175a 100644 --- a/schemas/buildfinished.json +++ b/schemas/buildfinished.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/buildqueued.json b/schemas/buildqueued.json index d7aa4c6a..5a1ad112 100644 --- a/schemas/buildqueued.json +++ b/schemas/buildqueued.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/buildstarted.json b/schemas/buildstarted.json index 01a886ff..da7b2603 100644 --- a/schemas/buildstarted.json +++ b/schemas/buildstarted.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/changeabandoned.json b/schemas/changeabandoned.json index b49f7128..e1f7a4a4 100644 --- a/schemas/changeabandoned.json +++ b/schemas/changeabandoned.json @@ -6,10 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/changecreated.json b/schemas/changecreated.json index 21f50f23..6cb651de 100644 --- a/schemas/changecreated.json +++ b/schemas/changecreated.json @@ -6,10 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/changemerged.json b/schemas/changemerged.json index ffdafccb..cc28c74e 100644 --- a/schemas/changemerged.json +++ b/schemas/changemerged.json @@ -6,10 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/changereviewed.json b/schemas/changereviewed.json index f9b23b91..be04a3db 100644 --- a/schemas/changereviewed.json +++ b/schemas/changereviewed.json @@ -6,10 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/changeupdated.json b/schemas/changeupdated.json index 58136d40..8f021e07 100644 --- a/schemas/changeupdated.json +++ b/schemas/changeupdated.json @@ -6,10 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/environmentcreated.json b/schemas/environmentcreated.json index 67346679..b039b180 100644 --- a/schemas/environmentcreated.json +++ b/schemas/environmentcreated.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/environmentdeleted.json b/schemas/environmentdeleted.json index feaea087..77999c9c 100644 --- a/schemas/environmentdeleted.json +++ b/schemas/environmentdeleted.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/environmentmodified.json b/schemas/environmentmodified.json index 6d153d86..d6216b04 100644 --- a/schemas/environmentmodified.json +++ b/schemas/environmentmodified.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/pipelinerunfinished.json b/schemas/pipelinerunfinished.json index ded91677..38ab5d0a 100644 --- a/schemas/pipelinerunfinished.json +++ b/schemas/pipelinerunfinished.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/pipelinerunqueued.json b/schemas/pipelinerunqueued.json index 19f9f8ba..1225e863 100644 --- a/schemas/pipelinerunqueued.json +++ b/schemas/pipelinerunqueued.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/pipelinerunstarted.json b/schemas/pipelinerunstarted.json index f6cb8bc7..a79f6dec 100644 --- a/schemas/pipelinerunstarted.json +++ b/schemas/pipelinerunstarted.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/repositorycreated.json b/schemas/repositorycreated.json index 6a1d5482..e83c9d6a 100644 --- a/schemas/repositorycreated.json +++ b/schemas/repositorycreated.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/repositorydeleted.json b/schemas/repositorydeleted.json index c1e25435..bae78b15 100644 --- a/schemas/repositorydeleted.json +++ b/schemas/repositorydeleted.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/repositorymodified.json b/schemas/repositorymodified.json index 55919871..283fc846 100644 --- a/schemas/repositorymodified.json +++ b/schemas/repositorymodified.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/servicedeployed.json b/schemas/servicedeployed.json index c474f919..1a120051 100644 --- a/schemas/servicedeployed.json +++ b/schemas/servicedeployed.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/servicepublished.json b/schemas/servicepublished.json index 1631ace1..3a9e6fb4 100644 --- a/schemas/servicepublished.json +++ b/schemas/servicepublished.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/serviceremoved.json b/schemas/serviceremoved.json index 35fd2dd1..d19e20fe 100644 --- a/schemas/serviceremoved.json +++ b/schemas/serviceremoved.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/servicerolledback.json b/schemas/servicerolledback.json index 326d70cd..d2502aff 100644 --- a/schemas/servicerolledback.json +++ b/schemas/servicerolledback.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/serviceupgraded.json b/schemas/serviceupgraded.json index 199182c1..d0e1b98c 100644 --- a/schemas/serviceupgraded.json +++ b/schemas/serviceupgraded.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/taskrunfinished.json b/schemas/taskrunfinished.json index a0cb969f..e5066721 100644 --- a/schemas/taskrunfinished.json +++ b/schemas/taskrunfinished.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/taskrunstarted.json b/schemas/taskrunstarted.json index 19bde39e..d4f0f86d 100644 --- a/schemas/taskrunstarted.json +++ b/schemas/taskrunstarted.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/testcasefinished.json b/schemas/testcasefinished.json index ad5b4800..4bf21e86 100644 --- a/schemas/testcasefinished.json +++ b/schemas/testcasefinished.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/testcasequeued.json b/schemas/testcasequeued.json index caf06070..62a6df8f 100644 --- a/schemas/testcasequeued.json +++ b/schemas/testcasequeued.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/testcasestarted.json b/schemas/testcasestarted.json index 7741d5fb..75d0cf05 100644 --- a/schemas/testcasestarted.json +++ b/schemas/testcasestarted.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/testsuitefinished.json b/schemas/testsuitefinished.json index b5be4c8b..27b8fe06 100644 --- a/schemas/testsuitefinished.json +++ b/schemas/testsuitefinished.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string", diff --git a/schemas/testsuitestarted.json b/schemas/testsuitestarted.json index 8738230b..2333142c 100644 --- a/schemas/testsuitestarted.json +++ b/schemas/testsuitestarted.json @@ -6,11 +6,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "0.1.0", - "0.1.1" - ], - "default": "0.1.1" + "minLength": 1 }, "id": { "type": "string",