-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.yaml
1002 lines (1002 loc) · 30.8 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
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
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
swagger: '2.0'
info:
description: API for Automobile Online Marketplace
version: "v1"
title: AutoMart
contact:
email: [email protected]
license:
name: ISC
host: AutoMart
basePath: /api/v1
tags:
- name: auth
description: Operations about user authentication
- name: user
description: User profile and all users operation
- name: car
description: Operations about adverts
- name: order
description: Operations about orders
- name: flag
description: Operations about ads flags
schemes:
- https
paths:
/auth/signup:
post:
tags:
- auth
summary: Create user
description: Creates a new user account.
produces:
- application/json
parameters:
- name: user
in: body
description: user to sign up
schema:
type: object
required:
- first_name
- last_name
- email
- phone
- password
- passord_confirmation
properties:
first_name:
type: string
last_name:
type: string
email:
type: string
phone:
type: integer
password:
type: string
password_confirmation:
type: string
responses:
201:
description: User created succcessfully
examples:
application/json:
message: User created succcessfully
data:
token: MTU1OTgyMTklsle8juajdud83duae9d9ad9dhdIwMCw
id: 1558861688503
first_name: John
last_name: Doe
email: [email protected]
phone: 08136266387
isAdmin: false
400:
description: Invalid input
/auth/signin:
post:
tags:
- auth
summary: sign in a user
description: Sign in user into the application
consumes:
- application/json
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: user
in: body
description: user to sign in
schema:
type: object
required:
- email
- password
properties:
email:
type: string
password:
type: string
responses:
200:
description: User signed in
examples:
application/json:
message: User successfully signed in
user:
id: 1558861688503
first_name: John
last_name: Doe
email: [email protected]
token: >-
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTI1NTI5MjU3LCJleHAiOjE1MjU2MTU2NTd9.WqI-bayENIvde4UIkUWqVW3ZdMHtyVyY4RwOVx2gP4Y
phone: 08136266387
isAdmin: false
400:
description: Invalid login credentials
/auth/logout:
get:
tags:
- auth
summary: Logs out a user
description: logs a user out of the app
produces:
- application/json
parameters:
- name: Authorization
in: header
description: an authorization header
required: true
type: string
responses:
200:
description: You have been logged out successfully
/user:
patch:
tags:
- user
summary: Update user password
description: User update his/her password
consumes:
- application/json
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: Authorization
in: header
required: true
type: string
- name: userId
in: header
description: the id of the user performing the update
required: true
type: number
responses:
200:
description: User details updated successfully
examples:
application/json:
data:
id: 1558730737306
email: [email protected]
first_name: Chidiebere
last_name: Chukwuma
password: $2b$10$AINdYnWPPF99URkSCD1sQu3AG8oakjeWPJD1ZB9FxLlGTclRnSHY2,
isAdmin: false
phone: 08136266387
status: active
400:
description: Invalid input, fill all required fields
401:
description: Unauthorized, invalid token or session have expired
404:
description: User not found
/users/{userId}:
patch:
tags:
- user
summary: Disable a user
description: Admin disable an active user
consumes:
- application/json
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- in: header
name: Authorization
description: The admin authorization
required: true
type: string
- in: path
name: userId
description: An adverts id
required: true
type: integer
responses:
200:
description: User successfully disabled
examples:
application/json:
data:
id: 1558730737306
email: [email protected]
first_name: Chidiebere
last_name: Chukwuma
password: $2b$10$AINdYnWPPF99URkSCD1sQu3AG8oakjeWPJD1ZB9FxLlGTclRnSHY2,
isAdmin: false
phone: 08136266387
status: disabled
400:
description: Invalid request
401:
description: Unauthorized, invalid token or session have expired
404:
description: User not found/inactive
/users:
get:
tags:
- user
summary: Get all users
description: Retrieve all users of the system
produces:
- application/json
parameters:
- name: Authorization
in: header
description: Token to identify the admin
required: true
type: string
responses:
200:
description: Successfully retrieved all users
examples:
application/json:
data:
- id: 1558861688503
email: [email protected]
first_name: John
last_name: Doe
password: $2b$10$w8IStgH9bZgq2At6Nz4MD.TStPQLWq6SITarxEzb8M0xlsNeHhrWi
isAdmin: false
phone: 08136266387
status: active
- id: 1558862824484
email: [email protected]
first_name: Mark
last_name: Johnson
password: $2b$10$w8IStgH9bZgq2At6Nz4MD.TStPQLWq6SITarxEzb8M0xlsNeHhrWi
isAdmin: true
phone: 08136266387
status: disabled
401:
description: Unauthorized, invalid token or session have expired
/car:
post:
tags:
- car
summary: Creates a new car advert
description: Add car to app
consumes:
- application/x-www-form-urlencoded
- application/json
produces:
- application/json
parameters:
- name: Authorization
in: header
description: an authorization header
required: true
type: string
- name: owner
in: header
description: Owner of the car
required: true
type: integer
- name: model
in: formData
description: Model of the car
required: true
type: string
- name: manufacturer
in: formData
description: The car manufacturer
required: true
type: string
- name: state
in: formData
description: the state of the car [new, used]
required: true
type: string
- name: price
in: formData
description: the price of the car advertised
required: true
type: number
- name: body_type
in: formData
description: the shape of the car [sedan, suv, jeep etc]
required: true
type: string
- name: description
in: formData
description: the description of the car advertised
required: true
type: string
- name: status
in: formData
description: the status of the car advertised[ available, sold]
required: false
type: string
- name: img
in: formData
description: Url to image of the car
type: string
responses:
201:
description: Ad created successfully
examples:
application/json:
data:
id: 1558731607229
owner: 1558730737306
created_on: 5/24/2019, 9:59:37 PM
state: Used
status: available
price: 7000000
manufacturer: Benz
model: 2017 Benz CLS
body_type: Sedan
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358034/benz_vjvfvs.jpg
400:
description: Invalid inputs
examples:
application/json:
message: Fill all required fields
status: 400
401:
description: Unauthorized, invalid token or session have expired
500:
description: There's a problem uploading your image
/car/{id}:
get:
tags:
- car
summary: get ad by id
description: Get a single ad by id
produces:
- application/json
parameters:
- in: path
name: id
description: An adverts id
required: true
type: integer
responses:
200:
description: Successfully got an ad
examples:
application/json:
data:
id: 1558731168820
owner: 1558955989206
created_on: 5/24/2019, 9:59:37 PM
state: New
status: available
price: 1200000
manufacturer: AUDI
model: 2017 Ford Fiesta
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
400:
description: Invalid ad id
404:
description: Ad with given id not found
delete:
tags:
- car
summary: Deletes an ad
description: Deletes an ad by given id
consumes:
- application/json
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: Authorization
in: header
required: true
type: string
- name: id
in: path
description: Ad id used to delete the ad
required: true
type: integer
responses:
200:
description: Ad successfully deleted
401:
description: >-
Unauthorized, invalid token, no token provided or session have
expired
404:
description: Meal does not exists
/car/price/:
get:
tags:
- car
summary: Get cars within a price range
description: Get cars within a price range
produces:
- application/json
parameters:
- name: min
in: path
description: the minimum price
required: true
type: integer
- name: max
in: path
description: the maximum price
required: true
type: integer
responses:
200:
description: Successfully returned ads
examples:
application/json:
data:
- id: 1558731607229
owner: 1558730737306
created_on: 5/24/2019, 9:59:37 PM
state: Used
status: available
price: 7000000
manufacturer: Ford
model: 2017 Ford Fiesta
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358034/benz_vjvfvs.jpg
- id: 1558731168820
owner: 1558955989206
created_on: 5/24/2019, 9:51:34 PM
state: New
status: available
price: 1200000
manufacturer: AUDI
model: SPORT UV
body_type: SUV
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358034/benz_vjvfvs.jpg
/car/manufacturer/{manufacturer}:
get:
tags:
- car
summary: Get cars by manufacturer
description: Get all cars by manufacturer
produces:
- application/json
parameters:
- name: manufacturer
in: path
description: the manufacturer to get ads
required: true
type: string
responses:
200:
description: Successfully retrieved cars by manufacturer
examples:
application/json:
status: success
data:
- id: 1558731607229
owner: 1558730737306
created_on: 5/24/2019, 9:59:37 PM
state: Used
status: available
price: 7000000
manufacturer: AUDI
model: 2017 AUDI YANKS
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
- id: 1558731168820
owner: 1558955989206
created_on: 5/24/2019, 9:51:34 PM
state: New
status: available
price: 1200000
manufacturer: AUDI
model: SPORT UV
body_type: SUV
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
404:
description: There are no ads for the selected manufacturer
/car/bodytype/{body_type}:
get:
tags:
- car
summary: Get cars by body type
description: Get all cars by body type
produces:
- application/json
parameters:
- name: body_type
in: path
description: the body type of cars to select from
required: true
type: string
responses:
200:
description: Successfully retrieved cars by body type
examples:
application/json:
status: success
data:
- id: 1558731607229
owner: 1558730737306
created_on: 5/24/2019, 9:59:37 PM
state: Used
status: available
price: 7000000
manufacturer: Benz
model: 2017 Benz CLS
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
- id: 1558731168820
owner: 1558955989206
created_on: 5/24/2019, 9:51:34 PM
state: New
status: available
price: 1200000
manufacturer: AUDI
model: SPORT UV
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
404:
description: No ads with the selected body type
/car/state/{state}:
get:
tags:
- car
summary: Get cars by their state
description: Get all cars by their state
produces:
- application/json
parameters:
- name: state
in: path
description: Get cars by their state (used, new)
required: true
type: string
responses:
200:
description: Successfully retrieved cars by their state
examples:
application/json:
status: success
data:
- id: 1558731607229
owner: 1558730737306
created_on: 5/24/2019, 9:59:37 PM
state: Used
status: available
price: 7000000
manufacturer: Ford
model: 2017 Ford Fiesta
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
- id: 1558731168820
owner: 1558955989206
created_on: 5/24/2019, 9:51:34 PM
state: Used
status: available
price: 1200000
manufacturer: AUDI
model: SPORT UV
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
404:
description: No ads for the selected state
/car/status/available:
get:
tags:
- car
summary: Get all available cars
description: Get all cars that are available
produces:
- application/json
responses:
200:
description: Successfully returned all cars
examples:
application/json:
status: success
data:
- id: 1558731607229
owner: 1558730737306
created_on: 5/24/2019, 9:59:37 PM
state: Used
status: available
price: 7000000
manufacturer: Benz
model: 2017 Benz CLS
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
- id: 1558731168820
owner: 1558955989206
created_on: 5/24/2019, 9:51:34 PM
state: New
status: available
price: 1200000
manufacturer: AUDI
model: SPORT UV
body_type: Hatchback
description: This is the description of the car
img: https://res.cloudinary.com/chidichuks/image/upload/v1560358106/benz_smpuel.jpg
404:
description: There are no cars available. Check back
/order/:
post:
tags:
- order
summary: Make an order
description: User makes an order
consumes:
- application/x-www-form-urlencoded
- application/json
produces:
- application/json
parameters:
- name: Authorization
in: header
description: an authorization header
required: true
type: string
- name: buyerId
in: header
description: Id of the buyer obtained from the authorization
required: true
type: number
- name: carId
in: formData
description: The id of the ad to be purchased
required: true
type: string
- name: priceOffered
in: formData
description: the amount the buyer is offering for the car
required: true
type: integer
responses:
200:
description: Your order is received
examples:
application/json:
data:
id: 1559313537712
carId: 1558731607229
date: 5/31/2019, 3:38:57 PM
status: pending
price: 7000000
priceOffered: 6500000
sellerId: 1558730737306
buyerId: 1558861688503
deliveredDate: 5/31/2019, 3:38:57 PM,
400:
description: Invalid input for car or amount
examples:
application/json:
message: Car id is required
status: error
401:
description: No token provided or sessions expired
404:
description: Car not available or seller cannot be verified
/orders:
get:
tags:
- order
summary: Get all orders
description: Get all orders made
produces:
- application/json
parameters:
- name: Authorization
in: header
description: an authorization header
required: true
type: string
responses:
200:
description: Orders succesfully retrieved
examples:
application/json:
orders:
- id: 1559313537712
carId: 1558731607229
date: 5/31/2019, 3:38:57 PM
status: completed
price: 7000000
priceOffered: 6500000
sellerId: 1558730737306
buyerId: 1558861688503
deliveredDate: 5/31/2019, 3:38:57 PM
- id: 1559313537714
carId: 1558731168820
date: 5/31/2019, 3:38:57 PM
status: pending
price: 7000000
priceOffered: 6500000
sellerId: 1558730737306
buyerId: 1558862824484
deliveredDate: 5/31/2019, 3:38:57 PM
401:
description: Unauthorized, invalid token or session have expired
404:
description: There are no orders yet
/orders/{orderId}:
patch:
tags:
- order
summary: Update an existing order
description: Buyer can cancel or complete an order, seller can reject or accept
consumes:
- application/json
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: Authorization
in: header
required: true
type: string
- name: orderId
in: path
description: Order id used to identify order to update
required: true
type: number
- name: status
in: formData
description: status to update order to, can be accepted, rejected, completed, cancelled.
required: true
type: string
responses:
200:
description: Order Updated
examples:
application/json:
message: Successfully updated order
orders:
id: 1559313537712
carId: 1558731607229
date: 5/31/2019, 3:38:57 PM
status: completed
price: 7000000
priceOffered: 6500000
sellerId: 1558730737306
buyerId: 1558861688503
deliveredDate: 5/31/2019, 3:38:57 PM
400:
description: Invalid input
401:
description: Unauthorized, invalid token or session have expired
403:
description: You dont have the permission to modify this resource
404:
description: Order details not found
406:
description: seller or buyer inactive
get:
tags:
- order
summary: View a particular order
description: Order can be viewed by admin, buyer or seller
produces:
- application/json
parameters:
- name: Authorization
in: header
description: an authorization header
required: true
type: string
- name: orderId
in: path
description: Id of the order to be viewed
required: true
type: integer
responses:
200:
description: Order retrieved successfully
examples:
application/json:
orders:
id: 1559313537712
carId: 1558731607229
date: 5/31/2019, 3:38:57 PM
status: completed
price: 7000000
priceOffered: 6500000
sellerId: 1558730737306
buyerId: 1558861688503
deliveredDate: 5/31/2019, 3:38:57 PM
400:
description: Invalid input
401:
description: Unauthorized, invalid token or session have expired
403:
description: You dont have the permission to view this resource
404:
description: Order not found
delete:
tags:
- order
summary: Deletes an order
description: Deletes an order
produces:
- application/json
parameters:
- name: Authorization
in: header
required: true
type: string
- name: orderId
in: path
description: Order id of the order to delete
required: true
type: number
responses:
200:
description: Order successfully deleted
400:
description: Invalid request
401:
description: Unauthorized, invalid token or session have expired
404:
description: Order not found or uncompleted
/flag/:
post:
tags:
- flag
summary: Flag an ad
description: User can flag an ad as fradulent, too pricey or suspicious
consumes:
- application/x-www-form-urlencoded
- application/json
produces:
- application/json
parameters:
- name: Authorization
in: header
description: an authorization header
required: true
type: string
- name: carId
in: formData
description: Id of the ad to flag
required: true
type: number
- name: reason
in: formData
description: The reason for flagging an ad
required: true
type: string
responses:
200:
description: Your flag has been recorded
examples:
application/json:
data:
id: 1559313537712
carId: 1558731607229
date: 5/31/2019, 3:38:57 PM
reason: suspicious
description: The car parts are not original
reportedBy: 1558730737306
status: pending
severity: extreme
400:
description: Ensure to indicate ad id
401:
description: No token provided or sessions expired
404:
description: The ad is no longer active
/flags/{flagId}:
patch:
tags:
- flag
summary: Update a flag status
description: admin to update the status of a flag to resolved
consumes:
- application/json
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: Authorization
in: header
required: true
type: string
- name: flagId
in: path
description: Flag to be updated
required: true
type: number
responses:
200:
description: Order Updated
examples:
application/json:
flag:
id: 1559313537712
carId: 1558731607229
date: 5/31/2019, 3:38:57 PM
reason: suspicious
description: The car parts are not original
reportedBy: 1558730737306
status: resolved
severity: extreme
400:
description: Invalid input
401:
description: Unauthorized, invalid token or session have expired
403:
description: You dont have the permission to modify this resource
404:
description: Flag details not found
get:
tags:
- flag
summary: View a flag report
description: admin views a flag
produces:
- application/json
parameters:
- name: Authorization
in: header
description: an authorization header
required: true
type: string
- name: flagId
in: path
description: Id of the flag to be viewed
required: true
type: integer
responses:
200:
description: Order retrieved successfully
examples:
application/json:
flag:
id: 1559313537712
carId: 1558731607229
date: 5/31/2019, 3:38:57 PM
reason: suspicious
description: The car parts are not original
reportedBy: 1558730737306
status: resolved
severity: extreme
400:
description: Invalid input
401:
description: Unauthorized, invalid token or session have expired
403:
description: You dont have the permission to view this resource
404:
description: Order not found
delete:
tags:
- flag
summary: Deletes a resolved flag
description: Admin deletes a resolved flag
produces:
- application/json
parameters:
- name: Authorization
in: header
required: true
type: string
- name: flagId
in: path
description: Id of the flag to delete
required: true
type: number
responses:
200:
description: Flag successfully deleted
400:
description: Invalid request
401:
description: Unauthorized, invalid token or session have expired