-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi3_0.yaml
697 lines (695 loc) · 20.3 KB
/
openapi3_0.yaml
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
openapi: 3.1.0
info:
title: Backpack API
description: |-
🚧 Work In Progress API specification for [Backpack](https://github.com/Vrixyz/backpack)
contact:
email: [email protected]
license:
name: MIT
url: https://github.com/Vrixyz/backpack/blob/main/LICENCE-MIT.txt
version: 1.0.0
externalDocs:
description: github
url: https://github.com/Vrixyz/backpack
servers:
- url: http://127.0.0.1:8080/api/v1
- url: https://app-c3f0bdf4-ef26-470d-ace6-18b04dd819d6.cleverapps.io/api/v1
tags:
- name: Authentication
description: Everything you can do without being fully authenticated. Mainly to get a Biscuit authentication token.
# - name: user
# description: A user owns items, he can authenticate as admin to create and modify apps and items he manages.
- name: app
description: Operations about apps, authenticated as admin
- name: item
description: Operations about items, authenticated as admin
- name: user as user
description: Operations about users, authenticated as user or admin
- name: item as user
description: Operations about items, authenticated as user or admin
paths:
# Authentication
/authentication/email_password/create:
post:
tags:
- Authentication
summary: Create a new user
description: If no existing users have provided email, the user is created and a password is sent by mail.
operationId: createUserEmail
requestBody:
description: The email of the created user.
content:
application/json:
schema:
type: object
properties:
email:
type: string
examples:
required: true
responses:
"201":
description: Successful creation of the user.
content:
text/plain:
schema:
type: object
properties:
id:
type: integer
description: "The id of the created user."
examples:
- 42
password_plain:
type: string
format: password
description: "Password copypasted from email on creation"
examples:
- "5~#_ER]rz/..."
"500":
description: Internal server error
/authentication/email_password/login:
post:
tags:
- Authentication
summary: Login with an user/email
description:
"Login with an account created via `/create_email_password`.<br />\
The returned authentication token is short lived and will need to be refreshed frequently.<br />\
The returned refresh token is long lived."
operationId: loginUserEmailPassword
requestBody:
description: The email and password of the existing user.
content:
application/json:
schema:
type: object
properties:
email:
type: string
examples:
password_plain:
type: string
format: password
description: "Password copypasted from email on creation"
examples:
- "5~#_ER]rz/..."
as_app_user:
type: integer
description: "id of the app to authenticate on"
examples:
- "42"
required:
- email
- password_plain
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/AuthenticationResponse"
"403":
description: User not existing or wrong credentials.
/authentication/email_password/login/refresh:
post:
tags:
- Authentication
summary: 🚧 refresh a (potentially expired) authentication token
description: Refresh a token by getting a new one. Provide info from a previous call to `/login`.
operationId: loginRefreshUserEmailPassword
requestBody:
description: The email and password of the existing user.
content:
application/json:
schema:
type: object
properties:
refresh_token:
type: string
examples:
- "0d-ace1-14b02dd819"
required:
- refresh_token
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/AuthenticationResponse"
"403":
description: User not existing, wrong credentials or refresh token expired/revoked.
/authentication/health_check:
get:
tags:
- Authentication
summary: Returns 200
description: Useful to verify the server is up.
operationId: healthcheck
responses:
"200":
description: OK
# app
/admin/app:
post:
tags:
- app
summary: Create a new app
description: Create a new app with given name.
operationId: createApp
requestBody:
description: Create an app
content:
application/json:
schema:
type: object
properties:
name:
type: string
required: true
responses:
"201":
description: Successful operation returns the id of created app.
content:
application/json:
schema:
description: the id of the created app.
type: integer
security:
- biscuit_token:
- admin
delete:
tags:
- app
summary: Delete an existing app
description: Delete existing app with provided id.
operationId: deleteApp
requestBody:
description: "Deletes an existing app. It should fail if it owns items.\
Items should be removed or transferred before."
content:
application/json:
schema:
type: object
properties:
id:
description: the id of the app to be deleted
type: integer
required: true
responses:
"200":
description: Successful deletion of app.
"401":
description: Unauthorized. (User is not admin for this app?)
security:
- biscuit_token:
- admin
get:
tags:
- app
summary: Get apps.
description: Get all apps the user is admin of.
operationId: getApp
responses:
"200":
description: Successful operation returns the id of created app.
content:
application/json:
schema:
description: all apps the user is admin of.
type: array
items:
$ref: "#/components/schemas/App"
security:
- biscuit_token:
- admin
# item
/admin/item/app/{appId}:
parameters:
- in: path
name: appId
schema:
type: integer
required: true
post:
tags:
- item
summary: Create a new item
description: Create a new item with given name, with given app as owner.
operationId: createItem
requestBody:
description: Create an item
content:
application/json:
schema:
type: object
properties:
name:
type: string
required: true
responses:
"201":
description: Successful operation returns the id of created item.
content:
application/json:
schema:
description: the id of the created item.
type: integer
security:
- biscuit_token:
- admin
/admin/item:
delete:
tags:
- item
summary: 🚧 Delete an existing item
description: 'Delete existing item with provided id.<br><br>
🚧 hard because we should check if no users have this items.<br>
But It''s a pain to remove with such a constraint,
so we should probably be able to:
<ol>
<li>"quarantine" it.</li>
<li>Then forbid its use/addition.</li>
<li>Then operate a migration (refund, whatever...)</li>
<li>Then remove all its users_items, and lastly remove the item.</li>
</ol>'
operationId: deleteItem
requestBody:
content:
application/json:
schema:
type: object
properties:
id:
description: the id of the item to be deleted
type: integer
required: true
responses:
"200":
description: Successful operation returns nothing.
"401":
description: Unauthorized. (User is not admin of the owner app?)
security:
- biscuit_token:
- admin
# authenticated
/authenticated/user:
delete:
tags:
- user as user
summary: Delete authenticated user, this operation is irreversible.
operationId: delete_user
responses:
"200":
description: Successful operation returns nothing.
"400":
description: An error desription is returned as a string.
content:
application/json:
schema:
type: object
properties:
name:
type: string
examples:
- "Authenticated user owns resources which should be deleted before being able to delete user."
security:
- biscuit_token:
- admin
- user
/authenticated/whoami:
get:
tags:
- user as user
summary: Get authentication info (biscuit info)
operationId: whoami
responses:
"200":
description: Successful operation returns biscuit info.<br/>👻This should be exposed through pubilc key.
content:
application/json:
schema:
$ref: "#/components/schemas/BiscuitInfo"
security:
- biscuit_token:
- admin
- user
/authenticated/user/{userId}:
get:
tags:
- user as user
parameters:
- in: path
name: userId
schema:
type: integer
required: true
summary: Get user info (name)
operationId: get_user
responses:
"200":
description: User info
content:
application/json:
schema:
type: object
properties:
name:
type: string
examples:
- "super name"
security:
- biscuit_token:
- admin
- user
/authenticated/item/{itemId}/user/{userId}/modify:
parameters:
- in: path
name: userId
schema:
type: integer
required: true
- in: path
name: itemId
schema:
type: integer
required: true
post:
tags:
- item as user
summary: modify given item by amount
description: "🚧 Logged as user or admin.<br>
- User fails if its app has no rights to modify (or has not this app in its biscuit)<br>
- User fails if they have no right onto that user_item combination. Could be useful to give/take<br>
- Admin fails if he's not managing this app"
operationId: modifyItem
requestBody:
content:
application/json:
schema:
type: object
properties:
amount:
description: the amount to add (or remove if negative).<br>🚧 Specific rights should be checked for negative/positive values.
type: integer
required: true
responses:
"201":
description: Successful operation returns the new item amount.
content:
application/json:
schema:
type: integer
examples:
- 5
"401":
description: Unauthorized. (User is not admin of the owner app?)
security:
- biscuit_token:
- admin
- user
/authenticated/item/{itemId}/user/{userId}/send_item:
parameters:
- in: path
name: userId
schema:
type: integer
required: true
- in: path
name: itemId
schema:
type: integer
required: true
post:
tags:
- item as user
summary: send amount of item to another user
description: "Logged as user or admin.<br>
- User fails if its app has no rights to modify (or has not this app in its biscuit)<br>
- User fails if amount is negative<br>
- Admin fails if he's not managing this app"
operationId: sendItem
requestBody:
content:
application/json:
schema:
type: object
properties:
amount:
description: the amount to add (or remove if negative).<br>Can only be positive if authenticated as user.
type: integer
user_to_send_to:
description: the user to send to.<br>🚧 Specific rights should be checked for negative/positive values.
type: integer
required: true
responses:
"201":
description: Successful operation returns the new item amount for caller user.
content:
application/json:
schema:
type: integer
examples:
- 5
"401":
description: Unauthorized. (User is not admin of the owner app?)
security:
- biscuit_token:
- admin
- user
/authenticated/item/user/{userId}:
parameters:
- in: path
name: userId
description: userId is in path to allow asking for other users' items.
schema:
type: integer
required: true
get:
tags:
- item as user
summary: Get user's items
description: "Logged as user or admin."
operationId: getUserItems
responses:
"201":
description: Successful operation returns the user items.
content:
application/json:
schema:
description: items details
type: array
items:
$ref: "#/components/schemas/ItemAmount"
"401":
description: Unauthorized.
security:
- biscuit_token:
- admin
- user
/authenticated/item/{itemId}/user/{userId}:
parameters:
- in: path
name: itemId
schema:
type: integer
required: true
- in: path
name: userId
description: userId is in path to allow asking for other users' items.
schema:
type: integer
required: true
get:
tags:
- item as user
summary: Get a specific item amount
description: "Logged as user or admin."
operationId: getUserItem
responses:
"201":
description: amount of the item.
content:
application/json:
schema:
type: integer
"401":
description: Unauthorized.
security:
- biscuit_token:
- admin
- user
/authenticated/item/{itemId}:
parameters:
- in: path
name: itemId
schema:
type: integer
required: true
get:
tags:
- item as user
summary: 👻 Get item details (is it useful?)
description: Get item details, with owner app, useful before having the more complicated route getting all app's items
operationId: getItem
responses:
"200":
description: Successful operation returns the item details.
content:
application/json:
schema:
$ref: "#/components/schemas/ItemDef"
security:
- biscuit_token:
- admin
- user
/authenticated/item/app/{appId}:
parameters:
- in: path
name: appId
schema:
type: integer
required: true
get:
tags:
- app as user
summary: Get app's items.
description: Get all items definitions which can be interacted through a given app.
operationId: getItems
responses:
"200":
description: Successful operation returns the items of the app.
content:
application/json:
schema:
description: items interactable through a given app.
type: array
items:
$ref: "#/components/schemas/ItemDef"
security:
- biscuit_token:
- admin
/authenticated/app/item/{itemId}:
parameters:
- in: path
name: itemId
schema:
type: integer
required: true
get:
tags:
- app as user
summary: Get all apps authorized for this item
operationId: getAppsItem
responses:
"201":
description: Successful operation returns the apps owning this item.
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/App"
security:
- biscuit_token:
- admin
components:
schemas:
AuthenticationResponse:
type: object
properties:
authToken:
type: string
examples:
- En0KEwoEMTIzNBgDIgkKBwgKEgMYgAgSJAgAEiAs2CFWr5WyHHWEiMhTXxVNw4gP7PlADPaGfr_AQk9WohpA6LZTjFfFhcFQrMsp2O7bOI9BOzP-jIE5PGhha62HDfX4t5FLQivX5rUhH5iTv2c-rd0kDSazrww4cD1UCeytDSIiCiCfMgpVPOuqq371l1wHVhCXoIscKW-wrwiKN80vR_Rfzg==
refreshToken:
type: object
properties:
id:
type: string
examples:
- Tv2c-rd0kDSazrww4cD1UCeytDS
expirationDate:
type: string
format: date-time
examples:
- 2030-07-21T17:32:28Z
BiscuitInfo:
type: object
properties:
user_id:
type: integer
examples:
- 1
role:
# TODO: #15 (OpenAPI) fix BiscuitInfo Role: swagger editor wants a "schema:" before this line, but vscode highlighter doesn't like it...
oneOf:
- $ref: RoleAdmin
- $ref: RoleUser
RoleAdmin:
type: string
enum: [Admin]
RoleUser:
type: integer
App:
type: object
properties:
id:
type: integer
format: int64
examples:
- 100000
name:
type: string
examples:
- "Game name"
ItemWithName:
type: object
properties:
id:
type: integer
format: int64
examples:
- 100000
name:
type: string
examples:
- "Item name"
ItemDef:
type: object
properties:
item:
$ref: "#/components/schemas/ItemWithName"
app_id:
type: integer
examples:
- 19
ItemAmount:
type: object
properties:
item:
$ref: "#/components/schemas/ItemWithName"
amount:
type: integer
examples:
- 42
securitySchemes:
github_auth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://github.com/login/oauth/access_token
tokenUrl: todo
scopes:
admin: modify managed apps and items definitions
user: used for modifying user items in low security apps, or authentication forwarded to trusted game server.
biscuit_token:
type: http
scheme: bearer
bearerFormat: Biscuit