Skip to content

Commit

Permalink
Remove the version enums from schemas
Browse files Browse the repository at this point in the history
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 <andrea.frittoli@gmail.com>
  • Loading branch information
afrittoli committed Nov 15, 2022
1 parent 835bd42 commit a156281
Show file tree
Hide file tree
Showing 34 changed files with 41 additions and 158 deletions.
8 changes: 8 additions & 0 deletions primer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions schemas/artifactpackaged.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/artifactpublished.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
5 changes: 1 addition & 4 deletions schemas/branchcreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
5 changes: 1 addition & 4 deletions schemas/branchdeleted.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/buildfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/buildqueued.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/buildstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
5 changes: 1 addition & 4 deletions schemas/changeabandoned.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
5 changes: 1 addition & 4 deletions schemas/changecreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
5 changes: 1 addition & 4 deletions schemas/changemerged.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
5 changes: 1 addition & 4 deletions schemas/changereviewed.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
5 changes: 1 addition & 4 deletions schemas/changeupdated.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/environmentcreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/environmentdeleted.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/environmentmodified.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/pipelinerunfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/pipelinerunqueued.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/pipelinerunstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/repositorycreated.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/repositorydeleted.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/repositorymodified.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/servicedeployed.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/servicepublished.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/serviceremoved.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/servicerolledback.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/serviceupgraded.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/taskrunfinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/taskrunstarted.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/testcasefinished.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions schemas/testcasequeued.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"properties": {
"version": {
"type": "string",
"enum": [
"0.1.0",
"0.1.1"
],
"default": "0.1.1"
"minLength": 1
},
"id": {
"type": "string",
Expand Down
Loading

0 comments on commit a156281

Please sign in to comment.