-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenApi.yaml
More file actions
469 lines (469 loc) · 15.4 KB
/
OpenApi.yaml
File metadata and controls
469 lines (469 loc) · 15.4 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
openapi: 3.0.0
servers:
- description: Heroku deploy
url: https://efghnetwork.herokuapp.com/simplesocialnetwork/v1.0
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/e311/SimpleSocialNetWork/1.0.0
- description: Localhost deploy
url: http://localhost:8080/simplesocialnetwork/v1.0
info:
description: Simple application to be developed as a recruitment test.
version: "1.0.0"
title: Simple Social Network API
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/user:
post:
tags:
- user
summary: Creates a new User in the system.
operationId: addUser
description: Creates a new User in the system, please note that at this point the complex objects update is not supported (i.e. followers, followed, posts).
requestBody:
description: user to be created
content:
application/json:
schema:
$ref: '#/components/schemas/user'
responses:
'200':
description: Created user
content:
application/json:
schema:
$ref: '#/components/schemas/user'
'400':
description: if there is any inconsistency with the user object definition
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
get:
tags:
- user
summary: Returns users in the system
operationId: getUsers
description: Returns the full list of users in the system
responses:
'200':
description: List containing the users in the system
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/user'
/user/{userHandle}:
parameters:
- name: userHandle
in: path
description: user whose information you will be retrieving/modifying
required: true
schema:
type: string
put:
tags:
- user
summary: Modifies a specified user.
operationId: updateUser
description: Modifies a specified user with the values provided in an object, please note that at this point the complex objects update is not supported (i.e. followers, followed, posts)
requestBody:
description: user object containing the values to be updated
content:
application/json:
schema:
$ref: '#/components/schemas/user'
responses:
'200':
description: Modified user object
content:
application/json:
schema:
$ref: '#/components/schemas/user'
'400':
description: if there is any inconsistency with the user object definition or if the handle is empty or null
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
get:
tags:
- user
summary: Retrieves a user details.
operationId: getUserById
description: Retrieves a user details given its handle.
responses:
'200':
description: User object containing the requested user.
content:
application/json:
schema:
$ref: '#/components/schemas/user'
'400':
description: if the handle is empty or null
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
/user/{userHandle}/timeline:
parameters:
- name: userHandle
in: path
description: user whose information you will be retrieving
required: true
schema:
type: string
get:
tags:
- posts
parameters:
- name: reverseOrder
in: query
description: false to retrieve the posts in chronological order, true to retrieve them in inverse chronological order, defaults to true
required: false
schema:
type: boolean
default: true
summary: Get posts made by the followed users.
operationId: getUserTimeline
description: Get the compilation of all the posts made by the users being followed by the user shoe handle is specified in the url.
responses:
'200':
description: List of posts sorted according to what was specified.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/post'
'400':
description: if the handle is empty or null
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
/user/{userHandle}/followed:
parameters:
- name: userHandle
in: path
description: user whose information you will be retrieving/modifying
required: true
schema:
type: string
get:
tags:
- followers
summary: Retrieves the list of users being followed.
operationId: getFollowedUsers
description: Retrieves the list of users being followed by the user whose handle is specified in the url.
responses:
'200':
description: List of users being followed by the user
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/user'
'400':
description: if the handle is empty or null
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
post:
tags:
- followers
summary: Adds a user to the followed list.
operationId: addFollowedUser
description: Adds the received user to the followed list of the user specified in the url.
requestBody:
description: user to be followed, please note that the only attribute to be taking into account in the request is the user handle.
content:
application/json:
schema:
$ref: '#/components/schemas/user'
responses:
'200':
description: User object whose followed list was being modified
content:
application/json:
schema:
$ref: '#/components/schemas/user'
'400':
description: if the handle is empty or null
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: if the provided handle does not correspond to any user on the system or if the sent user to be followed does not match any user in the system
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
/user/{userHandle}/followed/{followedUserHandle}:
parameters:
- name: userHandle
in: path
description: user whose information you will be retrieving/modifying
required: true
schema:
type: string
- name: followedUserHandle
in: path
description: user that will be removed from the followed list
required: true
schema:
type: string
delete:
tags:
- followers
summary: Unfollows a user.
operationId: removeFollowedUser
description: Remove a specified user from the followed list of another specified user.
responses:
'204':
description: User removed from the followed list
'400':
description: if the handle is empty or null
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: if the provided handle does not correspond to any user on the system
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
/user/{userHandle}/followers:
parameters:
- name: userHandle
in: path
description: user whose information you will be retrieving
required: true
schema:
type: string
get:
tags:
- followers
summary: Retrieve the list of followers.
operationId: getFollowers
description: Retrieve the list of followers for the specified user.
responses:
'200':
description: List of users that are following the specified user
content:
application/json:
schema:
$ref: '#/components/schemas/user'
'400':
description: if the handle is empty or null
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: if the provided handle does not correspond to any user on the system
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
/user/{userHandle}/post/:
parameters:
- name: userHandle
in: path
description: user whose posts you are going to handle
required: true
schema:
type: string
post:
tags:
- posts
summary: Creates a post for a user.
operationId: addPost
description: Add a post on behalf of the specified user with the given text.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/post'
responses:
'200':
description: Added post object
content:
application/json:
schema:
$ref: '#/components/schemas/post'
'400':
description: Invalid user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
get:
tags:
- posts
parameters:
- name: reverseOrder
in: query
description: false to retrieve the posts in chronological order, true to retrieve them in inverse chronological order, defaults to true
required: false
schema:
type: boolean
default: true
summary: Get posts made by a user.
operationId: getPostsForUser
description: Get the compilation of all the posts made by the specified user.
responses:
'200':
description: List containing the posts, sorted according what is specified
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/post'
'400':
description: Invalid user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
/user/{userHandle}/post/{uniqueId}:
parameters:
- name: userHandle
in: path
description: user whose posts you are going to handle
required: true
schema:
type: string
- name: uniqueId
in: path
description: id of the post to be modified
required: true
schema:
type: string
delete:
tags:
- posts
summary: Delete a post.
operationId: deletePost
description: Delete a specified post given its unique Id.
responses:
'204':
description: Process ended without errors
'400':
description: Invalid user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle or post id sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
get:
tags:
- posts
summary: Retrieves a post.
operationId: getPost
description: Retrieves a post given a specified ID.
responses:
'200':
description: Process ended without errors
content:
application/json:
schema:
$ref: '#/components/schemas/post'
'400':
description: Invalid user handle sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
'404':
description: Unexistant user handle or post id sent
content:
application/json:
schema:
$ref: '#/components/schemas/apierror'
components:
schemas:
user:
type: object
required:
- handle
properties:
handle:
type: string
example: MyUser
displayName:
type: string
example: My User
post:
required:
- content
properties:
content:
type: string
example: My new post
creationDate:
type: string
format: date
uniqueID:
type: string
format: uuid
example: 408-867-5309
apierror:
properties:
errorMessage:
type: string
example: "NoSuchElementException: User not found for the given handle"
errorCause:
type: string
example: "NoSuchElementException: User not found for the given handle"
errorStack:
type: string
example: "java.util.NoSuchElementException: User not found for the given handle\r\n\tat Network.getUser(Network.java:57)\r\n\tat PostService.getPostsByUserHandle(PostService.java:29)\r\n\tat PostController.getPostsForUser(PostController.java:36)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)"