-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHogWeedGo.openapi.yml
More file actions
627 lines (602 loc) · 18 KB
/
HogWeedGo.openapi.yml
File metadata and controls
627 lines (602 loc) · 18 KB
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
openapi: 3.0.3
info:
title: HogWeedGo service openapi specification
version: 0.0.1
paths:
/healthcheck:
get:
operationId: healthcheck
description: "Endpoint to check whether the HogWeed server is alive."
responses:
'200':
content:
text/plain:
schema:
pattern: '^healthy$'
description: "Server is up and healthy."
tags:
- health
- unauth
/api/me/prove_email:
get:
operationId: proveEmail
description: "Endpoint to generate a unique code for given email. It is required for authentication and stays valid for 10 minutes."
parameters:
- in: query
name: email
schema:
type: string
format: email
required: true
description: "Email the code is requested for."
responses:
'200':
content:
text/plain:
schema:
pattern: '^Code was sent$'
description: "Response of server in production environment."
application/json:
schema:
$ref: '#/components/schemas/Email'
description: "The code was successfully generated and sent. If environment variable MOCK_SMTP_SERVER is set to True response will be sent as JSON. Otherwise it will be sent to specified email."
tags:
- me
- unauth
/api/me/auth:
get:
operationId: auth
description: "Endpoint for creating new user (with given email)."
parameters:
- in: query
name: email
schema:
type: string
format: email
required: true
description: "Email user account is created with."
- in: query
name: code
schema:
type: string
required: true
description: "Special unique registration code (usually received by email from '/api/me/prove_email' endpoint)."
- in: query
name: password
schema:
type: string
required: true
description: "Password of newly created user."
responses:
'200':
content:
application/json:
schema:
pattern: '^Token (?<TOKEN>[a-z0-9]*)$'
description: "New user is successfully created. TOKEN stands for user session auth token. To log in user should add Authentication: Token TOKEN' header to his request."
'401':
content:
text/plain:
schema:
pattern: '^Wrong or expired code!$'
description: "Provided code was wrong or expired (sent more than 10 minutes after being requested)."
'403':
content:
text/plain:
schema:
pattern: '^User already exists!$'
description: "User with provided email already exists."
'400':
content:
text/plain:
schema:
pattern: '^Can not (?:authenticate|log in) user with email: (?<EMAIL>\S*), password: (?<PASSWORD>\S*)!$'
description: "User can not be created for unknown reason. EMAIL and PASSWORD stand for email and password provided in params."
'429':
content:
application/json:
schema:
description: '^Request was throttled\. Expected available in (?<SECONDS>[0-9]*) seconds?\.$'
description: "This endpoint may be called maximum 4 times per minute."
tags:
- me
- unauth
/api/me/log_in:
get:
operationId: logIn
description: "Endpoint for logging existing user in."
parameters:
- in: query
name: email
schema:
type: string
format: email
required: true
description: "Email user account is created with."
- in: query
name: password
schema:
type: string
required: true
description: "Password of newly created user."
responses:
'200':
content:
application/json:
schema:
pattern: '^Token (?<TOKEN>[a-z0-9]*)$'
description: "User is successfully logged in. TOKEN stands for user session auth token. To log in user should add 'Authentication: Token [TOKEN]' header to his request."
'400':
content:
text/plain:
schema:
pattern: '^Can not (?:authenticate|log in) user with email: (?<EMAIL>\S*), password: (?<PASSWORD>\S*)!$'
description: "User can not be logged in. EMAIL and PASSWORD stand for email and password provided in params."
'429':
content:
application/json:
schema:
description: '^Request was throttled\. Expected available in (?<SECONDS>[0-9]*) seconds?\.$'
description: "This endpoint may be called maximum 4 times per minute."
tags:
- me
- unauth
/api/me/profile:
get:
operationId: profile
description: "Endpoint for retrieving information about current user."
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: "Current user profile."
security:
- HogWeedAuth: []
tags:
- me
- auth
/api/me/setup:
post:
operationId: setupMe
description: "Endpoint for altering user information (such as email, password, name or profile picture)."
parameters:
- in: query
name: email
schema:
type: string
format: email
description: "New email for current user."
- in: query
name: code
schema:
type: string
description: "Special unique registration code (usually received by email from '/api/me/prove_email' endpoint). Required for email changing only."
- in: query
name: password
schema:
type: string
description: "New password for current user."
- in: query
name: name
schema:
type: string
description: "New name of current user."
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
photo:
type: string
format: binary
additionalProperties: false
description: "New profile picture of current user."
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Setup'
description: "All requested user properties were successfully changed."
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/Setup'
description: "At least one of the requested properties could not be changed."
'429':
content:
application/json:
schema:
description: '^Request was throttled\. Expected available in (?<SECONDS>[0-9]*) seconds?\.$'
description: "This endpoint may be called maximum 4 times per minute."
security:
- HogWeedAuth: []
tags:
- me
- auth
/api/me/log_out:
delete:
operationId: logOut
description: "Endpoint for logging current user out (finishing his session and deleting token)."
responses:
'200':
content:
text/plain:
schema:
pattern: '^Logged out successfully$'
description: "User was logged out successfully, his token is valid no more."
security:
- HogWeedAuth: []
tags:
- me
- auth
/api/me/leave:
delete:
operationId: leave
description: "Endpoint for deleting current user."
responses:
'200':
content:
text/plain:
schema:
pattern: '^User deleted successfully$'
description: "User was deleted successfully, all his information removed from server."
security:
- HogWeedAuth: []
tags:
- me
- auth
/api/reports:
get:
operationId: listReports
description: "Endpoint for getting all reports ever sent."
parameters:
- in: query
name: filter
schema:
enum:
- RECEIVED
- APPROVED
- INVALID
type: string
description: "Optional filter for requested reports (returns all if not set)."
responses:
'200':
content:
application/json:
schema:
type: object
properties:
count:
type: integer
next:
type: string
format: uri
nullable: true
previous:
type: string
format: uri
nullable: true
results:
type: array
items:
$ref: '#/components/schemas/ReportOut'
additionalProperties: false
required:
- count
- next
- previous
- results
description: "Reports list."
tags:
- api
post:
operationId: createReport
description: "Endpoint for creating a new report."
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/ReportIn'
photos:
type: array
items:
type: string
format: binary
additionalProperties: false
required:
- data
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ReportOut'
description: "New added report."
'400':
content:
application/json:
schema:
type: string
description: "Report can not be created because of data integrity validation failure."
'429':
content:
application/json:
schema:
description: '^Request was throttled\. Expected available in (?<SECONDS>[0-9]*) seconds?\.$'
description: "This endpoint may be called maximum 4 times per minute."
security:
- HogWeedAuth: []
tags:
- auth
/api/users/{id}:
get:
operationId: retrieveUser
description: "Endpoint for retrieving information about particular service user."
parameters:
- in: path
name: id
schema:
type: integer
required: true
description: "A unique integer value identifying this User."
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: "User profile."
tags:
- api
- user
/api/comments:
post:
operationId: createComment
description: "Endpoint for creating a new comment."
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CommentIn'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/CommentOut'
description: "Comment was successfully created."
'400':
content:
application/json:
schema:
type: string
description: "Report can not be created because of data integrity validation failure."
'429':
content:
application/json:
schema:
description: '^Request was throttled\. Expected available in (?<SECONDS>[0-9]*) seconds?\.$'
description: "This endpoint may be called maximum 4 times per minute."
security:
- HogWeedAuth: []
tags:
- comment
- auth
components:
schemas:
Email:
type: object
properties:
subject:
pattern: '^HogWeedGo authentication$'
message:
pattern: '^Your confirmation code is: "(?<TOKEN>[0-9]*)"\nIt will be valid for 10 minutes\.$'
description: "TOKEN stands for a token, unique for given server and email, valid for 10 minutes."
recipients:
type: array
items:
type: string
format: email
minItems: 1
maxItems: 1
description: "Email the code is generated for."
additionalProperties: false
required:
- subject
- message
- recipients
Setup:
type: object
properties:
email:
enum:
- Wrong or expired code!
- Saved!
- User with given email already exists!
- Code required!
type: string
description: "Describes whether user email was altered and if not why."
token:
pattern: '^Email required!$'
description: "Describes that confirmation code was sent without email."
password:
pattern: '^Saved!$'
description: "Describes whether user password was changed."
name:
pattern: '^Saved!$'
description: "Describes whether user name was changed."
photo:
pattern: '^Saved!$'
description: "Describes whether user profile picture was changed."
additionalProperties: false
Location:
type: object
properties:
lng:
type: number
lat:
type: number
additionalProperties: false
required:
- lng
- lat
ReportIn:
type: object
properties:
address:
type: string
nullable: true
description: "Address defined by user. May be just a geo-related recommendation."
maxLength: 128
init_comment:
type: string
description: "User comment about the report."
maxLength: 2048
place:
$ref: '#/components/schemas/Location'
type:
type: string
description: "User guess for report."
maxLength: 64
additionalProperties: false
required:
- init_comment
- place
- type
ReportOut:
type: object
properties:
address:
type: string
nullable: true
description: "Address defined by user. May be just a geo-related recommendation."
maxLength: 128
init_comment:
type: string
description: "User comment about the report."
maxLength: 2048
date:
type: string
format: number
description: "Date specified by user for his observation."
status:
enum:
- RECEIVED
- APPROVED
- INVALID
type: string
description: "Report status."
subs:
type: integer
nullable: true
description: "The sender of the report, subscription."
id:
type: integer
description: "Unique identifier of this report."
type:
type: string
description: "Staff reply for the report."
maxLength: 64
place:
$ref: '#/components/schemas/Location'
photos:
type: array
items:
type: object
properties:
photo:
type: string
format: uri
thumbnail:
type: string
format: uri
additionalProperties: false
required:
- photo
- thumbnail
comments:
type: array
items:
$ref: "#/components/schemas/CommentOut"
additionalProperties: false
required:
- init_comment
- date
- status
- subs
- id
- type
- place
- photos
- comments
User:
type: object
properties:
last_login:
type: string
format: date-time
nullable: true
first_name:
type: string
maxLength: 150
nullable: true
is_staff:
type: boolean
description: "Designates whether the user can log into this admin site."
photo:
type: string
format: uri
nullable: true
thumbnail:
type: string
format: uri
nullable: true
additionalProperties: false
required:
- is_staff
CommentIn:
type: object
properties:
report:
type: integer
description: "Report this comment is attached to."
text:
type: string
description: "A comment, added to a report by another user."
maxLength: 2048
additionalProperties: false
required:
- report
- text
CommentOut:
type: object
properties:
report:
type: integer
description: "Report this comment is attached to."
text:
type: string
description: "A comment, added to a report by another user."
maxLength: 2048
subs:
type: integer
nullable: true
description: "Author of the comment."
additionalProperties: false
required:
- report
- text
securitySchemes:
HogWeedAuth:
type: apiKey
name: Authorization
in: header
description: 'Header value should be: "Token [TOKEN]"'