Skip to content

Commit acedf39

Browse files
committed
Add jsonschema struct tags
The omitempty struct tag is interpreted by the schema generation library like a non-required field, so we cannot set "omitempty" on required fields, else the schema will be invalid. To solve the issue, use instead minLenght tags for all string required fields, to indicate that a non-empty value must be provided for validation to pass. Signed-off-by: Andrea Frittoli <[email protected]>
1 parent e0dfa9e commit acedf39

14 files changed

+162
-109
lines changed

jsonschema/changeabandoned.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {},

jsonschema/changecreated.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {},

jsonschema/changemerged.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {},

jsonschema/changereviewed.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {},

jsonschema/changeupdated.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {},

jsonschema/pipelinerunfinished.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {

jsonschema/pipelinerunqueued.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {

jsonschema/pipelinerunstarted.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {

jsonschema/taskrunfinished.json

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
"context": {
66
"properties": {
77
"version": {
8-
"type": "string"
8+
"type": "string",
9+
"minLength": 1
910
},
1011
"id": {
11-
"type": "string"
12+
"type": "string",
13+
"minLength": 1
1214
},
1315
"source": {
14-
"type": "string"
16+
"type": "string",
17+
"minLength": 1
1518
},
1619
"type": {
17-
"type": "string"
20+
"type": "string",
21+
"minLength": 1
1822
},
1923
"timestamp": {
2024
"type": "string",
@@ -34,13 +38,15 @@
3438
"subject": {
3539
"properties": {
3640
"id": {
37-
"type": "string"
41+
"type": "string",
42+
"minLength": 1
3843
},
3944
"source": {
4045
"type": "string"
4146
},
4247
"type": {
43-
"type": "string"
48+
"type": "string",
49+
"minLength": 1
4450
},
4551
"content": {
4652
"properties": {
@@ -53,7 +59,8 @@
5359
"pipelineRun": {
5460
"properties": {
5561
"id": {
56-
"type": "string"
62+
"type": "string",
63+
"minLength": 1
5764
},
5865
"source": {
5966
"type": "string"

0 commit comments

Comments
 (0)