-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi.yaml
839 lines (829 loc) · 21 KB
/
openapi.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
openapi: "3.0.0"
info:
version: 1.0.0
title: Cryptour API
license:
name: SWE 2022
servers:
- url: https://backend.cryptour.dullmer.de/
- url: http://localhost:3030
tags:
- name: Tours
description: >-
Tours are the core Dataset of the API. They describe a planned
hiking route and can be created, sold and bought through the planned
crypto implementation
- name: Users
description: >-
A user can be a provider or consumer of a tour.
paths:
/tours:
get:
summary: List all tours
operationId: listTours
tags:
- Tours
parameters:
- name: searchQuery
in: query
description: Search by title of the tour
required: false
schema:
type: string
- name: minDifficulty
in: query
description: Search by minimum tour difficulty
required: false
schema:
type: integer
format: int32
- name: maxDifficulty
in: query
description: Search by maximum tour difficulty
required: false
schema:
type: integer
format: int32
- name: minDistance
in: query
description: Search by minimum tour length
required: false
schema:
type: integer
format: int32
- name: maxDistance
in: query
description: Search by maximum tour length
required: false
schema:
type: integer
format: int32
- name: minDuration
in: query
description: Search by minimum tour time
required: false
schema:
type: integer
format: int32
- name: maxDuration
in: query
description: Search by maximum tour time
required: false
schema:
type: integer
format: int32
- name: location
in: query
description: Search by tour location
required: false
schema:
type: string
responses:
200:
description: An array of tours
content:
application/json:
schema:
$ref: "#/components/schemas/Tours"
headers:
NumberOfResults:
schema:
type: number
description: "How many Tours were found"
400:
description: malformed query input
content:
application/json:
schema:
type: object
properties:
Error:
type: string
example: Expected Number for {Queryparameter}
post:
summary: Create a tour
operationId: createTour
tags:
- Tours
security:
- basicAuth: []
- cookieAuth: []
requestBody:
description: A description of a Tour
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TourCreate"
responses:
200:
description: Tour successfully created
content:
application/json:
schema:
type: object
properties:
tID:
type: number
example: 5
description: resulting tour id
400:
description: tour is not correctly formatted
content:
application/json:
schema:
type: object
properties:
Error:
type: string
example: body is not properly formatted! Please reference the YAML
401:
$ref: "#/components/responses/UnauthorizedError"
/tours/{TID}:
get:
summary: Get a specific tour
operationId: getTour
tags:
- Tours
parameters:
- name: TID
in: path
required: true
description: The ID of the tour to retrieve
schema:
type: integer
format: int64
responses:
200:
description: Tour found
content:
application/json:
schema:
$ref: "#/components/schemas/Tour"
400:
description: no TID Parameter given
content:
application/json:
schema:
type: object
properties:
Error:
type: string
example: Expected Number for TID
404:
description: Tour not found
content:
application/json:
schema:
type: object
properties:
Error:
type: string
example: Could not find tour with id {TID}
delete:
summary: Delete a specific tour
operationId: deleteTour
tags:
- Tours
security:
- basicAuth: []
- cookieAuth: []
parameters:
- name: TID
in: path
required: true
description: The ID of the tour to delete
schema:
type: integer
format: int64
responses:
204:
description: Tour deleted
401:
$ref: "#/components/responses/UnauthorizedError"
403:
description: User does not own tour or tour already bought by someone. Unable to delete.
content:
application/json:
schema:
type: object
properties:
Error:
type: string
example: Tour is already bought and therefore cannot be deleted
404:
description: Tour not found
content:
application/json:
schema:
type: object
properties:
Error:
type: string
example: Could not find Tour
/tours/{TID}/image:
post:
summary: Upload an image file
operationId: uploadImage
tags:
- Tours
security:
- basicAuth: []
- cookieAuth: []
parameters:
- name: TID
in: path
required: true
description: The ID of the tour to delete
schema:
type: integer
format: int64
requestBody:
description: The Image file
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
201:
description: Image successfully uploaded
400:
description: unexpected error when uploading image
401:
$ref: "#/components/responses/UnauthorizedError"
/tours/{TID}/image/{IID}:
get:
summary: Get a tour image
operationId: getTourImage
tags:
- Tours
parameters:
- name: TID
in: path
required: true
description: The ID of the tour
schema:
type: integer
format: int64
- name: IID
in: path
required: true
description: The ID of the image to retrieve
schema:
type: integer
format: int64
responses:
200:
description: Tour Image returned
content:
image/jpeg:
schema:
type: string
format: binary
404:
description: image not found
content:
application/json:
schema:
type: string
example: Could not find image with ID {IID} for tour with ID {TID}
/tours/{TID}/gpx:
get:
summary: Get a tour gpx file
operationId: getTourGPX
tags:
- Tours
security:
- basicAuth: []
- cookieAuth: []
parameters:
- name: TID
in: path
required: true
description: The ID of the tour to retrieve
schema:
type: integer
format: int64
responses:
200:
description: Tour GPX returned
content:
application/octet-stream:
schema:
type: string
format: binary
401:
$ref: "#/components/responses/UnauthorizedError"
403:
description: user has not bought tour
content:
application/json:
schema:
type: string
example: User not allowed to download gpx file
404:
description: GPX not found
content:
application/json:
schema:
type: string
example: Could not find GPX Data for Tour with ID {TID}
post:
summary: Upload a gpx file
operationId: uploadGPX
tags:
- Tours
security:
- basicAuth: []
parameters:
- name: TID
in: path
required: true
description: The ID of the tour to delete
schema:
type: integer
format: int64
requestBody:
description: The GPX file
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
201:
description: GPX successfully uploaded
400:
description: unexpected when uploading gpx file
401:
$ref: "#/components/responses/UnauthorizedError"
/tours/{TID}/rating:
post:
summary: Rate a tour
operationId: rateTour
security:
- basicAuth: []
- cookieAuth: []
parameters:
- name: TID
in: path
required: true
description: The ID of the tour to retrieve
schema:
type: integer
format: int64
requestBody:
description: The rating from 1 to 5
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Rating"
tags:
- Tours
responses:
200:
description: Rating added or updated
401:
$ref: "#/components/responses/UnauthorizedError"
404:
description: Tour not found
content:
application/json:
schema:
type: string
example: wrong tid
406:
description: Rating not between 1 and 5
content:
application/json:
schema:
type: string
example: int value between 1 and 5 allowed
500:
description: unexpected error
get:
summary: Get a tour rating
operationId: getTourRating
tags:
- Tours
parameters:
- name: TID
in: path
required: true
description: The ID of the tour to retrieve
schema:
type: integer
format: int64
responses:
200:
description: Tour Rating returned
content:
application/json:
schema:
$ref: "#/components/schemas/Rating"
headers:
NumberOfResults:
schema:
type: integer
description: Number of submitted ratings
400:
description: unexpected error
content:
application/json:
schema:
type: object
properties:
Error:
type: string
example: no ratings submitted for this tour
404:
description: tour not found
content:
application/json:
schema:
type: string
example: "Error: Could not Find Tour with ID {TID}"
/tours/{TID}/creator:
get:
summary: Get the creator username of this tour
operationId: getCreatorName
tags:
- Tours
responses:
200:
description: Successful request
content:
text/plain:
schema:
type: string
example: user1
404:
description: tour not found
content:
text/plain:
schema:
type: string
example: "Error: Could not Find Tour with ID {TID}"
/user:
get:
summary: Get info about myself
operationId: getUser
tags:
- Users
security:
- basicAuth: []
- cookieAuth: []
responses:
200:
description: Successful request
content:
application/json:
schema:
$ref: "#/components/schemas/User"
400:
description: unexpected error
401:
$ref: "#/components/responses/UnauthorizedError"
post:
summary: Create a new User
operationId: createUser
tags:
- Users
requestBody:
description: The user information
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UserRegister"
responses:
201:
description: User successfully created
content:
application/json:
schema:
$ref: "#/components/schemas/User"
400:
description: user supplied cannot be created
content:
application/json:
schema:
type: string
example: unknown error
patch:
summary: Edit the information of an existing user
operationId: patchUser
tags:
- Users
security:
- basicAuth: []
- cookieAuth: []
requestBody:
description: The user information
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UserRegister"
responses:
201:
description: User successfully created
content:
application/json:
schema:
$ref: "#/components/schemas/User"
400:
description: unexpected error
401:
$ref: "#/components/responses/UnauthorizedError"
500:
description: unexpected error
/user/createdTours:
get:
summary: Get my created tours
operationId: getCreatedTours
tags:
- Users
security:
- basicAuth: []
- cookieAuth: []
responses:
200:
description: Tour found
content:
application/json:
schema:
type: array
items:
type: number
400:
description: unexpected error
401:
$ref: "#/components/responses/UnauthorizedError"
/user/boughtTours:
get:
summary: Get my bought tours
operationId: getBoughtTours
tags:
- Users
security:
- basicAuth: []
- cookieAuth: []
responses:
200:
description: Bought tours
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Tour"
401:
$ref: "#/components/responses/UnauthorizedError"
500:
description: unexpected error
/user/connectWallet:
post:
summary: Create a new User
operationId: connectWallet
tags:
- Users
security:
- basicAuth: []
- cookieAuth: []
requestBody:
description: The user wallet id on the Ethereum chain
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/WalletConnect"
responses:
201:
description: Wallet successfully connected
401:
$ref: "#/components/responses/UnauthorizedError"
400:
description: unexpected error
/user/#:
post:
summary: Log in user and receive session cookie
tags:
- Users
security:
- basicAuth: []
responses:
200:
description: user successfully logged in
401:
$ref: "#/components/responses/UnauthorizedError"
400:
description: unexpected error
/user/logout:
post:
summary: destroy session cookie
tags:
- Users
security:
- cookieAuth: []
responses:
200:
description: sessioncookie successfully destroyed
401:
description: couldn't destroy session cookie
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: sessioncookie couldn't be destroyed!
400:
description: unexpected error
/user/loggedin:
get:
summary: check if the user is logged in
tags:
- Users
security:
- cookieAuth: []
responses:
200:
description: user logged in
401:
description: not logged in
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: not logged in
400:
description: client not logged in
/user/updatePassword:
patch:
summary: update the user password
tags:
- Users
security:
- basicAuth: []
- cookieAuth: []
responses:
201:
description: password successfully updated
401:
description: unexpected error
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: unexpected error
400:
description: unexpected error
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: unexpected error
components:
schemas:
User:
required:
- firstname
- surname
- email
- username
properties:
id:
type: integer
format: int64
firstname:
type: string
surname:
type: string
username:
type: string
email:
type: string
format: email
walletID:
type: string
UserRegister:
required:
- firstname
- surname
- email
- username
- password
properties:
firstname:
type: string
surname:
type: string
username:
type: string
password:
type: string
email:
type: string
format: email
wallet-id:
type: string
Tour:
properties:
title:
type: string
difficulty:
type: integer
format: int32
location:
type: string
distance:
type: number
duration:
type: number
description:
type: string
creatorID:
type: string
tourImages:
type: array
items:
type: object
properties:
tiID:
type: string
TourCreate:
properties:
title:
type: string
difficulty:
type: integer
format: int32
location:
type: string
distance:
type: number
duration:
type: number
description:
type: string
Tours:
type: array
items:
$ref: "#/components/schemas/Tour"
Rating:
required:
- rating
properties:
rating:
type: integer
WalletConnect:
properties:
walletAddress:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
responses:
UnauthorizedError:
description: Authentication information is missing or invalid
content:
application/json:
schema:
type: string
example: Invalid Credentials
securitySchemes:
basicAuth:
type: http
scheme: basic
cookieAuth:
type: apiKey
in: cookie
name: SessionID