Skip to content

Commit 2aeeca6

Browse files
committed
Use some more common types.
1 parent fead88b commit 2aeeca6

File tree

9 files changed

+78
-35
lines changed

9 files changed

+78
-35
lines changed

contest-api/json-schema/award.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
"properties": {
88
"id": { "$ref": "common.json#/identifier" },
99
"citation": { "type": "string" },
10-
"team_ids": {
11-
"type": "array",
12-
"uniqueItems": true,
13-
"items": { "$ref": "common.json#/identifier" }
14-
}
10+
"team_ids": { "$ref": "common.json#/identifiers" }
1511
},
1612
"required": ["id", "citation", "team_ids"],
1713
"$ref": "common.json#/strictproperties"

contest-api/json-schema/commentary.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,8 @@
99
"time": { "$ref": "common.json#/abstime" },
1010
"contest_time": { "$ref": "common.json#/reltime" },
1111
"message": { "type": "string" },
12-
"team_ids": {
13-
"type": "array",
14-
"uniqueItems": true,
15-
"items": { "$ref": "common.json#/identifier" }
16-
},
17-
"problem_ids": {
18-
"type": "array",
19-
"uniqueItems": true,
20-
"items": { "$ref": "common.json#/identifier" }
21-
}
12+
"team_ids": { "$ref": "common.json#/identifiersornull" },
13+
"problem_ids": { "$ref": "common.json#/identifiersornull" }
2214
},
2315
"required": ["id", "time", "contest_time", "message", "team_ids", "problem_ids"],
2416
"$ref": "common.json#/strictproperties"

contest-api/json-schema/common.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@
7373
]
7474
},
7575

76+
"identifiers": {
77+
"type": "array",
78+
"uniqueItems": true,
79+
"items": { "$ref": "#/identifier" }
80+
},
81+
82+
"identifiersornull": {
83+
"oneOf": [
84+
{ "$ref": "#/identifiers" },
85+
{ "type": "null" }
86+
]
87+
},
88+
7689
"judgementtypeid": {
7790
"enum": [
7891
"AC", "RE", "WA", "TLE", "RTE", "CE", "APE", "OLE", "PE", "EO", "IO", "NO",
@@ -114,6 +127,18 @@
114127
"$ref": "#/strictproperties"
115128
},
116129

130+
"imageref": {
131+
"allOf": [
132+
{ "$ref": "#/fileref" },
133+
{
134+
"properties": {
135+
"mime": { "enum": ["image/png", "image/jpeg", "image/svg+xml"] }
136+
},
137+
"required": ["width", "height"]
138+
}
139+
]
140+
},
141+
117142
"filerefs": {
118143
"type": "array",
119144
"uniqueItems": true,
@@ -122,6 +147,32 @@
122147
}
123148
},
124149

150+
"filerefsornull": {
151+
"oneOf": [
152+
{
153+
"type": "array",
154+
"uniqueItems": true,
155+
"items": {
156+
"$ref": "#/fileref"
157+
}
158+
},
159+
{ "type": "null" }
160+
]
161+
},
162+
163+
"imagerefsornull": {
164+
"oneOf": [
165+
{
166+
"type": "array",
167+
"uniqueItems": true,
168+
"items": {
169+
"$ref": "#/imageref"
170+
}
171+
},
172+
{ "type": "null" }
173+
]
174+
},
175+
125176
"command": {
126177
"type": "object",
127178
"properties": {
@@ -134,6 +185,13 @@
134185
"$ref": "#/strictproperties"
135186
},
136187

188+
"commandornull": {
189+
"oneOf": [
190+
{ "$ref": "#/command" },
191+
{ "type": "null" }
192+
]
193+
},
194+
137195
"$comment": "Inside here add '\"minItems\": 1' to require all collection endpoints to contain at least one element.",
138196
"nonemptyarray": {
139197
},

contest-api/json-schema/contest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"type": "integer",
1717
"minimum": 0
1818
},
19-
"banner": { "$ref": "common.json#/filerefs" },
20-
"logo": { "$ref": "common.json#/filerefs" }
19+
"banner": { "$ref": "common.json#/imagerefsornull" },
20+
"logo": { "$ref": "common.json#/imagerefsornull" }
2121
},
2222
"required": ["id", "name", "duration"],
2323
"$ref": "common.json#/strictproperties"

contest-api/json-schema/language.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"uniqueItems": true,
1515
"items": { "type": "string" }
1616
},
17-
"compiler": { "$ref": "common.json#/command" },
18-
"runner": { "$ref": "common.json#/command" }
17+
"compiler": { "$ref": "common.json#/commandornull" },
18+
"runner": { "$ref": "common.json#/commandornull" }
1919
},
2020
"oneOf": [
2121
{

contest-api/json-schema/organization.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
{ "type": "null" }
1919
]
2020
},
21+
"country_flag": { "$ref": "common.json#/imagerefsornull" },
2122
"url": { "type": [ "string", "null" ] },
2223
"twitter_hashtag": { "type": [ "string", "null" ] },
2324
"location": {
@@ -42,7 +43,7 @@
4243
{ "type": "null" }
4344
]
4445
},
45-
"logo": { "$ref": "common.json#/filerefs" }
46+
"logo": { "$ref": "common.json#/imagerefsornull" }
4647
},
4748
"required": ["id", "name"],
4849
"$ref": "common.json#/strictproperties"

contest-api/json-schema/submission.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"contest_time": { "$ref": "common.json#/reltime" },
1414
"entry_point": { "type": [ "string", "null" ] },
1515
"files": { "$ref": "common.json#/filerefs" },
16-
"reaction": { "$ref": "common.json#/filerefs" }
16+
"reaction": { "$ref": "common.json#/filerefsornull" }
1717
},
1818
"required": ["id", "language_id", "problem_id", "team_id", "time", "contest_time", "files"],
1919
"$ref": "common.json#/strictproperties"

contest-api/json-schema/team-member.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
]
1818
},
1919
"role": { "enum": [ "contestant", "coach" ] },
20-
"photo": { "$ref": "common.json#/filerefs" }
20+
"photo": { "$ref": "common.json#/imagerefsornull" }
2121
},
2222
"required": ["id", "team_id", "first_name", "last_name"],
2323
"$ref": "common.json#/strictproperties"

contest-api/json-schema/team.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
"name": { "type": "string" },
1111
"display_name": { "type": [ "string", "null" ] },
1212
"organization_id": { "$ref": "common.json#/identifierornull" },
13-
"group_ids": {
14-
"type": "array",
15-
"uniqueItems": true,
16-
"items": { "$ref": "common.json#/identifierornull" }
17-
},
13+
"group_ids": { "$ref": "common.json#/identifiersornull" },
1814
"hidden": { "type": [ "boolean", "null" ] },
1915
"location": {
2016
"type": "object",
@@ -26,14 +22,14 @@
2622
"required": ["x", "y", "rotation"],
2723
"$ref": "common.json#/strictproperties"
2824
},
29-
"photo": { "$ref": "common.json#/filerefs" },
30-
"video": { "$ref": "common.json#/filerefs" },
31-
"backup": { "$ref": "common.json#/filerefs" },
32-
"key_log": { "$ref": "common.json#/filerefs" },
33-
"tool_data": { "$ref": "common.json#/filerefs" },
34-
"desktop": { "$ref": "common.json#/filerefs" },
35-
"webcam": { "$ref": "common.json#/filerefs" },
36-
"audio": { "$ref": "common.json#/filerefs" }
25+
"photo": { "$ref": "common.json#/imagerefsornull" },
26+
"video": { "$ref": "common.json#/filerefsornull" },
27+
"backup": { "$ref": "common.json#/filerefsornull" },
28+
"key_log": { "$ref": "common.json#/filerefsornull" },
29+
"tool_data": { "$ref": "common.json#/filerefsornull" },
30+
"desktop": { "$ref": "common.json#/filerefsornull" },
31+
"webcam": { "$ref": "common.json#/filerefsornull" },
32+
"audio": { "$ref": "common.json#/filerefsornull" }
3733
},
3834
"required": ["id", "name"],
3935
"$ref": "common.json#/strictproperties"

0 commit comments

Comments
 (0)