-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.yaml
More file actions
593 lines (590 loc) · 15 KB
/
openapi.yaml
File metadata and controls
593 lines (590 loc) · 15 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
---
openapi: 3.0.1
info:
contact:
name: manuelarte <https://github.com/manuelarte>
description: GOWasp, a vulnerable application to practice ethical hacking.
title: GOwasp
version: '0.0.4'
paths:
/api/users/signup:
post:
operationId: userSignup
description: Allow user to signup
summary: User Signup endpoint
tags:
- user
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserCredential'
responses:
"200":
description: User successfully signed up.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
"400":
description: Input data is not valid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
"500":
description: Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/users/login:
post:
operationId: userLogin
description: Allow user to login
summary: Login
tags:
- user
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserCredential'
responses:
"200":
description: User successfully log in.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
"400":
description: Username and password combination not valid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/users/logout:
delete:
operationId: userLogout
description: Allow user to logout
summary: Logout
tags:
- user
responses:
"200":
description: User successfully logged out.
/api/users/{userId}:
get:
operationId: getUserByID
description: Get user
summary: get user
tags:
- user
parameters:
- in: path
name: userId
required: true
schema:
type: integer
x-go-type: uint
x-go-name: userID
description: ID of the user to retrieve its data
- in: query
name: fields
required: false
schema:
type: string
format: fields
description: Fields to retrieve
example: "id,username"
responses:
"200":
description: User retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/User'
"404":
description: User not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/posts:
get:
operationId: getPosts
description: Get posts
summary: get posts
tags:
- posts
parameters:
- in: query
name: page
required: false
schema:
type: integer
minimum: 0
default: 0
description: Page to retrieve
- in: query
name: size
required: false
schema:
type: integer
minimum: 1
default: 20
description: Size of the page
- in: query
name: sort
required: false
schema:
type: string
enum:
- "postedAt,asc"
- "postedAt,desc"
- "title,asc"
- "title,desc"
default: "postedAt,asc"
description: Sorting criteria
example: "postedAt,asc"
- in: query
name: q
required: false
schema:
type: string
default: ""
format: rfc8040
example: "title eq 'Cats are evil'"
responses:
"200":
description: Post page retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/PagePosts'
"400":
description: Error retrieving posts page
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/posts/{postId}:
get:
operationId: getPostByID
description: Get the post
summary: get post
tags:
- posts
parameters:
- in: path
name: postId
required: true
schema:
type: integer
x-go-type: uint
x-go-name: postID
description: Numeric ID of the post
responses:
"200":
description: Post retrieved
headers:
X-XSRF-TOKEN:
description: CSRF token
schema:
type: string
example: 123e4567-e89b-12d3-a456-426655440000
content:
application/json:
schema:
$ref: '#/components/schemas/Post'
"400":
description: Error retrieving post
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
"404":
description: Post not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
"500":
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/posts/{postId}/comments:
get:
operationId: getPostComments
description: Get the post comments
summary: get comments page
tags:
- posts
parameters:
- in: path
name: postId
required: true
schema:
type: integer
x-go-type: uint
x-go-name: postID
description: Numeric ID of the post to get its comments
- in: query
name: page
required: false
schema:
type: integer
minimum: 0
default: 0
description: Page to retrieve
- in: query
name: size
required: false
schema:
type: integer
minimum: 1
default: 20
description: Size of the page
responses:
"200":
description: Comments page retrieved
headers:
X-XSRF-TOKEN:
description: CSRF token
schema:
type: string
example: 123e4567-e89b-12d3-a456-426655440000
Set-Cookie:
description: CSRF cookie
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/PagePostComments'
"400":
description: Error retrieving comments page
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
post:
operationId: postPostComment
description: Post a post comment
summary: post comment
tags:
- comments
parameters:
- in: path
name: postId
required: true
schema:
type: integer
x-go-type: uint
x-go-name: postID
description: Numeric ID of the post to get its comments
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PostCommentNew'
responses:
"200":
description: Post comments added
content:
application/json:
schema:
$ref: '#/components/schemas/PostComment'
"400":
description: Error posting new comment
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/api/session:
get:
operationId: getSession
description: Get the user session
summary: get user session
tags:
- user
responses:
"200":
description: User logged in
content:
application/json:
schema:
$ref: '#/components/schemas/UserSession'
"404":
description: User not logged in
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
"500":
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
ErrorResponse:
type: object
required:
- code
- message
- details
properties:
code:
type: integer
description: The resulting http code
message:
type: string
description: Description of the error occurred
details: {}
User:
type: object
required:
- self
properties:
self:
type: string
format: uri
description: Self link of the user
id:
type: integer
description: Id of the user
x-go-type: uint
x-go-name: ID
createdAt:
type: string
format: date-time
description: Creating time of the user
updatedAt:
type: string
format: date-time
description: Updating time of the user
username:
type: string
minLength: 3
maxLength: 20
description: Username of the user
password:
type: string
minLength: 4
maxLength: 20
description: Password of the user
isAdmin:
type: boolean
description: Whether the user is admin or not
UserSession:
type: object
required:
- id
- username
- password
- isAdmin
properties:
id:
type: integer
description: Id of the user
x-go-type: uint
x-go-name: ID
username:
type: string
minLength: 3
maxLength: 20
description: Username of the user
password:
type: string
minLength: 4
maxLength: 20
description: Password of the user
isAdmin:
type: boolean
description: Whether the user is admin or not
UserCredential:
type: object
required:
- username
- password
properties:
username:
type: string
minLength: 3
maxLength: 20
description: Username of the user
password:
type: string
minLength: 4
maxLength: 20
description: Password of the user
isAdmin:
type: boolean
default: false
PageMetadata:
type: object
required:
- page
- size
- totalPages
- totalCount
properties:
page:
type: integer
description: The returned page
size:
type: integer
description: The size of the page
totalPages:
type: integer
description: The total number of pages
totalCount:
type: integer
description: The total number of items
PagePostComments:
type: object
required:
- data
- _metadata
properties:
data:
type: array
items:
$ref: '#/components/schemas/PostComment'
_metadata:
$ref: '#/components/schemas/PageMetadata'
PagePosts:
type: object
required:
- data
- _metadata
properties:
data:
type: array
items:
$ref: '#/components/schemas/Post'
_metadata:
$ref: '#/components/schemas/PageMetadata'
Post:
type: object
required:
- self
- id
- createdAt
- updatedAt
- postedAt
- userId
- title
- content
properties:
self:
type: string
format: uri
description: Self link of the post
id:
type: integer
description: Id of the post
x-go-type: uint
x-go-name: ID
createdAt:
type: string
format: date-time
description: Creating time of the comment
updatedAt:
type: string
format: date-time
description: Updating time of the comment
postedAt:
type: string
format: date-time
description: Posting time of the comment
userId:
type: integer
description: Id of the user
x-go-type: uint
x-go-name: userID
title:
type: string
description: Title of the post
minimum: 3
maximum: 200
content:
type: string
description: The post content
minimum: 3
maximum: 2000
PostCommentExtended:
allOf:
- $ref: "#/components/schemas/PostComment"
- type: object
required:
- username
properties:
username:
type: string
PostComment:
type: object
required:
- id
- createdAt
- updatedAt
- postedAt
- postId
- userId
- comment
properties:
id:
type: integer
description: Id of the comment
x-go-type: uint
x-go-name: ID
createdAt:
type: string
format: date-time
description: Creating time of the comment
updatedAt:
type: string
format: date-time
description: Updating time of the comment
postedAt:
type: string
format: date-time
description: Posting time of the comment
postId:
type: integer
description: Id of the post
x-go-type: uint
x-go-name: postID
userId:
type: integer
description: Id of the user who wrote the comment
x-go-type: uint
x-go-name: userID
comment:
type: string
description: The comment value
PostCommentNew:
type: object
required:
- userId
- comment
- csrf
properties:
userId:
type: integer
description: Id of the user who wrote the comment
x-go-type: uint
x-go-name: userID
comment:
type: string
description: The comment value
csrf:
type: string
description: CSRF token
format: uuid
example: 123e4567-e89b-12d3-a456-426655440000