blob: d058381beca93f873b12c8c9a6e8c4f3f4fd4f0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
openapi: 3.0.0
info:
title: Albatross internal web API
version: 0.1.0
paths:
/login:
post:
summary: User login
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
username:
type: string
example: "john"
password:
type: string
example: "password123"
required:
- username
- password
responses:
'200':
description: Successfully authenticated
content:
application/json:
schema:
type: object
properties:
token:
type: string
example: "xxxxx.xxxxx.xxxxx"
required:
- token
'401':
description: Invalid username or password
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: "Invalid credentials"
required:
- message
/games:
get:
summary: List games
parameters:
- in: query
name: player_id
schema:
type: integer
required: false
- in: header
name: Authorization
schema:
type: string
required: true
responses:
'200':
description: List of games
content:
application/json:
schema:
type: object
properties:
games:
type: array
items:
$ref: '#/components/schemas/Game'
required:
- games
'403':
description: Forbidden
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: "Forbidden operation"
required:
- message
/games/{game_id}:
get:
summary: Get a game
parameters:
- in: path
name: game_id
schema:
type: integer
required: true
- in: header
name: Authorization
schema:
type: string
required: true
responses:
'200':
description: A game
content:
application/json:
schema:
$ref: '#/components/schemas/Game'
'403':
description: Forbidden
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: "Forbidden operation"
required:
- message
components:
schemas:
JwtPayload:
type: object
properties:
user_id:
type: integer
example: 123
username:
type: string
example: "john"
display_name:
type: string
example: "John Doe"
icon_path:
type: string
example: "/images/john.jpg"
is_admin:
type: boolean
example: false
required:
- user_id
- username
- display_name
- is_admin
Game:
type: object
properties:
game_id:
type: integer
example: 1
state:
type: string
example: "closed"
enum:
- closed
- waiting_entries
- waiting_start
- prepare
- starting
- gaming
- finished
display_name:
type: string
example: "Game 1"
duration_seconds:
type: integer
example: 360
started_at:
type: integer
example: 946684800
problem:
$ref: '#/components/schemas/Problem'
required:
- game_id
- state
- display_name
- duration_seconds
Problem:
type: object
properties:
problem_id:
type: integer
example: 1
title:
type: string
example: "Problem 1"
description:
type: string
example: "This is a problem"
required:
- problem_id
- title
- description
GamePlayerMessage:
oneOf:
- $ref: '#/components/schemas/GamePlayerMessageS2C'
- $ref: '#/components/schemas/GamePlayerMessageC2S'
GamePlayerMessageS2C:
oneOf:
- $ref: '#/components/schemas/GamePlayerMessageS2CPrepare'
- $ref: '#/components/schemas/GamePlayerMessageS2CStart'
- $ref: '#/components/schemas/GamePlayerMessageS2CExecResult'
GamePlayerMessageS2CPrepare:
type: object
properties:
type:
type: string
const: "player:s2c:prepare"
data:
$ref: '#/components/schemas/GamePlayerMessageS2CPreparePayload'
required:
- type
- data
GamePlayerMessageS2CPreparePayload:
type: object
properties:
problem:
$ref: '#/components/schemas/Problem'
required:
- problem
GamePlayerMessageS2CStart:
type: object
properties:
type:
type: string
const: "player:s2c:start"
data:
$ref: '#/components/schemas/GamePlayerMessageS2CStartPayload'
required:
- type
- data
GamePlayerMessageS2CStartPayload:
type: object
properties:
start_at:
type: integer
example: 946684800
required:
- start_at
GamePlayerMessageS2CExecResult:
type: object
properties:
type:
type: string
const: "player:s2c:execresult"
data:
$ref: '#/components/schemas/GamePlayerMessageS2CExecResultPayload'
required:
- type
- data
GamePlayerMessageS2CExecResultPayload:
type: object
properties:
status:
type: string
example: "success"
enum:
- success
score:
type: integer
nullable: true
example: 100
required:
- status
- score
GamePlayerMessageC2S:
oneOf:
- $ref: '#/components/schemas/GamePlayerMessageC2SEntry'
- $ref: '#/components/schemas/GamePlayerMessageC2SReady'
- $ref: '#/components/schemas/GamePlayerMessageC2SCode'
GamePlayerMessageC2SEntry:
type: object
properties:
type:
type: string
const: "player:c2s:entry"
required:
- type
GamePlayerMessageC2SReady:
type: object
properties:
type:
type: string
const: "player:c2s:ready"
required:
- type
GamePlayerMessageC2SCode:
type: object
properties:
type:
type: string
const: "player:c2s:code"
data:
$ref: '#/components/schemas/GamePlayerMessageC2SCodePayload'
required:
- type
- data
GamePlayerMessageC2SCodePayload:
type: object
properties:
code:
type: string
example: "print('Hello, world!')"
required:
- code
# GameWatcherMessage:
# oneOf:
# - $ref: '#/components/schemas/GameWatcherMessageS2C'
# - $ref: '#/components/schemas/GameWatcherMessageC2S'
# GameWatcherMessageS2C:
# oneOf:
# GameWatcherMessageC2S:
# oneOf:
|