-
Notifications
You must be signed in to change notification settings - Fork 9
/
swagger.yaml
848 lines (829 loc) · 22.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
swagger: '2.0'
info:
version: '1.0'
title: "Czechitas DA App"
description: >
**Czechitas DA App** is application made for testing and educational purposes for [Czechitas Digital Academy](https://www.czechitas.cz/cs/co-delame/digitalni-akademie).
license:
name: MIT
url: https://github.com/czechitas-ostrava/registration-app/blob/master/LICENSE
host: czechitas-app.kutac.cz
basePath: /api/
schemes:
- https
consumes:
- application/json
produces:
- application/json
securityDefinitions:
Bearer token:
type: apiKey
name: Authorization
in: header
description: >
Add `Authorization` header with value `Bearer {{token}}`.
**Example value:** `Bearer ATlf4s6d18ds43sadrt48vc3s34`
tags:
- name: Categories collection
- name: Orders collection
- name: Users collection
- name: Terms collection
paths:
/categories:
get:
summary: List all categories
tags: [Categories collection]
responses:
200:
description: Successful Response
schema:
type: array
items:
$ref: '#/definitions/Category'
examples:
application/json:
- id: 1
parent_id: null
name: Programování
slug: 1-programovani
content: "# Programování a vše okolo"
position: 1
created_at: '2021-02-18T21:01:27.000000Z'
updated_at: '2021-02-18T21:01:27.000000Z'
imagePath: 'https://czechitas.loc/uploads/category/1-programovani.jpg?v1614019523'
children:
- id: 2
parent_id: 1
name: JavaScript
slug: 2-js
contains_school: 0
content: "## Zaměření hlavně na JavaScript a NodeJS"
position: 1
created_at: '2021-02-18T21:01:45.000000Z'
updated_at: '2021-02-18T21:01:45.000000Z'
imagePath: 'https://czechitas.loc/uploads/category/2-js.jpg?v1614020508'
401:
$ref: '#/responses/401'
403:
$ref: '#/responses/403'
/orders:
post:
tags: [Orders collection]
summary: Create a new Order
parameters:
- name: body
in: body
required: true
schema:
$ref: '#/definitions/OrderRequest'
responses:
201:
description: Create new order
schema:
$ref: '#/definitions/Order'
examples:
application/json:
id: 7
type: camp
client: Školka u rybníčku
ico: 09902244
address: 'U Lomu 159, Horni Dolni 988 77'
substitute: Mnou
contact_name: Vojim Vomacka
contact_tel: '+420777888999'
contact_mail: [email protected]
start_date_1: '2020-12-31T23:00:00.000000Z'
start_date_2: null
start_date_3: null
xdata:
students: 22
age: 15-20
adults: 5
end_date_1: '2021-01-09T23:00:00.000000Z'
end_date_2: null
end_date_3: null
date_part: afternoon
updated_at: '2021-02-24T19:39:25.000000Z'
created_at: '2021-02-24T19:39:25.000000Z'
401:
$ref: '#/responses/401'
403:
$ref: '#/responses/403'
422:
$ref: '#/responses/422'
/users/register:
post:
tags: ['Users collection']
summary: Register new user with role Parent
parameters:
- name: body
in: body
required: true
schema:
type: object
required:
- name
- email
- password
properties:
name:
type: string
email:
type: string
format: email
description: Is also username in the UI
password:
type: string
format: password
responses:
201:
description: Created new user
schema:
type: object
required:
- id
- name
- email
- role
- access_token
properties:
id:
type: number
name:
type: string
email:
type: string
role:
type: string
enum: [parent]
description: New user is always parent role
created_at:
type: string
format: date-time
description: DateTime in RFC3339 format
updated_at:
type: string
format: date-time
description: DateTime in RFC3339 format
access_token:
type: string
description: Bearer token for new user
examples:
application/json:
id: 10
name: Vojim Vomacka
email: [email protected]
role: parent
created_at: '2021-02-24T21:54:26.000000Z'
updated_at: '2021-02-24T21:54:26.000000Z'
access_token: "***"
422:
$ref: '#/responses/422'
/users/current:
get:
tags: ['Users collection']
security:
- Bearer token: ['parent', 'admin', 'master']
summary: Get current logged in user
responses:
200:
description: Authenticated user
schema:
type: object
required:
- id
- name
- email
- role
properties:
id:
type: number
name:
type: string
email:
type: string
is_blocked:
type: boolean
role:
type: string
enum: [parent]
description: New user is always parent role
created_at:
type: string
format: date-time
description: DateTime in RFC3339 format
updated_at:
type: string
format: date-time
description: DateTime in RFC3339 format
examples:
application/json:
id: 10
name: Vojim Vomacka
email: [email protected]
is_blocked: false
role: parent
created_at: '2021-02-24T21:54:26.000000Z'
updated_at: '2021-02-24T21:54:26.000000Z'
401:
$ref: '#/responses/401'
/terms:
get:
summary: List all terms
tags: [Terms collection]
security:
- Bearer token: ['parent', 'admin', 'master']
parameters:
- name: page
in: query
required: false
type: integer
minimum: 1
default: 1
- name: perPage
in: query
required: false
type: integer
minimum: 1
maximum: 100
default: 50
responses:
200:
description: Lists all terms. When `parent` is authenticated, only available terms are listed.
schema:
type: array
items:
type: object
required: [id, category_id, start, end, price]
properties:
id:
type: number
category_id:
type: number
start:
type: string
format: date-time
end:
type: string
format: date-time
opening:
type: string
format: date-time
price:
type: number
minimum: 1
examples:
application/json:
- id: 1
category_id: 2
start: '2021-02-21T23:00:00.000000Z'
end: '2021-02-27T23:00:00.000000Z'
opening: null
price: 495
- id: 7
category_id: 2
start: '2021-04-30T22:00:00.000000Z'
end: '2021-05-03T22:00:00.000000Z'
opening: '2021-02-20T16:23:55.000000Z'
price: 1600
401:
$ref: '#/responses/401'
403:
$ref: '#/responses/403'
post:
summary: Crate new term
tags: [Terms collection]
security:
- Bearer token: ['admin', 'master']
parameters:
- name: body
in: body
required: true
schema:
$ref: '#/definitions/TermRequest'
responses:
201:
description: Successful creation
schema:
$ref: '#/definitions/Term'
examples:
application/json:
id: 8
category_id: 2
start: '2021-02-02T23:00:00.000000Z'
end: '2021-02-03T23:00:00.000000Z'
opening: '2021-05-20T15:23:55.000000Z'
price: 800
note_public: ''
note_private: ''
updated_at: '2021-02-24T23:12:09.000000Z'
created_at: '2021-02-24T23:12:09.000000Z'
401:
$ref: '#/responses/401'
403:
$ref: '#/responses/403'
422:
$ref: '#/responses/422'
/terms/{termId}:
get:
summary: Get single term
tags: [Terms collection]
security:
- Bearer token: ['parent', 'admin', 'master']
parameters:
- name: termId
in: path
description: Id of Term to get
required: true
type: integer
responses:
200:
description: Show details of selected term. Return only some columns for parent
schema:
$ref: '#/definitions/Term'
examples:
application/json:
id: 7
category_id: 2
flag: null
start: '2021-04-30T22:00:00.000000Z'
end: '2021-05-03T22:00:00.000000Z'
opening: '2021-02-20T16:23:55.000000Z'
price: 1600
note_public: '# Here comes the sun...'
note_private: ''
created_at: '2021-02-22T19:43:25.000000Z'
updated_at: '2021-02-22T19:56:00.000000Z'
deleted_at: null
401:
$ref: '#/responses/401'
403:
$ref: '#/responses/403'
404:
$ref: '#/responses/404'
put:
summary: Update term
tags: [Terms collection]
security:
- Bearer token: ['admin', 'master']
parameters:
- name: termId
in: path
description: Id of Term to update
required: true
type: integer
- name: body
in: body
required: true
schema:
$ref: '#/definitions/TermRequest'
responses:
200:
description: Successful update
schema:
$ref: '#/definitions/Term'
examples:
application/json:
id: 8
category_id: 2
start: '2021-02-02T23:00:00.000000Z'
end: '2021-02-03T23:00:00.000000Z'
opening: '2021-05-20T15:23:55.000000Z'
price: 800
note_public: ''
note_private: ''
updated_at: '2021-02-24T23:12:09.000000Z'
created_at: '2021-02-24T23:12:09.000000Z'
401:
$ref: '#/responses/401'
403:
$ref: '#/responses/403'
404:
$ref: '#/responses/404'
422:
$ref: '#/responses/422'
delete:
summary: Delete term
tags: [Terms collection]
security:
- Bearer token: ['admin', 'master']
parameters:
- name: termId
in: path
description: Id of Term to delete
required: true
type: integer
responses:
200:
description: Successful delete
schema:
type: string
examples:
application/json:
"OK"
401:
$ref: '#/responses/401'
403:
$ref: '#/responses/403'
404:
$ref: '#/responses/404'
responses:
401:
description: Missing token
schema:
type: object
properties:
message:
type: string
example: "Unauthenticated."
examples:
application/json:
message: Unauthenticated.
403:
description: Forbidden
schema:
type: object
properties:
message:
type: string
example: "This action is unauthorized."
examples:
application/json:
message: This action is unauthorized.
404:
description: Not found
schema:
type: object
properties:
message:
type: string
example: "No query result"
examples:
application/json:
message: "No query results for model [CzechitasApp\\Models\\Term] 100"
422:
description: Failed validation
schema:
$ref: '#/definitions/ValidationError'
examples:
application/json:
message: The given data was invalid.
errors:
email:
- The email field is required.
end:
- The end must be a date after or equal to start.
definitions:
ValidationError:
title: Response when request contains invalid data
type: object
properties:
message:
type: string
errors:
type: object
additionalProperties:
type: array
items:
type: string
SecondLevelCategory:
title: Category nested under parent category
type: object
required: [id, name, slug, position]
properties:
id:
type: number
parent_id:
type: number
name:
type: string
slug:
type: string
example: javascript
description: Must be valid for URL
content:
type: string
format: markdown
position:
type: number
created_at:
type: string
format: date-time
description: Date in RFC3339 format
updated_at:
type: string
format: date-time
description: Date in RFC3339 format
image_path:
type: string
format: url
Category:
title: Top level Category
type: object
required: [id, name, slug, position]
properties:
id:
type: number
parent_id:
type: number
name:
type: string
slug:
type: string
description: Must be valid for URL
content:
type: string
format: markdown
description: Supports markdown
position:
type: number
created_at:
type: string
format: date-time
description: Date in RFC3339 format
updated_at:
type: string
format: date-time
description: Date in RFC3339 format
image_path:
type: string
format: url
children:
type: array
items:
$ref: '#/definitions/SecondLevelCategory'
OrderRequest:
title: Order of Camp or School in nature
type: object
required:
- type
- client
- ico
- address
- substitute
- contact_name
- contact_tel
- contact_mail
- start_date_1
- end_date_1
- students
- age
- adults
properties:
type:
type: string
enum: [camp,school_nature]
description: According to selected type, another attributes might be requested as well
client:
type: string
ico:
type: string
maxLength: 15
address:
type: string
description: Address of the client, mostly school address
substitute:
type: string
description: "Mostly the director of the school"
contact_name:
type: string
description: Name of main teacher who is contacted according to the Camp or School in nature
contact_tel:
type: string
format: phone number
description: Phone number of the contact
contact_mail:
type: string
format: email
description: Email of the contact
start_date_1:
type: string
format: date
description: Beginning of 1. prefered term in YYYY-mm-dd format
end_date_1:
type: string
format: date
description: End of 1. prefered term in YYYY-mm-dd format
start_date_2:
type: string
format: date
description: Beginning of 2. prefered term in YYYY-mm-dd format
end_date_2:
type: string
format: date
description: End of 2. prefered term in YYYY-mm-dd format
start_date_3:
type: string
format: date
description: Beginning of 3. prefered term in YYYY-mm-dd format
end_date_3:
type: string
format: date
description: End of 3. prefered term in YYYY-mm-dd format
students:
type: number
minimum: 1
age:
type: string
maxLength: 30
description: What age students are, any textual representation
adults:
type: number
minimum: 1
date_part:
type: string
enum: [forenoon,afternoon]
description: Required only for camp type
start_time:
type: string
format: HH:ii
description: Required only for school_nature type
start_food:
type: string
enum: [breakfast,lunch,dinner]
description: Required only for school_nature type
end_time:
type: string
format: HH:ii
description: Required only for school_nature type
end_food:
type: string
enum: [breakfast,lunch,dinner]
description: Required only for school_nature type
Order:
title: Order response of Camp or School in nature
type: object
required:
- id
- type
- client
- ico
- address
- substitute
- contact_name
- contact_tel
- contact_mail
- start_date_1
- xdata
properties:
id:
type: number
type:
type: string
enum: [camp,school_nature]
description: According to selected type, another attributes might be requested as well
client:
type: string
ico:
type: string
maxLength: 15
address:
type: string
description: Address of the client, mostly school address
substitute:
type: string
description: "Mostly the director of the school"
contact_name:
type: string
description: Name of main teacher who is contacted according to the Camp or School in nature
contact_tel:
type: string
format: phone number
description: Phone number of the contact
contact_mail:
type: string
format: email
description: Email of the contact teacher
start_date_1:
type: string
example: "2021-02-23"
description: Beginning of 1. prefered term in YYYY-mm-dd format
start_date_2:
type: string
example: "2021-02-23"
description: Beginning of 2. prefered term in YYYY-mm-dd format
start_date_3:
type: string
example: "2021-02-23"
description: Beginning of 3. prefered term in YYYY-mm-dd format
xdata:
type: object
properties:
end_date_1:
type: string
example: "2021-02-24"
description: End of 1. prefered term in YYYY-mm-dd format
end_date_2:
type: string
example: "2021-02-24"
description: End of 2. prefered term in YYYY-mm-dd format
end_date_3:
type: string
example: "2021-02-24"
description: End of 3. prefered term in YYYY-mm-dd format
students:
type: number
minimum: 1
age:
type: string
maxLength: 30
description: What age students are, any textual representation
adults:
type: number
minimum: 1
date_part:
type: string
enum: [forenoon,afternoon]
description: Required only for camp type
start_time:
type: string
format: HH:MM
description: Required only for school_nature type
start_food:
type: string
enum: [breakfast,lunch,dinner]
description: Required only for school_nature type
end_time:
type: string
format: HH:MM
description: Required only for school_nature type
end_food:
type: string
enum: [breakfast,lunch,dinner]
description: Required only for school_nature type
created_at:
type: string
format: date-time
description: Date in RFC3339 format
updated_at:
type: string
format: date-time
description: Date in RFC3339 format
Term:
title: Term
type: object
required: [id, category_id, start, end, price]
properties:
id:
type: number
category_id:
type: number
flag:
type: string
start:
type: string
format: date-time
end:
type: string
format: date-time
opening:
type: string
format: date-time
price:
type: number
minimum: 1
note_public:
type: string
format: markdown
note_private:
type: string
format: markdown
created_at:
type: string
format: date-time
description: Date in RFC3339 format
updated_at:
type: string
format: date-time
description: Date in RFC3339 format
deleted_at:
type: string
format: date-time
description: Date in RFC3339 format
TermRequest:
title: Term request
type: object
required: [category_id, start, end, price]
properties:
category_id:
type: number
minimum: 1
start:
type: string
format: date
end:
type: string
format: date
opening:
type: string
example: null
description: "Must be in format like '2021-01-30T12:34:56+02:00', Z as timezone cannot be used"
price:
type: number
minimum: 1
note_public:
type: string
format: markdown
note_private:
type: string
format: markdown