-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathswagger_doc.yml
executable file
·678 lines (659 loc) · 19.3 KB
/
swagger_doc.yml
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
openapi: 3.0.0
servers:
- url: /
- url: https://cmput404w19-project.herokuapp.com/
info:
title: Social Distribution Project REST API
description: A Social Distribution Project
version: 0.2.8
tags:
- name: post
description: Blog post operations
- name: comment
description: Post comment operations
- name: friend
description: Friend operations
- name: author
description: Author operations
paths:
/posts:
get:
summary: All posts marked as public on the server
tags:
- post
parameters:
- in: query
name: page
description: page number
schema:
type: integer
- in: query
name: size
description: size limit
schema:
type: integer
responses:
"200":
$ref: "#/components/responses/GetPostsResponse"
/posts/{post_id}:
get:
summary: Get a single post
description: Access to a single post with id = `post_id`
tags:
- post
parameters:
- name: post_id
in: path
description: Post ID
schema:
type: string
required: true
responses:
"200":
$ref: "#/components/responses/GetOnePostResponse"
/posts/{post_id}/comments:
get:
summary: Get comments of a post
tags:
- comment
parameters:
- name: post_id
in: path
description: Post ID
schema:
type: string
required: true
- in: query
name: page
description: page number
schema:
type: integer
- in: query
name: size
description: size limit
schema:
type: integer
responses:
200:
$ref: "#/components/responses/GetCommentsResponse"
post:
summary: Add a comment to a post
tags:
- comment
parameters:
- name: post_id
in: path
description: Post ID
schema:
type: string
required: true
requestBody:
description: Comment properties
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: string
required: true
example: addComment
post:
$ref: "#/components/schemas/Comment"
responses:
"200":
$ref: "#/components/responses/CreateCommentResponse"
"403":
$ref: "#/components/responses/CreateCommentResponse403"
/author/posts:
get:
summary: Posts that are visible to the currently authenticated user
tags:
- post
responses:
"200":
$ref: "#/components/responses/GetPostsResponse"
post:
summary: Create a post to the currently authenticated user
tags:
- post
requestBody:
description: Post properties
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: string
required: true
example: createPost
post:
$ref: "#/components/schemas/Post"
responses:
"200":
$ref: "#/components/responses/CreatePostResponse"
/author/{author_id}/posts:
get:
summary: Get all publicly visible posts to current user
description: (all posts made by `author_id` visible to the currently authenticated user)
tags:
- post
parameters:
- name: author_id
in: path
description: Author ID
required: true
schema:
type: string
responses:
"200":
$ref: "#/components/responses/GetPostsResponse"
/author/{author_id}/friends:
get:
summary: Get friend list of a author
tags:
- friend
parameters:
- name: author_id
in: path
description: Author ID
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: friends
authors:
type: array
items:
type: string
example:
[
"http://host3/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://host2/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
]
post:
summary: Ask a service if anyone in the list is a friend
tags:
- friend
parameters:
- name: author_id
in: path
description: Author ID
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: 'friends'
author:
type: string
example: author_id
authors:
type: array
items:
type: string
example: ['http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013', 'http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891']
responses:
'200':
$ref: '#/components/responses/IfFriendsResponse'
/author/{author1_id}/friends/{author2_id}:
get:
summary: Ask if 2 authors are friends
description: |
STRIP the `http://` and `https://` from the URI in the restful query
If you need a template (optional): `GET http://service/author/<authorid1>/friends/<service2>/author/<authorid2>`
where `authorid1` = `de305d54-75b4-431b-adb2-eb6b9e546013` (actually `author` `http://service/author/de305d54-75b4-431b-adb2-eb6b9e546013` )
where `authorid2` =
`GET http://service/author/de305d54-75b4-431b-adb2-eb6b9e546013/friends/127.0.0.1%3A5454%2Fauthor%2Fae345d54-75b4-431b-adb2-fb6b9e547891`
Please escape / of IDs with %2F e.g. urllib.parse.quote( "http://service/author/whatever" , safe='~()*!.\'')
tags:
- friend
parameters:
- name: author1_id
in: path
description: Author ID
required: true
schema:
type: string
- name: author2_id
in: path
description: Author ID
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: friends
friends:
type: boolean
example: true
authors:
type: array
items:
type: string
example:
[
"http://host3/author/de305d54-75b4-431b-adb2-eb6b9e546013",
"http://host2/author/ae345d54-75b4-431b-adb2-fb6b9e547891",
]
/author/{author_id}:
get:
summary: Get a author's profile
tags:
- author
parameters:
- name: author_id
in: path
description: Author ID
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ExtendAuthorModel'
/friendrequest:
post:
summary: Make a friend request
tags:
- friend
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: 'friendrequest'
author:
type: object
properties:
id:
type: string
example: 'http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013'
host:
type: string
example: 'http://127.0.0.1:5454'
displayName:
type: string
example: 'Greg Johnson'
url:
type: string
example: 'http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013'
friend:
type: object
properties:
id:
type: string
example: 'http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281'
host:
type: string
example: 'http://127.0.0.1:5454'
displayName:
type: string
example: 'Lara Croft'
url:
type: string
example: 'http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e637281'
responses:
'200':
$ref: '#/components/responses/MakeFriendRequestResponse'
components:
responses:
CreatePostResponse:
description: Create post response
content:
application/json:
schema:
type: object
properties:
query:
type: string
success:
type: boolean
message:
type: string
example:
query: createPost
type: true
message: Post created
GetPostsResponse:
description: Get posts response
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: posts
count:
type: integer
description: Number of posts
example: 1023
size:
type: integer
description: Page size
example: 50
next:
type: string
description: Next page url
example: "http://service/author/posts?page=5"
previous:
type: string
description: Previous page url
example: " http://service/author/posts?page=3"
posts:
$ref: "#/components/schemas/ArrayOfPosts"
GetOnePostResponse:
description: Get a single post response
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: "getPost"
post:
$ref: "#/components/schemas/Post"
GetCommentsResponse:
description: Get comments response
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: "comments"
count:
type: integer
description: Number of comments
example: 1023
size:
type: integer
description: Comments size
example: 50
next:
type: string
description: Next page url
example: "http://service/posts/{post_id}/comments?page=5"
previous:
type: string
description: Previous page url
example: "http://service/posts/{post_id}/comments?page=3"
comments:
$ref: "#/components/schemas/ArrayOfComments"
CreateCommentResponse:
description: Create comment response
content:
application/json:
schema:
type: object
properties:
query:
type: string
success:
type: boolean
message:
type: string
example:
query: addComment
type: true
message: Comment added
CreateCommentResponse403:
description: Fail to create comment response
content:
application/json:
schema:
type: object
properties:
query:
type: string
success:
type: boolean
message:
type: string
example:
query: addComment
type: false
message: Comment not allowed
IfFriendsResponse:
description: OK
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: 'friends'
author:
type: string
example: author_id
authors:
type: array
items:
type: string
example: ['http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013', 'http://127.0.0.1:5454/author/ae345d54-75b4-431b-adb2-fb6b9e547891']
MakeFriendRequestResponse:
description: Make friend request response
content:
application/json:
schema:
type: object
properties:
query:
type: string
example: 'friendrequest'
success:
type: boolean
message:
type: string
example: 'Friend request sent'
schemas:
Post:
description: A blog post
required:
- title
- description
- contentType
- content
type: object
properties:
id:
type: string
description: ID of the post
example: "de305d54-75b4-431b-adb2-eb6b9e546013"
title:
type: string
description: Blog post title
example: "A post title about a post about web dev"
source:
type: string
description: Where did you get this post from
example: "http://lastplaceigotthisfrom.com/posts/yyyyy"
origin:
type: string
description: Where is it actually from
example: "http://whereitcamefrom.com/posts/zzzzz"
description:
type: string
description: A brief description of the post
example: "This post discusses stuff -- brief"
contentType:
type: string
description: The content type of the post
enum:
- text/plain
- text/markdown
- image/png;base64
- image/jpeg;base64
- application/base64
example: "text/plain"
content:
type: string
description: Content of the post
example: "stuffs"
author:
$ref: "#/components/schemas/Author"
categories:
type: array
description: A array of post categories
items:
type: string
example: ["web", "tutorial"]
count:
type: integer
description: Total number of comments
example: 1023
size:
type: integer
description: Page size
example: 50
next:
type: string
description: The first page of comments
example: "http://service/posts/{post_id}/comments"
comments:
type: array
description: Comments of the post
items:
$ref: "#/components/schemas/Comment"
published:
type: string
description: ISO 8601 TIMESTAMP
example: "2015-03-09T13:07:04+00:00"
visibility:
type: string
description: Visibility of the post
example: "PUBLIC"
enum:
- PUBLIC
- FOAF
- FRIENDS
- PRIVATE
- SERVERONLY
visibleTo:
type: string
example: ["Jeff Dean"]
description: List of author URIs who to read the private message
unlisted:
type: boolean
description: Unlisted means it is public if you know the post name -- use this for images, it's so images don't show up in timelines
ArrayOfPosts:
description: An array of posts
type: array
items:
$ref: "#/components/schemas/Post"
ExtendAuthorModel:
allOf:
- $ref: "#/components/schemas/Author"
- type: object
properties:
friends:
type: array
items:
$ref: "#/components/schemas/Author"
Author:
description: An author
type: object
properties:
id:
type: string
description: ID of the author
example: "http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013"
email:
type: string
description: Email
example: '[email protected]'
bio:
type: string
description: Author bio
example: 'Hi, I am lara'
host:
type: string
description: Home host of the author
example: "http://127.0.0.1:5454"
firstName:
type: string
description: First name
example: Lara
lastName:
type: string
description: Last name
example: Smith
displayName:
type: string
description: The display name of the author
example: "Greg Johnson"
url:
type: string
description: Url to the author's profile
example: "http://127.0.0.1:5454/author/de305d54-75b4-431b-adb2-eb6b9e546013"
github:
type: string
description: HATEOS url for Github API
example: "http://github.com/gjohnson"
Comment:
description: A comment that is posted under the post
type: object
properties:
id:
type: string
description: Comment ID
example: "de305d54-75b4-431b-adb2-eb6b9e546013"
contentType:
type: string
description: The content type of the comment
enum:
- text/plain
- text/markdown
comment:
type: string
description: The content of the comment
example: "Sick Old English"
published:
type: string
description: ISO 8601 TIMESTAMP
example: "2015-03-09T13:07:04+00:00"
author:
$ref: "#/components/schemas/Author"
ArrayOfComments:
description: An array of comments
type: array
items:
$ref: "#/components/schemas/Comment"