-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathswagger.yaml
853 lines (849 loc) · 21.6 KB
/
swagger.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
swagger: '2.0'
info:
description: This is the API documentation for the COP 4331 Marketplace App. Made by Jeovan Teixeira, Ethan Fluhr, and Remi Roper.
version: 1.0.0
title: Marketplace App
contact:
email: [email protected]
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
paths:
/login:
post:
tags:
- Users
summary: Logs in to the marketplace app
operationId: dlLogin
description: Logs in to the marketplace app, returns empty info with an error string saying if it worked or not
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: loginUser
description: Login
schema:
$ref: '#/definitions/Login'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/LoginResponse'
"No Records Found":
description: Login couldn't find the user in the Users table with their login and password
/register:
post:
tags:
- Users
summary: Regisers new users in to the marketplace app
operationId: dlRegister
description: Registers in to the marketplace app, returns new user ID and an error string saying if it worked or not
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: registerUser
description: Register
schema:
$ref: '#/definitions/Register'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/RegisterResponse'
"User Already Exists":
description: Duplicate User has been Found
/emailVerify:
post:
tags:
- Server
summary: Checks if the user can verify their email or not
operationId: dlVerifyEmail
description: Takes in the user's id and verification number. If it matches the verification number in the database and was verified in time then they will be marked as verified. If not return an error.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: verifyEmail
description: Email
schema:
$ref: '#/definitions/EmailVerify'
responses:
"User Id Not Found":
description: The given id was not found in the database
"User is already verified":
description: The user has been verified before
"User didn't verify in time":
description: The user verified their account too late
"Incorrect Verification Number":
description: The given verification number did not match the database
"Undefined Behavior Spotted":
description: A database issue was encountered
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/EmailVerifyResponse'
/editUser:
post:
tags:
- Users
summary: Edits the user's account info with given fields
operationId: dlEditUser
description: Takes in the user's unique identifier and edit's their database document with given input fields. If the input field is empty, the database will not change that field.
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- in: formData
name: id
type: string
- in: formData
name: firstName
type: string
- in: formData
name: lastName
type: string
- in: formData
name: username
type: string
- in: formData
name: password
type: string
- in: formData
name: email
type: string
- in: formData
name: phoneNumber
type: string
- in: formData
name: aboutMe
type: string
- in: formData
name: image
type: file
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/LoginResponse'
"Non-Empty Error String":
description: An error occured with updating the user
/createPost:
post:
tags:
- Posts
summary: Creates a new post to show in the marketplace app
operationId: dlCreatePost
description: Creates a new post and puts it into the database, returns id of post and error string
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- in: formData
name: username
type: string
- in: formData
name: name
type: string
- in: formData
name: genre
type: string
- in: formData
name: price
type: number
- in: formData
name: desc
type: string
- in: formData
name: condition
type: string
- in: formData
name: image
type: file
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/NormalResponse'
"Post already exists":
description: Duplicate post has been found
/editPost:
post:
tags:
- Posts
summary: Edits the user's post with given fields
operationId: dlEditPost
description: Takes in the new post details and edits the post at the given id in the database. If the input field is empty, the database will not change that field.
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- in: formData
name: id
type: string
- in: formData
name: username
type: string
- in: formData
name: name
type: string
- in: formData
name: genre
type: string
- in: formData
name: price
type: number
- in: formData
name: desc
type: string
- in: formData
name: condition
type: string
- in: formData
name: image
type: file
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/NormalResponse'
"Non-Empty Error String":
description: An error occured with updating the post
/searchPost:
post:
tags:
- Posts
summary: Searches the database for posts given certain input
operationId: dlsearchPost
description: Place search terms in their respective fields and get back an array that matches the search terms sent. To limit the amount of search results use minIndex and maxIndex to limit the resulting array. minIndex and maxIndex are not required to make the post request work.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: searchPost
description: search
schema:
$ref: '#/definitions/SearchPost'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/SearchPostResponse'
"Too many used fields":
description: Input format was incorrect. Two fields must be blank.
/noRegexSearchPost:
post:
tags:
- Posts
summary: Searches the database for posts given certain input without the use of regex
operationId: dlsearchPost
description: Place search terms in their respective fields and get back an array that matches the search terms sent. To limit the amount of search results use minIndex and maxIndex to limit the resulting array. minIndex and maxIndex are not required to make the post request work.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: searchPost
description: search
schema:
$ref: '#/definitions/SearchPost'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/SearchPostResponse'
"Too many used fields":
description: Input format was incorrect. Two fields must be blank.
/searchPostPaged:
post:
tags:
- Posts
summary: Searches the database for posts given certain input and given pagination indexes
operationId: dlsearchPost
description: Place search terms in their respective fields and get back an array that matches the search terms sent. To limit the amount of search results use minIndex and maxIndex to limit the resulting array. minIndex and maxIndex are not required to make the post request work.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: searchPost
description: search
schema:
$ref: '#/definitions/SearchPostPaged'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/SearchPostResponse'
"Non-empty error string":
description: There was an error with the database.
/deletePost:
post:
tags:
- Posts
summary: Deletes a certain post
operationId: dldeletePost
description: Takes in the info of a post and deletes it off the database.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: deletePost
description: deleting
schema:
$ref: '#/definitions/DeletePost'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/NormalResponse'
"Post was not found":
description: Database wasn't able to find the post
/interestAddition:
post:
tags:
- Posts
summary: Adds the user to the interests section for the given post
operationId: dlInterest
description: Takes in the post id and user id and adjusts the database to show that the user is interested
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: interest
description: Editing Interest
schema:
$ref: '#/definitions/InterestAddition'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/ErrorOnlyResponse'
"Non-Empty Error String":
description: An error occured with updating the database
/interestDeletion:
post:
tags:
- Posts
summary: Deletes the user to the interests section for the given post
operationId: dlInterestDelete
description: Takes in the post id and user id and adjusts the database to show that the user is uninterested
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: interest
description: Editing Interest
schema:
$ref: '#/definitions/InterestAddition'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/ErrorOnlyResponse'
"Non-Empty Error String":
description: An error occured with updating the database
/getUser:
post:
tags:
- Users
summary: Get user object
operationId: dlGetUser
description: When given an id, return the user object associated with that id. The boolean value in the input field "justUsername" will determine whether you receive just the username or the whole user document.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: GetUser
description: Returns user objects
schema:
$ref: '#/definitions/GetUser'
responses:
"Empty Error String":
description: OK
"User was not found":
description: The given user was not found
/getPost:
post:
tags:
- Posts
summary: Get post object
operationId: dlGetPost
description: When given an id, return the post object associated with that id
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: GetPost
description: Returns user objects
schema:
$ref: '#/definitions/GetPost'
responses:
"Empty Error String":
description: OK
"Post was not found":
description: The given user was not found
/passwordRequest:
post:
tags:
- Server
summary: Aid in password recovery
operationId: dlpasswordRequest
description: Takes in the username of the user and searches the database for them. If they exists then grab their email and send them a verification code to verify it is them. While that happens update the DB to have this verification code.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: Password Request
description: Aid in password recovery
schema:
$ref: '#/definitions/PasswordRequest'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/PasswordRequestResponse'
"User is not in Database":
description: The given user was not found
/passwordChange:
post:
tags:
- Server
summary: Changes the password of a given user
operationId: dlpasswordChange
description: Takes in the username of the user, verification number, and the new password. It checks the DB to see if the verification number is correct. If so change the user's password.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: Password Change
description: Changes the password of a given user
schema:
$ref: '#/definitions/PasswordChange'
responses:
"Empty Error String":
description: OK
schema:
$ref: '#/definitions/LoginResponse'
"User is not in Database":
description: The given user was not found
"Verify Num doesn't match Database":
description: The given verification number was different from the database
/searchUser:
post:
tags:
- Users
summary: Searches for a user
operationId: dlsearhUser
description: Searches a user via their username
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: Password Change
description: Changes the password of a given user
schema:
$ref: '#/definitions/SearchUser'
responses:
"Empty Error String":
description: OK
"Non-Empty Error String":
description: There was an error with the database when searching for the users
parameters:
id:
in: formData
name: id
type: string
username:
in: formData
name: username
type: string
password:
in: formData
name: password
type: string
email:
in: formData
name: email
type: string
phoneNumber:
in: formData
name: phoneNumber
type: string
aboutMe:
in: formData
name: aboutMe
type: string
firstName:
in: formData
name: firstName
type: string
lastName:
in: formData
name: lastName
type: string
name:
in: formData
name: name
type: string
genre:
in: formData
name: genre
type: string
price:
in: formData
name: prices
type: number
desc:
in: formData
name: desc
type: string
condition:
in: formData
name: condition
type: string
image:
in: formData
name: image
type: file
definitions:
NormalResponse:
type: object
properties:
_id:
type: string
example: 12121fafwfaf103012
error:
type: string
example: ""
ErrorOnlyResponse:
type: object
properties:
error:
type: string
example: ""
GetUser:
type: object
required:
- userId
properties:
userId:
type: string
example: 12121fafwfaf103012
justUsername:
type: number
example: 0
GetPost:
type: object
required:
- Post ID
properties:
postId:
type: string
example: 12121fafwfaf103012
Login:
type: object
required:
- Login
- Password
properties:
username:
type: string
example: fred
password:
type: string
example: secret
LoginResponse:
type: object
properties:
id:
type: string
example: 12121fafwfaf103012
firstName:
type: string
example: Fred
lastName:
type: string
example: Doe
username:
type: string
example: Fred1212
email:
type: string
example: [email protected]
phoneNumber:
type: string
example: 1112223333
aboutMe:
type: string
example: About Me
profilePic:
type: object
ttl:
type: number
example: 12121213454
interestedIn:
type: string
example: []
error:
type: string
example: ""
Register:
type: object
required:
- First Name
- Last Name
- Username
- Password
- Email
- Phone Number
properties:
firstname:
type: string
example: Fred
lastname:
type: string
example: Doe
username:
type: string
example: fred111
password:
type: string
example: secret
email:
type: string
example: [email protected]
phoneNumber:
type: string
example: 4079981234
RegisterResponse:
type: object
properties:
_id:
type: string
example: 12121fafwfaf103012
firstName:
type: string
example: Fred
lastName:
type: string
example: Doe
username:
type: string
example: Fred1212
email:
type: string
example: [email protected]
phoneNumber:
type: string
example: 1112223333
aboutMe:
type: string
example: About Me
profilePic:
type: object
ttl:
type: number
example: 12121213454
interestedIn:
type: string
example: []
error:
type: string
example: ""
EmailVerify:
type: object
required:
- id
- Verification Number
properties:
id:
type: string
example: 12121fafwfaf103012
verifyNum:
type: integer
example: 458792
EmailVerifyResponse:
type: object
properties:
id:
type: string
example: 12121fafwfaf103012
ttl:
type: number
example: 12345593473
error:
type: string
example: ''
InterestAddition:
type: object
required:
- User ID
- Post ID
properties:
userId:
type: string
example: 12121fafwfaf103012
postId:
type: string
example: 1313131fwasdwad131
SearchPost:
type: object
required:
- Username
- Name of Post
- Genre
properties:
username:
type: string
example: Fred121
name:
type: string
example: Fred
genre:
type: string
example: Cars
SearchPostPaged:
type: object
required:
- Username
- Name of Post
- Genre
- limit
- skip
properties:
username:
type: string
example: Fred121
name:
type: string
example: Fred
genre:
type: string
example: Cars
limit:
type: number
example: 10
skip:
type: number
example: 1
SearchPostResponse:
type: object
properties:
results:
type: array
items:
type: object
properties:
_id:
type: string
example: 1313131fwasdwad131
username:
type: string
example: Fred121
name:
type: string
example: Fred
genre:
type: string
example: Cars
price:
type: number
example: 22.49
desc:
type: string
example: Description
condition:
type: string
example: Good
error:
type: string
example: ""
DeletePost:
type: object
required:
- Id
properties:
id:
type: string
example: 1313131fwasdwad131
PasswordRequest:
type: object
required:
- username
properties:
username:
type: string
example: Fred121
PasswordRequestResponse:
type: object
properties:
username:
type: string
example: Fred121
email:
type: string
example: [email protected]
verifyNum:
type: number
example: 12345
error:
type: string
example: ''
PasswordChange:
type: object
required:
- username
- verifyNum
- newPassword
properties:
username:
type: string
example: Fred121
verifyNum:
type: number
example: 12345
newPassword:
type: string
example: secret
SearchUser:
type: object
required:
- username
properties:
username:
type: string
example: Fred121
host: cop4331-marketplace-98e1376d9db6.herokuapp.com
basePath: /api
schemes:
- https