-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.yaml
965 lines (907 loc) · 33 KB
/
api.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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
openapi: 3.0.3
info:
title: WASAPhoto API Specification
description: |
This OpenAPI document describes the WASAPhoto project REST API.
Keep in touch with your friends by sharing photos of special moments,
thanks to WASAPhoto! Directly from your PC,
you can upload your photos, and they will be visible to everyone
who is following you.
**Project details at [Project.pdf](http://gamificationlab.uniroma1.it/notes/Project.pdf)**
version: "1.0.8"
servers:
- url: http://localhost:8080
description: Localhost development server
tags:
- name: auth
description: Authentication related operations
- name: user
description: User and ban related operations
- name: follow
description: Followings and followers related operations
- name: photo
description: Photo and file upload related operations
- name: likes
description: Likes related operations
- name: comments
description: Comments related operations
paths:
/session:
post:
tags: ["auth"]
summary: Logs in the user
description: |
If the user does not exist, it will be created,
and an identifier is returned.
If the user exists, the user identifier is returned.
Later, the returned user identifier can be used an authentication token
to authenticate subsequent requests.
In case a new user is created, it'll use the given username as
his/her first name, and the surname will be empty.
You can later get the full user information with the appropriate endpoint.
operationId: doLogin
requestBody:
description: User login details
required: true
content:
application/json:
schema: { $ref: "#/components/schemas/LoginRequest" }
responses:
"200":
description: User log-in action successful, user already exists
content:
application/json:
schema: { $ref: "#/components/schemas/LoginResult" }
"201":
description: |
User log-in action successful,
user didn't exist and it has just been created.
content:
application/json:
schema: { $ref: "#/components/schemas/LoginResult" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
security: []
/users/:
description: Users collection
get:
tags: ["user"]
operationId: searchUsers
summary: Search users
description: |
Search users by their username, or partial username.
A text search is performed on usernames.
A user must be logged in. This is required in order to hide
other users who banned the one who is performing the search.
parameters:
- name: username
in: query
description: Username or part of the username to search
required: true
schema: { $ref: "#/components/schemas/Username" }
- name: exactMatch
in: query
description: |
It performs a search using the exact username match,
not just the partial username search.
required: false
schema:
description: Enable the exactMatch option
type: boolean
default: false
- $ref: "#/components/parameters/PageCursor"
responses:
"200": { $ref: "#/components/responses/PaginatedUsersResult" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
/users/{userId}:
description: Actions performed on a single user, identified by the given ID
parameters:
- $ref: "#/components/parameters/UserId"
get:
tags: ["user"]
operationId: getUserProfile
summary: Get user's profile details
description: |
Get user's profile details,
not including the list of his/her photos,
which can be requested using the dedicated endpoint.
Who requests the user info must be authenticated,
in order to detect if it's allowed to see other's information
(e.g. banned or not).
responses:
"200":
description: Get details about this user's profile
content:
application/json:
schema: { $ref: "#/components/schemas/User" }
"404":
description: User with given ID doesn't exist
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
put:
tags: ["user"]
operationId: setMyDetails
summary: Update user details
description: |
Update user details like name, surname, username, etc.
You can only update your own details.
requestBody:
description: Fields to update on the specified user
required: true
content:
application/json:
schema: { $ref: "#/components/schemas/User" }
responses:
"200":
description: User fields have been updated successfully
content:
application/json:
schema: { $ref: "#/components/schemas/User" }
"409":
description: A user with the requested new username already exists
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/users/{userId}/username:
parameters:
- $ref: "#/components/parameters/UserId"
description: |
Special resource which points to
the username field of the currently logged in user.
put:
tags: ["user"]
operationId: setMyUserName
summary: Update username
description: Update user's username. You are not allowed to edit others username.
requestBody:
description: New username to assign to the current user
required: true
content:
text/plain:
schema: { $ref: "#/components/schemas/Username" }
responses:
"200":
description: User username has been updated successfully
content:
application/json:
schema: { $ref: "#/components/schemas/User" }
"409":
description: A user with the requested new username already exists
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/users/{userId}/followers/:
description: Actions on someone's followers
parameters:
- $ref: "#/components/parameters/UserId"
get:
tags: ["follow"]
operationId: listFollowers
summary: List someone's followers
description: |
List, with cursor pagination, all the followers of the specified user.
You must be authenticated in order to be sure that you are allowed
to see information about this user.
parameters:
- $ref: "#/components/parameters/PageCursor"
responses:
"200": { $ref: "#/components/responses/PaginatedUsersResult" }
"404":
description: A user with this ID doesn't exist
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/users/{userId}/followings/:
parameters:
- $ref: "#/components/parameters/UserId"
get:
tags: ["follow"]
operationId: listFollowings
summary: List someone's followings
description: |
List, with cursor pagination, all the followings of the specified user.
You must be authenticated in order to be sure that you are allowed
to see information about this user.
parameters:
- $ref: "#/components/parameters/PageCursor"
responses:
"200": { $ref: "#/components/responses/PaginatedUsersResult" }
"404":
description: A user with this ID doesn't exist
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/users/{userId}/followings/{followedId}:
description: A resource to identify a follower.
parameters:
- $ref: "#/components/parameters/UserId"
- name: followedId
in: path
required: true
description: |
Unique ID of the user to follow.
If A wants to follow B, followedId = B's ID
schema: { $ref: "#/components/schemas/ResourceId" }
delete:
tags: ["follow"]
operationId: unfollowUser
summary: Unfollow a user
description: |
Remove yourself as a follower
of the user identified by the ID in the path.
responses:
"204":
description: |
You are not following this user anymore,
or you wasn't following him/her in the first place (idempotent)
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
put:
tags: ["follow"]
operationId: followUser
summary: Follow a user
description: |
Add the user you want to follow in the followings collection.
You may not have the authorization to follow someone,
for instance if the user you want to follow already banned you.
Also, you cannot add followers to someone else's followings.
responses:
"201":
description: You are now following this user.
content:
application/json:
schema: { $ref: "#/components/schemas/UserFollow" }
"200":
description: You were already following this user (idempotent).
content:
application/json:
schema: { $ref: "#/components/schemas/UserFollow" }
"404":
description: The user specified with "followedId" doesn't exist.
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/users/{userId}/bannedPeople/{blockedId}:
description: Resource to indicate who blocked who.
parameters:
- $ref: "#/components/parameters/UserId"
- name: blockedId
required: true
in: path
description: The unique ID of the user to block
schema: { $ref: "#/components/schemas/ResourceId" }
put:
tags: ["user"]
operationId: banUser
summary: Ban a user
description: Ban another existing user. Banning someone will also make him unfollow you.
responses:
"201":
description: User banned, and it wasn't before
content:
application/json:
schema: { $ref: "#/components/schemas/UserBan" }
"200":
description: User banned, but it already was
content:
application/json:
schema: { $ref: "#/components/schemas/UserBan" }
"404":
description: User to ban not found
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"409":
description: You cannot ban yourself
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
delete:
tags: ["user"]
operationId: unbanUser
summary: Unban a user
description: |
Unban a previously banned user.
You are only allowed to unban users for yourself.
responses:
"204":
description: User unbanned or not banned in the first place.
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
/users/{userId}/photos/:
description: Photos collection of a user
parameters:
- $ref: "#/components/parameters/UserId"
get:
tags: ["photo"]
operationId: listUserPhotos
summary: Get someone's photos
description: List all photos of a user, using a paginated requests.
You must be authenticated in order to be sure that you are allowed
to see information about this user.
parameters:
- $ref: "#/components/parameters/PageCursor"
responses:
"200": { $ref: "#/components/responses/PaginatedPhotosResult" }
"404":
description: A user with this ID cannot be found
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/photos/:
description: Photos collection
post:
tags: ["photo"]
operationId: uploadPhoto
summary: Upload photo
description: |
Upload a new photo to your personal account.
requestBody:
description: The binary image file to upload
content:
image/*:
schema:
description: Photo file to upload, directly as a binary file.
# Schema indicated according to the official docs:
# https://swagger.io/docs/specification/data-models/data-types/#file
type: string
minLength: 1
maxLength: 20971520 # 20MB
format: binary
responses:
"201":
description: |
The post was created.
The image was successfully uploaded and elaborated.
content:
application/json:
schema: { $ref: "#/components/schemas/Photo" }
"415":
description: The file sent cannot be processed as an image.
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"503":
description: A third-party service required to fulfill the request is not available.
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
/photos/{photoId}:
parameters:
- $ref: "#/components/parameters/PhotoId"
delete:
tags: ["photo"]
operationId: deletePhoto
summary: Delete a photo
description: |
Delete an existing published post.
A user can only delete his own photos.
responses:
"204":
description: The post existed and it has just been deleted, or it didn't exist (idempotent).
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/photos/{photoId}/likes/{userId}:
parameters:
- $ref: "#/components/parameters/PhotoId"
- $ref: "#/components/parameters/UserId"
put:
tags: ["likes"]
operationId: likePhoto
summary: Like a photo
description: The specified user will leave a like on a photo
responses:
"201":
description: Your like was added
content:
application/json:
schema: { $ref: "#/components/schemas/PhotoLike" }
"200":
description: Your like was already added
content:
application/json:
schema: { $ref: "#/components/schemas/PhotoLike" }
"404":
description: A post with this ID doesn't exist
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
delete:
tags: ["likes"]
operationId: unlikePhoto
summary: Unlike a photo
description: Remove a like from a photo
responses:
"204":
description: Your like was removed
"404":
description: A post with this ID doesn't exist
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/photos/{photoId}/comments/:
parameters:
- $ref: "#/components/parameters/PhotoId"
get:
tags: ["comments"]
operationId: getPhotoComments
summary: List comments left on a photo
description: |
List all the comments users left on a photo,
in reverse chronological order,
using cursor pagination not to overwhelm the client.
You must be logged in, because the author of the post may have banned you.
In that case, you are not authorized to see.
parameters:
- $ref: "#/components/parameters/PageCursor"
responses:
"200": { $ref: "#/components/responses/PaginatedCommentsResult" }
"404":
description: A post with this ID doesn't exist
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
post:
tags: ["comments"]
operationId: commentPhoto
summary: Comment a photo
description: |
Leave a comment on a photo, if authorized.
For instance, you cannot leave a comment
under a photo of a user who banned you.
requestBody:
required: true
content:
application/json:
schema: { $ref: "#/components/schemas/NewComment" }
responses:
"201":
description: Your comment was added
content:
application/json:
schema: { $ref: "#/components/schemas/Comment" }
"404":
description: A post with this ID doesn't exist
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/photos/{photoId}/comments/{commentId}:
parameters:
- $ref: "#/components/parameters/PhotoId"
- $ref: "#/components/parameters/CommentId"
delete:
tags: ["comments"]
operationId: uncommentPhoto
summary: Delete a comment
description: |
Delete a comment from a photo.
A comment can only be deleted by its author.
responses:
"204":
description: Your comment was deleted.
"404":
description: A post with the given ID doesn't exist.
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
/users/{userId}/stream:
description: Resource of photos stream for a user
parameters:
- $ref: "#/components/parameters/UserId"
get:
tags: ["follow"]
operationId: getMyStream
summary: Get my own stream
description: |
Get my own post stream (you are not allowed to see others' stream),
using cursor pagination.
It will contain posts from the profiles you follow,
in reverse chronological order.
parameters:
- $ref: "#/components/parameters/PageCursor"
responses:
"200": { $ref: "#/components/responses/PaginatedPhotosResult" }
"400": { $ref: "#/components/responses/BadRequest" }
"500": { $ref: "#/components/responses/ServerError" }
"401": { $ref: "#/components/responses/LoginError" }
"403": { $ref: "#/components/responses/AuthorizationError" }
components:
parameters:
UserId:
name: userId
required: true
in: path
description: The unique ID of a user
schema: { $ref: "#/components/schemas/ResourceId" }
PhotoId:
name: photoId
required: true
in: path
description: The unique ID of a post, not the image file directly
schema: { $ref: "#/components/schemas/ResourceId" }
CommentId:
name: commentId
description: The unique ID of a comment
required: true
in: path
schema: { $ref: "#/components/schemas/ResourceId" }
PageCursor:
name: pageCursor
description: |
In cursor pagination, this refers to
the ID of the latest resource received by the client.
required: false
in: query
schema: { $ref: "#/components/schemas/PageCursor" }
responses:
BadRequest:
description: |
The request was not compliant with the documentation
(eg. missing fields, etc).
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
ServerError:
description: |
An unexpected error occurred on the server
while processing this request.
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
LoginError:
description: |
Authentication is required to perform this action,
and no *valid* authentication was included in this request.
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
AuthorizationError:
description: |
A valid authentication is included in this request,
but you are not authorized to perform this action.
For instance, you are trying to modify someone else's data,
or access to information about someone who banned you.
content:
text/plain:
schema: { $ref: "#/components/schemas/Error" }
PaginatedPhotosResult:
description: |
The current page was successfully returned
and it may contain some photos.
content:
application/json:
schema: { $ref: "#/components/schemas/PaginatedPhotos" }
PaginatedUsersResult:
description: |
The current page was successfully returned
and it may contain some users.
content:
application/json:
schema: { $ref: "#/components/schemas/PaginatedUsers" }
PaginatedCommentsResult:
description: |
The current page was successfully returned
and it may contain some users.
content:
application/json:
schema: { $ref: "#/components/schemas/PaginatedComments" }
schemas:
Error:
description: Result representing an error description
type: string
minLength: 0
maxLength: 250
readOnly: true
ResourceId:
description: The unique resource ID as a UUID string
type: string
example: "123e4567-e89b-12d3-a456-426614174000"
minLength: 36
maxLength: 36
readOnly: true
pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
Username:
description: User's personal and unique username
type: string
example: john_doe_42
pattern: "^[a-z_0-9]+$"
minLength: 3
maxLength: 16
LoginRequest:
description: Current user to login
type: object
properties:
username: { $ref: "#/components/schemas/Username" }
LoginResult:
type: object
description: |
Login result with auth details
(the user ID to pass in Authorization as Bearer token).
properties:
userId: { $ref: "#/components/schemas/ResourceId" }
User:
description: |
Representation of a user, with all the details useful in his/her profile.
It won't directly include his/her photos, because they must be
requested separately, using pagination.
type: object
properties:
id: { $ref: "#/components/schemas/ResourceId" }
name:
description: User's name
type: string
example: John
pattern: "^.*$"
minLength: 2
maxLength: 256
surname:
description: User's surname
type: string
minLength: 0
maxLength: 256
example: Doe
pattern: "^.*?$"
default: ""
username:
$ref: "#/components/schemas/Username"
followersCount:
description: Total count of the followers of a user
type: integer
readOnly: true
minimum: 0
example: 500
followingsCount:
description: Total count of the followings of a user
type: integer
readOnly: true
minimum: 0
example: 80
postsCount:
description: Total count of the posts of a user
type: integer
readOnly: true
minimum: 0
example: 12
banned:
description: |
It indicates if the user performing this request
has banned the user represented by this resource.
type: boolean
readOnly: true
example: false
following:
description: |
It indicates whether or not the user performing this request
is currently following the user represented by this resource.
type: boolean
readOnly: true
example: true
DateTime:
description: Standard datetime representation
type: string
format: date-time
example: "2017-07-21T17:32:28Z"
minLength: 20
maxLength: 20
readOnly: true
StaticImageUrl:
description: |
The direct URL to the image file.
It may also be stored on a different server,
which can be dedicated to serve static resources,
or maybe a CDN or may also be simply this server.
The file can be cached and it's guaranteed to never change.
type: string
minLength: 10
maxLength: 256
readOnly: true
example: https://static.example.com/img_1111_d404401c8c6495b206fc35c95e55a6d5.webp
Photo:
description: |
A photo post, with aggregate information about likes and comments.
Detailed comments can be requested separately using an appropriate paginated endpoint.
type: object
properties:
id: { $ref: "#/components/schemas/ResourceId" }
imageUrl: { $ref: "#/components/schemas/StaticImageUrl" }
author: { $ref: "#/components/schemas/User" }
publishDate: { $ref: "#/components/schemas/DateTime" }
likesCount:
description: Total count of the likes this post received
type: integer
minimum: 0
example: 1200
readOnly: true
commentsCount:
description: Total count of the comments this post received
type: integer
minimum: 0
example: 300
readOnly: true
liked:
description: |
The current user liked this photo.
If the request isn't authenticated, this will always be false.
type: boolean
readOnly: true
NewComment:
description: A new comment to publish
type: object
properties:
text:
description: Comment text
type: string
minLength: 1
maxLength: 256
example: Great post! Keep up the good work.
pattern: ".+"
Comment:
description: A comment left on a post
allOf:
- type: object
properties:
id: { $ref: "#/components/schemas/ResourceId" }
publishDate: { $ref: "#/components/schemas/DateTime" }
author: { $ref: "#/components/schemas/User" }
- $ref: "#/components/schemas/NewComment"
PaginationInfo:
type: object
readOnly: true
description: |
Additional data necessary to handle
paginated responses and subsequent requests.
properties:
nextPageCursor: { $ref: "#/components/schemas/PageCursor" }
pageData:
type: array
minItems: 0
maxItems: 20
items:
type: object
description: Data of this page, if any
PageCursor:
type: string
description: String to be sent as pageCursor in the subsequent request
minLength: 1
maxLength: 80
nullable: true
example: "MjFkMTM5ZmUtNWRjNi00OThkLWEyMTAtNmUyNDM1N2MwNmFhOzIwMjItMTEtMjFUMTE6NTM6MDha"
pattern: "^[a-zA-Z0-9_-]+$"
PaginatedComments:
description: Current page of comments
allOf:
- $ref: "#/components/schemas/PaginationInfo"
- description: Current selected page
type: object
readOnly: true
properties:
pageData:
description: Comments of the current page
type: array
minItems: 0
maxItems: 20
items: { $ref: "#/components/schemas/Comment" }
PaginatedPhotos:
description: Current page of photos
allOf:
- $ref: "#/components/schemas/PaginationInfo"
- description: Current selected page
type: object
readOnly: true
properties:
pageData:
description: Photos of the current page
type: array
minItems: 0
maxItems: 20
items: { $ref: "#/components/schemas/Photo" }
PaginatedUsers:
description: Current page of users
allOf:
- $ref: "#/components/schemas/PaginationInfo"
- description: Current selected page
type: object
readOnly: true
properties:
pageData:
description: Users of the current page
type: array
minItems: 0
maxItems: 20
items: { $ref: "#/components/schemas/User" }
UserFollow:
description: Representation of the following of a user
type: object
readOnly: true
properties:
followingId: { $ref: "#/components/schemas/ResourceId" }
followerId: { $ref: "#/components/schemas/ResourceId" }
UserBan:
description: Representation of the ban of a user
type: object
readOnly: true
properties:
bannedId: { $ref: "#/components/schemas/ResourceId" }
bannerId: { $ref: "#/components/schemas/ResourceId" }
PhotoLike:
description: Representation of the like on a photo
type: object
readOnly: true
properties:
photoId: { $ref: "#/components/schemas/ResourceId" }
userId: { $ref: "#/components/schemas/ResourceId" }
securitySchemes:
UserIdAuth:
description: |
User authentication with the user ID passed
as it would be an authentication token.
Of course, that's extremely insecure, but it's done
according to the project specification.
type: http
scheme: bearer
# Apply security scheme globally, disabling it explicitly when unnecessary.
security:
- UserIdAuth: []