-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_spec.yaml
1035 lines (1035 loc) · 36 KB
/
api_spec.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
openapi: 3.0.0
info:
title: "SENG365 2024: Petitions API"
version: 1.0.2
description: "This specification documents the petitions API to be implemented for Assignment 1. This API provides all of the server-side functionality necessary in order to implement all the user stories for Assignment 2"
servers:
- url: https://seng365.csse.canterbury.ac.nz/api/v1
description: "Reference server"
- url: http://localhost:4941/api/v1
description: "Your development server"
tags:
- name: backdoor
description: "Development-only endpoints for resetting the database or querying it directly.<br>**These endpoints have been implemented for you, any changes to their functionality may cause tests to break**."
- name: users
description: "Endpoints for registering, logging in, modifying, and retrieving user information"
- name: users.images
description: "Endpoints for retrieving, uploading and deleting user profile images"
- name: petitions
description: "Endpoints for retrieving, creating, modifying, and deleting petitions"
- name: petitions.supportTiers
description: "Endpoints for modifying existing petition's support tiers"
- name: petitions.supporters
description: "Endpoints for viewing and updating supporters of petitions"
- name: petitions.images
description: "Endpoints for retrieving and uploading petition images"
paths:
/reset:
post:
tags:
- backdoor
summary: "Force reset of database to original structure."
responses:
'200':
description: "OK"
'500':
description: "Internal Server Error"
/resample:
post:
tags:
- backdoor
summary: "Reload sample of data into database."
responses:
'201':
description: "Created"
'500':
description: "Internal Server Error"
/reload:
post:
tags:
- backdoor
summary: "Force reset of database to original structure and reload all sample data"
responses:
201:
description: "Created"
500:
description: "Internal Server Error"
/executesql:
post:
tags:
- backdoor
summary: "Execute any arbitrary SQL statement provided, and return the output from the database."
description: "This is an enormous security hole, and <b>wouldn't</b> be present in any real-world application. However, we're using it for testing purposes in this assignment"
requestBody:
content:
text/plain:
schema:
title: SqlCommand
type: string
example: "SELECT * from users;"
responses:
200:
description: "OK"
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/SqlResult"
- $ref: "#/components/schemas/SqlResultSet"
500:
description: "Internal Server Error"
/users/register:
post:
tags:
- users
summary: "Register as a new user"
description: "Create a new user with the specified information.<ul><li>The email **must be syntactically valid** (e.g. it has to include an `@` and a top level domain for example `[email protected]`). Whether it is actually a registered email address will not be checked.</li><li>The email address <b>must not already be in use</b> (if it is in use the server should return a 403).</li><li>The password **must be at least 6 characters**</li></ul>"
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/RegisterUser"
responses:
201:
description: "Created"
content:
application/json:
schema:
$ref: "#/components/schemas/RegisterResponse"
400:
description: "Bad Request. Invalid information"
403:
description: "Forbidden.<ul><li>Email already in use</li></ul>"
500:
description: "Internal Sever Error"
/users/login:
post:
tags:
- users
summary: "Log in as an existing user."
description: "The response will contain a (unique) randomly-generated token that that client-side should store.<br>Whenever the client makes a request that requires authentication it should provide that same token as the value of the `X-Authorization` header in the request. The server will compare this to the value it has stored in the database to authenticate that request."
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/LoginUser"
responses:
200:
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/LoginResponse"
400:
description: "Bad Request. Invalid information"
401:
description: "UnAuthorized. Incorrect email/password"
500:
description: "Internal Server Error"
/users/logout:
post:
tags:
- users
summary: "Log out the currently authorised user."
description: "User will be logged out and their token will no longer be acceptable for authenticated requests"
security:
- UserToken: []
responses:
200:
description: "OK"
401:
description: "Unauthorized. Cannot log out if you are not authenticated"
500:
description: "Internal Server Error"
/users/{id}:
parameters:
- name: "id"
description: "ID of the user"
in: path
required: true
schema:
$ref: "#/components/schemas/LoginResponse/properties/userId"
get:
tags:
- users
summary: "Retrieve information about a user"
description: "The email field is only returned when the currently authenticated user is viewing their **own** details. Otherwise only the first and last names should be returned (this includes unauthenticated requests)."
security:
- {}
- UserToken: []
responses:
200:
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/User"
required:
- firstName
- lastName
404:
description: "Not Found. No user with specified ID"
500:
description: "Internal Server Error"
patch:
tags:
- users
summary: "Change a user's details"
description: "Update a user's information with that specified. Only accessible by the user themselves.<ul><li>The email must be syntactically valid and not in use as described in `/users/register`.</li><li>The `password` and `currentPassword` fields **can only be supplied when editing the password**.</li><li>The `currentPassword` **must match the users existing password**.</li><li>`currentPassword` and `password` **must not be the same**.</li><li>`currentPassword` and `password` **must be at least 6 characters**</li></ul>. **Note**: A subset of values can be supplied in the body (i.e. only changing the email)"
security:
- UserToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PatchUser"
responses:
200:
description: "OK"
400:
description: "Bad request. Invalid information"
401:
description: "Unauthorized or Invalid currentPassword"
403:
description: "Forbidden. <ul><li>Can not edit another user's information</li><li>Email is already in use</li><li>Identical current and new passwords</li></ul>"
404:
description: "Not Found"
500:
description: "Internal Server Error"
/users/{id}/image:
parameters:
- name: "id"
description: "ID of the user"
in: path
required: true
schema:
$ref: "#/components/schemas/LoginResponse/properties/userId"
get:
tags:
- users.images
summary: "Retrieve a user's profile image"
description: "The response MIME type will be one of `image/png`, `image/jpeg`, or `image/gif` depending on the filetype of the image being retrieved."
responses:
200:
description: "OK"
content:
image:
schema:
$ref: "#/components/schemas/BinaryImageFile"
404:
description: "Not Found. No user with specified ID, or user has no image"
500:
description: "Internal Server Error"
put:
tags:
- users.images
summary: "Set a user's profile photo"
description: "Only accessible to the user themselves. If the user already has a profile photo, the current profile photo will be replaced with it and a 200 OK response sent. If not, a 201 Created response will be sent.<br>If the file is a `.png`, the request will be sent with `Content-Type: image/png`. If the file is a `.jpeg` or `.jpg`, the request will be sent with `Content-Type: image/jpeg`. If the file is a `.gif`, the request will be sent with `Content-Type: image/gif`.<br>The request body should contain the raw binary content of the photo, i.e. it should not be in `multipart/form-data` format or contain any file metadata."
security:
- UserToken: []
requestBody:
content:
image/png:
schema:
$ref: "#/components/schemas/BinaryImageFile"
image/jpeg:
schema:
$ref: "#/components/schemas/BinaryImageFile"
image/gif:
schema:
$ref: "#/components/schemas/BinaryImageFile"
required: true
responses:
200:
description: "OK. Image updated"
201:
description: "Created. New image created"
400:
description: "Bad Request. Invalid image supplied (possibly incorrect file type)"
401:
description: "Unauthorized"
403:
description: "Forbidden<ul><li>Can not change another user's profile photo</li></ul>"
404:
description: "Not found. No such user with ID given"
500:
description: "Internal Server Error"
delete:
tags:
- users.images
summary: "Delete a user's profile image"
security:
- UserToken: []
responses:
200:
description: "OK"
401:
description: "Unauthorized"
403:
description: "Forbidden. <ul><li>Can not delete another user's profile photo</li></ul>"
404:
description: "Not Found. No such user with ID given"
500:
description: "Internal Server Error"
/petitions:
get:
tags:
- petitions
summary: "View Petitions"
description: "Get a list of all petitions with a subset of information.</br>By default, the petitions should be sorted by when they were created from oldest to newest. The list should be filtered, then sorted, then paginated using `startIndex` and `count`. </br>The returned object must include the total number of petitions that match the search criteria, which may differ from the number returned by the query (this is for client-side pagination)."
parameters:
- in: query
name: startIndex
description: "Number of items to skip before returning results"
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/startIndex"
- in: query
name: count
description: "Number of items to include in results."
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/count"
- in: query
name: q
description: "Only include petitions that have the search 'q' term in their title or description."
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/q"
- in: query
name: categoryIds
description: "Only include petitions that match **any** of the given categories (by id). Only ids that map to categories allowed."
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/categoryIds"
- in: query
name: supportingCost
description: "Only include petitions that have at least 1 support tier less than or equal to the given value. A value of 0 will only include petitions that are free to support. If no value is provided the API must return all petitions."
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/supportingCost"
- in: query
name: ownerId
description: "Only include petitions that have the given user (id) as their owner."
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/ownerId"
- in: query
name: supporterId
description: "Only include petitions that where the given user (id) is a supporter."
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/supporterId"
- in: query
name: sortBy
description: "Sort the petitions by the given property, according to the following rules:<ul><li>`ALPHABETICAL_ASC`: alphabetically by title, A-Z</li><li>`ALPHABETICAL_DESC`: alphabetically by title, Z-A</li><li>`COST_ASC`: by cost of cheapest support tier ascending</li><li>`COST_DESC`: by cost of cheapest support tier descending</li></li>`CREATED_ASC`: chronologically in order of creation date oldest-newest</li><li>`CREATED_DESC`: chronologically in order of creation date newest-oldest</li></ul>All sorting cases must include a tie-breaker on **petitionId**"
schema:
$ref: "#/components/schemas/PetitionSearchRequest/properties/sortBy"
responses:
200:
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/PetitionSearchResponse"
400:
description: "Bad Request"
500:
description: "Internal Server Error"
post:
tags:
- petitions
summary: "Add a new petition"
description: "Create a new petition.<ul><li> The `categoryId` **must reference an existing category**, if it does not it must return a 400.</li><li>A Petition **must have between 1 and 3** `supportTiers` (inclusive), if it does not it must return a 400.</li><li>The `title` **must be unique**, otherwise it must return a 403.</li><li>Each `supportTier.title` **must be unique within those for the petition**, otherwise it must return a 400.</li></ul>"
security:
- UserToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PostPetition"
responses:
201:
description: "Created"
content:
application/json:
schema:
properties:
petitionId:
$ref: "#/components/schemas/PetitionOverview/properties/petitionId"
400:
description: "Bad Request"
401:
description: "Unauthorized"
403:
description: "Forbidden. <ul><li>Only the owner of a petition may change it</li><li>Petition title already exists</li></ul>"
500:
description: "Internal Server Error"
/petitions/{id}:
parameters:
- name: id
description: "The id of the petition"
in: path
required: true
schema:
$ref: "#/components/schemas/PetitionOverview/properties/petitionId"
get:
tags:
- petitions
summary: "Retrieve detailed information about a petition"
description: "Retrieve all information about a petition matching `id`."
responses:
200:
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/Petition"
404:
description: "Not Fount. No petition with id"
500:
description: "Internal Server Error"
patch:
tags:
- petitions
summary: "Update an existing petition"
description: "Make changes to the basic attributes (`title`, `description` and `cost`) of an existing petition. Only accessible to the owner of the petition. **The same requirements as posting a petition exist**.<br>These basic values for a petition can be updated at any time, even if there are already supporters."
security:
- UserToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PatchPetition"
responses:
200:
description: "OK"
400:
description: "Bad Request. Invalid information"
401:
description: "Unauthorized"
403:
description: "Forbidden. <ul><li>Only the owner of a petition may change it</li><li>Petition title already exists</li></ul>"
404:
description: "Not Found. No petition found with id"
500:
description: "Internal Server Error"
delete:
tags:
- petitions
summary: "Delete a petition"
description: "Delete an existing petition. Only accessible to the owner of the petition. **Can not delete a petition if it has a supporter for any of its support tiers**"
security:
- UserToken: []
responses:
401:
description: "Unauthorized"
403:
description: "Forbidden.<ul><li>Only the owner of a petition may delete it</li><li>Can not delete a petition with one or more supporters</li></ul>"
404:
description: "Not Found. No petition found with id"
500:
description: "Internal Server Error"
/petitions/categories:
get:
tags:
- petitions
summary: "Get all petition categories"
description: "Retrieve a list of all accepted categories for petitions"
responses:
200:
description: "OK"
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Category"
500:
description: "Internal Server Error"
/petitions/{id}/image:
parameters:
- name: id
description: "Petition id"
in: path
required: true
schema:
$ref: "#/components/schemas/PetitionOverview/properties/petitionId"
get:
tags:
- petitions.images
summary: "Get a petition image"
description: "Gets the specified petition's image. The response MIME type will be either `image/png`, `image/jpeg`, or `image/gif`, depending on the file type of the image being retrieved."
responses:
200:
description: "OK"
content:
image:
schema:
$ref: "#/components/schemas/BinaryImageFile"
404:
description: "Not found.<ul><li>No petition with id</li><li>Petition has no image</li></ul>"
500:
description: "Internal Server Error"
put:
tags:
- petitions.images
summary: "Set a petition hero image"
description: "Set the specified petition's hero image. Only available to the owner of the petition. If the petition already has a hero image, the current hero image will be replaced and a 200 OK response sent. If not, a 201 created response will be sent.<br>If the file is a `.png`, the request will be sent with `Content-Type: image/png`. If the file is a `.jpeg` or `.jpg`, the request will be sent with `Content-Type: image/jpeg`. If the file is a `.gif`, the request will be sent with `Content-Type: image/gif`. No other image types should be allowed. <br>The request body should contain the raw binary content of the photo, i.e. it should not be in `multipart/form-data` format or contain any file metadata."
security:
- UserToken: []
requestBody:
content:
image/png:
schema:
$ref: '#/components/schemas/BinaryImageFile'
image/jpeg:
schema:
$ref: '#/components/schemas/BinaryImageFile'
image/gif:
schema:
$ref: '#/components/schemas/BinaryImageFile'
required: true
responses:
200:
description: "OK. Image updated"
201:
description: "Created. Image added"
400:
description: "Bad Request"
401:
description: "Unauthorized"
403:
description: "Forbidden. Only the owner of a petition can change the hero image"
404:
description: "Not Found. No petition found with id"
500:
description: "Internal Server Error"
/petitions/{id}/supportTiers:
parameters:
- name: id
description: "Petition id"
in: path
required: true
schema:
$ref: "#/components/schemas/PetitionOverview/properties/petitionId"
put:
tags:
- petitions.supportTiers
summary: "Add a new petition support tier"
description: "Add a new support tier. **Can not be added if 3 support tiers already exist**. The **title must be unique within the support tiers** of the petition."
security:
- UserToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PostSupportTier"
responses:
201:
description: "OK"
400:
description: "Bad Request"
401:
description: "Unauthorized"
404:
description: "Not Found"
403:
description: "Forbidden<ul><li>Only the owner of a petition may modify it</li><li>Can add a support tier if 3 already exist</li><li>Support title not unique within petition</li></ul>"
500:
description: "Internal Server Error"
/petitions/{id}/supportTiers/{tierId}:
parameters:
- name: id
description: "Petition id"
in: path
required: true
schema:
$ref: "#/components/schemas/PetitionOverview/properties/petitionId"
- name: tierId
description: "Support Tier id"
in: path
required: true
schema:
$ref: "#/components/schemas/PetitionOverview/properties/petitionId"
patch:
tags:
- petitions.supportTiers
summary: "Edit one of a petition's support tiers"
description: "Update a support tier. **Can not be updated if a supporter already exists for the specified tier**"
security:
- UserToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PatchSupportTier"
responses:
200:
description: "OK"
400:
description: "Bad Request"
401:
description: "Unauthorized"
403:
description: "Forbidden<ul><li>Only the owner of a petition may modify it</li><li>Can not edit a support tier if a supporter already exists for it</li><li>Support title not unique within petition</li></ul>"
404:
description: "Not Found"
500:
description: "Internal Server Error"
delete:
tags:
- petitions.supportTiers
summary: "Remove a petition support tier"
description: "Remove a support tier. **Can not be removed if a supporter already exists for the specified tier**, **Can not remove a support tier if it is the only one for a petition**"
security:
- UserToken: []
responses:
200:
description: "OK"
400:
description: "Bad Request"
401:
description: "Unauthorized"
403:
description: "Forbidden<ul><li>Only the owner of a petition may delete it</li><li>Can not delete a support tier if a supporter already exists for it</li><li>Can not remove a support tier if it is the only one for a petition</li></ul>"
404:
description: "Not Found"
500:
description: "Internal Server Error"
/petitions/{id}/supporters:
parameters:
- name: id
description: "Petition id"
in: path
required: true
schema:
$ref: "#/components/schemas/PetitionOverview/properties/petitionId"
get:
tags:
- petitions.supporters
summary: "Get all the supporters of a petition"
description: "Get a list of all supporters of the specified petition. The supporters are returned in reverse chronological order (from most recent to oldest) by `timestamp`."
responses:
200:
description: "OK"
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Supporter"
404:
description: "Not Found. No petition with id"
500:
description: "Internal Server Error"
post:
tags:
- petitions.supporters
summary: "Support a petition"
description: "Support the specified petition at the specified tier. A user can support multiple different tiers of the same petition, but may only support at each tier once"
security:
- UserToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PostSupport"
responses:
201:
description: "Created"
400:
description: "Bad Request"
401:
description: "Unauthorized"
403:
description: "Forbidden.<ul><li>Cannot support your own petition</li><li>Already supported at this tier</li></ul>"
404:
description: "Not Found.<ul><li>No petition found with id</li><li>Support tier does not exist</li></ul>"
500:
description: "Internal Server Error"
components:
schemas:
SqlResult:
type: object
properties:
fieldCount:
type: integer
example: 0
affectedRows:
type: integer
example: 1
insertId:
type: integer
example: 1
serverStatus:
type: integer
example: 2
warningCount:
type: integer
example: 0
message:
type: string
example: "(Rows matched: 1 Changed: 0 Warnings 0)"
protocol41:
type: boolean
example: true
changedRows:
type: integer
example: 0
SqlResultSet:
type: array
items: {}
UserEmail:
title: UserEmail
type: object
properties:
email:
type: string
description: "<i>Must include an @ symbol and a top level domain i.e. \"[email protected]\"</i>"
minLength: 1
maxLength: 256
format: email
example: "[email protected]"
UserPassword:
title: UserPassword
properties:
password:
type: string
minLength: 6
maxLength: 64
format: password
example: "password"
UserCurrentPassword:
title: UserCurrentPassword
properties:
currentPassword:
type: string
minLength: 6
maxLength: 64
format: password
example: "old_password"
User:
title: User
type: object
allOf:
- $ref: "#/components/schemas/UserEmail"
properties:
firstName:
type: string
minLength: 1
maxLength: 64
example: "Jane"
lastName:
type: string
minLength: 1
maxLength: 64
example: "Doe"
RegisterUser:
title: RegisterUser
type: object
allOf:
- $ref: "#/components/schemas/User"
- $ref: "#/components/schemas/UserPassword"
required:
- firstName
- lastName
- email
- password
LoginUser:
title: LoginUser
type: object
allOf:
- $ref: "#/components/schemas/UserEmail"
- $ref: "#/components/schemas/UserPassword"
required:
- email
- password
RegisterResponse:
title: RegisterResponse
type: object
properties:
userId:
type: integer
minimum: 0
example: 11
LoginResponse:
title: LoginResponse
type: object
properties:
userId:
type: integer
minimum: 0
example: 11
token:
type: string
example: "JSkIEpXk0b2jLgDpRuKAjGwCbFnDM0Tj"
PatchUser:
title: PatchUser
type: object
allOf:
- $ref: "#/components/schemas/User"
- $ref: "#/components/schemas/UserPassword"
- $ref: "#/components/schemas/UserCurrentPassword"
DateTimeInput:
title: DateTimeInput
description: A datetime expressed with no timezone, as either a date (yyyy-MM-dd) or date and time (yyyy-MM-dd hh:mm:ss.sss)
type: string
example: '2012-04-23 18:25:43'
DateTimeOutput:
title: DateTimeOutput
description: A UTC datetime expressed in ISO8601 format (yyyy-MM-ddThh:mm:ss.sssZ)
type: string
example: '2012-04-23T18:25:43.511Z'
BinaryImageFile:
type: string
format: binary
description: The raw content of the PNG, JPEG, or GIF image file.
example: (raw content of PNG, JPEG, or GIF image file)
Category:
title: Category
type: object
properties:
categoryId:
type: integer
minimum: 0
example: 1
nullable: false
name:
type: string
minLength: 1
maxLength: 64
example: "Art"
nullable: false
PetitionSearchRequest:
title: PetitionSearchRequest
type: object
properties:
startIndex:
type: integer
minimum: 0
default: 0
example: 10
count:
type: integer
minimum: 0
example: 10
q:
type: string
minLength: 1
maxLength: 64
example: "Park"
categoryIds:
type: array
items:
$ref: "#/components/schemas/Category/properties/categoryId"
supportingCost:
title: SupportingCost
type: integer
minimum: 0
example: 5
ownerId:
$ref: "#/components/schemas/LoginResponse/properties/userId"
supporterId:
$ref: "#/components/schemas/LoginResponse/properties/userId"
sortBy:
type: string
enum:
- ALPHABETICAL_ASC
- ALPHABETICAL_DESC
- COST_ASC
- COST_DESC
- CREATED_ASC
- CREATED_DESC
default: CREATED_ASC
PetitionSearchResponse:
title: PetitionSearchResponse
type: object
properties:
petitions:
type: array
items:
$ref: "#/components/schemas/PetitionOverviewIncCost"
nullable: false
count:
type: integer
minimum: 0
example: 15
nullable: false
PetitionOverview:
title: PetitionOverview
type: object
properties:
petitionId:
type: integer
minimum: 0
example: 1
nullable: false
title:
type: string
example: "Park Preservation"
minLength: 1
maxLength: 128
categoryId:
$ref: "#/components/schemas/Category/properties/categoryId"
ownerId:
$ref: "#/components/schemas/LoginResponse/properties/userId"
ownerFirstName:
$ref: "#/components/schemas/User/properties/firstName"
ownerLastName:
$ref: "#/components/schemas/User/properties/lastName"
numberOfSupporters:
type: number
minimum: 0
example: 100
creationDate:
$ref: "#/components/schemas/DateTimeOutput"
PetitionOverviewIncCost:
title: PetitionOverviewIncCost
type: object
allOf:
- $ref: "#/components/schemas/PetitionOverview"
properties:
supportingCost:
type: integer
minimum: 0
example: 0
nullable: false
Petition:
title: Petition
type: object
allOf:
- $ref: "#/components/schemas/PetitionOverview"
properties:
description:
type: string
minLength: 1
maxLength: 1024
example: "Help us renovate the local park!"
moneyRaised:
type: integer
minimum: 0
example: 950
supportTiers:
type: array
items:
$ref: "#/components/schemas/SupportTier"
PatchSupportTier:
title: PatchSupportTier
type: object
properties:
title:
type: string
minLength: 1
maxLength: 128
example: "Primary Supporter"
nullable: false
description:
type: string
minLength: 1
maxLength: 1024
example: "Supporting this tier will include getting your name included on a plaque"
nullable: false
cost:
type: integer
minimum: 0
example: 10
nullable: false
PostSupportTier:
title: PostSupportTier
type: object
allOf:
- $ref: "#/components/schemas/PatchSupportTier"
required:
- "title"
- "description"
- "cost"
SupportTier:
title: SupportTier
type: object
allOf:
- $ref: "#/components/schemas/PatchSupportTier"
properties:
supportTierId:
type: integer
minimum: 0
example: 1
nullable: false
PatchPetition:
title: PatchPetition
type: object
properties:
title:
$ref: "#/components/schemas/PetitionOverview/properties/title"
description:
$ref: "#/components/schemas/Petition/properties/description"
categoryId:
$ref: "#/components/schemas/PetitionOverview/properties/categoryId"
PostPetition:
title: PostPetition
type: object
properties:
title:
$ref: "#/components/schemas/PetitionOverview/properties/title"
description:
$ref: "#/components/schemas/Petition/properties/description"
categoryId:
$ref: "#/components/schemas/PetitionOverview/properties/categoryId"
supportTiers:
type: array
items:
type: object
allOf:
- $ref: "#/components/schemas/PatchSupportTier"
required:
- title
- description
- cost
required:
- title
- description
- categoryId
- supportTiers
Supporter:
title: Supporter
type: object
properties:
supportId:
type: integer
minimum: 1
example: 1
nullable: false
supportTierId:
$ref: "#/components/schemas/SupportTier/properties/supportTierId"
nullable: false
message:
type: string
minLength: 1