forked from olegkrav/doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
1667 lines (1620 loc) · 45.1 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: |
### Конструктор приложений
version: 0.1.0
title: ''
termsOfService: ''
contact:
email: ''
x-logo:
url: ""
backgroundColor: "#FFFFFF"
basePath: /api/v4
host: foodexpress.russianit.ru
tags:
- name: errors
description: |
пример типовой ошибки:
```
{
"id": "the.error.id",
"message": "no connect oauth provider", // причина
"request_id": "", // ID запроса
"status_code": 0 // HTTP status code
}
- name: websocket
description: |
#### События
События WebSocket в основном используются для уведомления клиента об изменениях, таких как доставка новых сообщений или уведомления собеседнику о вводе текста.
```
{
"event": "hello",
"data": {
"server_version": "3.6.0.1451.1c38da627ebb4e3635677db6939e9195"
},
"broadcast":{
"omit_users": null,
"user_id": "ay5sq51sebfh58ktrce5ijtcwy",
"channel_id": "",
}
}
```
Поле `event` указывает тип события,` data` содержит любые данные, относящиеся к событию, а `broadcast` содержит информацию о том, кому было отправлено событие. Например, приведенный выше пример имеет `user_id`, установленный в" ay5sq51sebfh58ktrce5ijtcwy ", что означает, что только пользователь с этим идентификатором получил это событие. Поле `omit_users` может содержать массив идентификаторов пользователей, которые были исключены при получении события.
Список событий:
- typing
- posted
- hello
#### WebSocket API
```
{
"action": "user_typing",
"seq": 2,
"data": {
"channel_id": "nhze199c4j87ped4wannrjdt9c",
}
}
```
Это пример запроса `user_typing`, оповещает сервер о том, что подключенный клиент начал печатать в беседе. Поле `action` указывает, что запрашивается, и выполняет аналогичную функцию, как роут в HTTP API.
«seq» или порядковый номер задается клиентом и при каждом использовании должны быть увеличены. Он используется для различения ответов на запросы, поступающие с WebSocket. Например, стандартный ответ на вышеуказанный запрос:
```
{
"status": "OK",
"seq_reply": 2
}
```
Уведомление `seq_reply` равно 2, соответствуя` seq` исходного запроса. Используя это, клиент может различать, к какому запросу относится ответ.
В случае ошибки ответ будет следующим:
```
{
"status": "FAIL",
"seq_reply": 2,
"error": {
"id": "some.error.id.here",
"message": "Some error message here"
}
}
```
- name: auth
description: |
#### Авторизация.
- name: messages
description: |
#### Сообщения.
- name: files
description: |
#### Работа с файлами.
- name: categories
description: |
#### Категории.
- name: cart
description: |
#### Корзина.
- name: products
description: |
#### Товары.
- name: promos
description: |
#### Акции.
- name: order
description: |
#### Заказы.
- name: bonus
description: |
#### Бонусы.
x-tagGroups:
- name: Базовые определения
tags:
- errors
- websocket
- name: Авторизация и чат
tags:
- auth
- messages
- files
- name: Каталог
tags:
- categories
- products
- promos
- name: Заказ
tags:
- cart
- order
- bonus
schemes:
- http
consumes:
- application/json
produces:
- application/json
responses:
'Forbidden':
description: Доступ запрещён
schema:
$ref: '#/definitions/AppError'
'Unauthorized':
description: Access-Token не предоставлен
schema:
$ref: '#/definitions/AppError'
'BadRequest':
description: Недопустимые или отсутствующие параметры в URL-адресе или теле запроса
schema:
$ref: '#/definitions/AppError'
'NotFound':
description: Страница не найдена
schema:
$ref: '#/definitions/AppError'
'TooLarge':
description: Содержание слишком большое
schema:
$ref: '#/definitions/AppError'
'NotImplemented':
description: Функция отключена
schema:
$ref: '#/definitions/AppError'
'InternalServerError':
description: Что-то пошло не так с сервером
schema:
$ref: '#/definitions/AppError'
paths:
'/order/{user_id}':
post:
tags:
- order
summary: Формирование заказа
description: |
####
```
```
parameters:
- in: path
name: "{user_id}"
description: ид пользователя
required: true
type: string
- in: body
schema:
$ref: '#/definitions/OrderBody'
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/CheckoutOrderResponse'
'/order/{order_id}':
get:
tags:
- order
summary: Просмотр заказа
description: |
####
```
```
parameters:
- in: path
name: "{order_id}"
description: ид заказа
required: true
type: int
'/order/{user_id}/history':
get:
tags:
- order
summary: История заказов у пользователя
description: |
####
```
```
parameters:
- in: path
name: "{user_id}"
description: ид пользователя
required: true
type: string
- in: query
name: page
description: номер страницы
- in: query
name: per_page
description: количество элементов на странице
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/OrderHistory'
'/cart/{user_id}':
get:
tags:
- cart
summary: Просмотр корзины пользователя
description: |
####
```
```
parameters:
- in: path
name: "{user_id}"
description: ид пользователя
required: true
type: string
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/Cart'
post:
tags:
- cart
summary: Добавление товаров в корзину
description: |
####
```
```
parameters:
- in: path
name: "{user_id}"
description: ид пользователя
required: true
type: string
- in: body
schema:
$ref: '#/definitions/CartItems'
'/users/reg':
post:
tags:
- auth
summary:
description: Регистрация пользователя по номеру телефона
parameters:
- name: nickname
in: path
description: Имя пользователя для отображения
required: true
type: string
- name: phone
in: path
description: Телефон, формат (7XXXXXXXXX)
required: true
type: string
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/RegToken'
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'/users/send':
post:
tags:
- auth
summary:
description: Отправка СМС сообщения с кодом доступа
parameters:
- name: token
in: path
description: Токен досутпа
required: true
type: string
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/StatusOK'
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'/users/verify':
post:
tags:
- auth
summary:
description: Подтверждения регистрации
parameters:
- name: token
in: path
description: Токен доступа
required: true
type: string
- name: code
in: path
description: Код подверждения
required: true
type: string
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/UserReg'
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'/tokens/{token}':
get:
tags:
- auth
summary:
description: Получить информации по токену доступа
parameters:
- name: token
in: path
description: Токена
required: true
type: string
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/GetToken'
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'/attach_device':
post:
tags:
- auth
summary:
description: Привязка токена устройства
parameters:
- name: device_id
in: path
description: Токен устройства
required: true
type: string
responses:
'200':
description: Успешно
schema:
$ref: '#/definitions/StatusOK'
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'/messages':
get:
tags:
- messages
summary: Возвращает список сообщений
description: |
Возвращет список сообщений. Параметры `since`, `before` и `after` нельзя использовать совместно.
parameters:
- name: page
in: query
description: Порядковый номер страницы
default: "0"
type: string
- name: per_page
in: query
description: Количество записей на странице
default: "60"
type: string
- name: since
in: query
description: Ненулевое значение в миллисекундах (unix), чтобы выбрать сообщения, созданные после этого времени
type: integer
- name: before
in: query
description: Идентификатор сообщения для выбора сообщений, которые были до него
type: string
- name: after
in: query
description: Идентификатор сообщения для выбора сообщений, которые были после
type: string
responses:
'200':
description: Список сообщений
schema:
$ref: "#/definitions/MessageList"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
post:
tags:
- messages
summary: Создание сообщения
description: ''
parameters:
- in: body
name: post
description: json
required: true
schema:
type: object
required:
- message
properties:
message:
type: string
description: Текст сообщения, поддерживает markdown
local_id:
type: string
description: Дополнительный идентификатор для мобильного клиента
file_ids:
type: array
description: Массив идентификаторов прикрепленных файлов
items:
type: string
responses:
'201':
description: Успешное создание сообщения
schema:
$ref: '#/definitions/Message'
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'/messages/{message_id}':
get:
tags:
- messages
summary: Получить сообщение
description: |
Получить одно сообщение
parameters:
- name: message_id
in: path
description: Идентификатор сообщения
required: true
type: string
responses:
'200':
description: Возвращает сообщение
schema:
$ref: "#/definitions/Message"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
/files:
post:
tags:
- files
summary: Загрузка файла
description: |
consumes: ["multipart/form-data"]
parameters:
- name: files
in: formData
description: Данные файлов
required: true
type: file
- name: channel_id
in: formData
description: Ид канала
required: true
type: string
- name: local_ids
in: formData
description: Локальный идентифкатор файлов
required: false
allowEmptyValue: true
type: string
responses:
'200':
description: Возврашает сопостовление локального идентификатора и ид в базе данных
schema:
type: object
properties:
file_infos:
description:
type: array
items:
$ref: '#/definitions/FileInfo'
local_ids:
description:
type: array
items:
type: string
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'413':
$ref: '#/responses/TooLarge'
'501':
$ref: '#/responses/NotImplemented'
'/files/{file_id}':
get:
tags:
- files
summary: Получить файл
description: |
parameters:
- name: file_id
in: path
description: Идентификатор файла (local_id, id)
required: true
type: string
responses:
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'501':
$ref: '#/responses/NotImplemented'
'/files/{file_id}/thumbnail':
get:
tags:
- files
summary: Картинка предпросмотра
description: |
parameters:
- name: file_id
in: path
description: Идентификатор файла (local_id, id)
required: true
type: string
responses:
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'501':
$ref: '#/responses/NotImplemented'
'/files/{file_id}/info':
get:
tags:
- files
summary: Метаданные файла
description: |
parameters:
- name: file_id
in: path
description: Идентификатор файла (local_id, id)
required: true
type: string
responses:
'200':
description: Метаданные
schema:
$ref: "#/definitions/FileInfo"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'404':
$ref: '#/responses/NotFound'
'501':
$ref: '#/responses/NotImplemented'
##################################################################################################################
'/categories':
get:
tags:
- categories
summary: Список категорий
description: |
###
parameters:
- in: query
name: client_id
type: string
description: ид организации
responses:
200:
description: Возвращает список категорий
schema:
$ref: '#/definitions/Categories'
400:
$ref: '#/responses/BadRequest'
401:
$ref: '#/responses/Unauthorized'
403:
$ref: '#/responses/Forbidden'
404:
$ref: '#/responses/NotFound'
501:
$ref: '#/responses/NotImplemented'
post:
tags:
- categories
summary: Создание категории
description: |
###
parameters:
- in: body
name: post
description: json
schema:
$ref: '#/definitions/Category'
responses:
200:
description: Возвращает информацию о созданной категории
schema:
$ref: '#/definitions/Category'
400:
$ref: '#/responses/BadRequest'
401:
$ref: '#/responses/Unauthorized'
403:
$ref: '#/responses/Forbidden'
404:
$ref: '#/responses/NotFound'
501:
$ref: '#/responses/NotImplemented'
'/categories/{category_id}/path':
get:
tags:
- categories
summary: Информация о категории и его потомках
description: |
###
parameters:
- in: path
name: "{category_id}"
type: integer
description: идентификатор организации
required: true
responses:
200:
description: Успешно
schema:
$ref: "#/definitions/Category"
400:
$ref: '#/responses/BadRequest'
401:
$ref: '#/responses/Unauthorized'
403:
$ref: '#/responses/Forbidden'
501:
$ref: '#/responses/NotImplemented'
'/categories/{category_id}':
get:
tags:
- categories
summary: Информация о категории
description: |
###
parameters:
- in: path
name: "{category_id}"
type: integer
description: идентификатор категории
required: true
responses:
200:
description: Успешно
schema:
$ref: "#/definitions/Category"
400:
$ref: '#/responses/BadRequest'
401:
$ref: '#/responses/Unauthorized'
403:
$ref: '#/responses/Forbidden'
501:
$ref: '#/responses/NotImplemented'
delete:
tags:
- categories
summary: Удаление категории
description: |
###
parameters:
- in: path
name: "{category_id}"
required: true
description: идентификатор категории
type: integer
responses:
200:
description: Успешно
schema:
$ref: "#/definitions/StatusOK"
400:
$ref: '#/responses/BadRequest'
401:
$ref: '#/responses/Unauthorized'
403:
$ref: '#/responses/Forbidden'
501:
$ref: '#/responses/NotImplemented'
'/promos':
get:
tags:
- promos
summary: Список акций/новостей
description: |
Возвращает список всех акций/новостей у клиента
parameters:
- name: page
in: query
description: Порядковый номер страницы
default: 0
type: string
- name: per_page
in: query
description: Количество записей на странице
default: 60
type: string
- in: query
name: "{client_id}"
type: integer
description: ид клиента
required: true
responses:
'200':
description: Возвращает список акций/новостей
schema:
$ref: "#/definitions/Promos"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
post:
tags:
- promos
summary: Создание акции/новости
description: |
parameters:
- in: query
name: "{client_id}"
description: ид клиента
type: integer
required: true
- in: body
name: post
description: json
schema:
$ref: "#/definitions/Promos"
responses:
'200':
description: Возвращает информацию о акции/новости
schema:
$ref: "#/definitions/Promos"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'/promos/{promo_id}':
get:
tags:
- promos
summary: Информация о акции/новости
description: |
Возвращает информацию о акции/новости по id
parameters:
- in: query
name: "{promo_id}"
type: integer
description: ид акции/новости
required: true
responses:
'200':
description: Возвращает информацию о акции/новости
schema:
$ref: "#/definitions/Promos"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
delete:
tags:
- promos
summary: Удаление акции/новости
description: |
parameters:
- in: query
name: "{promo_id}"
type: integer
description: ид акции/новости
required: true
'/promos/{promo_id}/publish':
get:
tags:
- promos
summary: Опубликовать акцию/новость
description: |
Публикация акции/новости
parameters:
- in: query
name: "{promo_id}"
type: integer
description: ид акции/новости
required: true
responses:
'200':
description: Возвращает информацию о акции/новости
schema:
$ref: "#/definitions/Promos"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'/products/{product_id}/publish':
get:
tags:
- products
summary: Опубликовать товар
description: |
Публикация товара
parameters:
- in: path
name: "{product_id}"
type: integer
description: ид товара
required: true
responses:
'200':
description: Возвращает информацию о товаре
schema:
$ref: "#/definitions/Product"
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'/files/promos/{promo_id}':
post:
tags:
- promos
summary: Загрузка медиафайлов акции/новости
description: |
consumes: ["multipart/form-data"]
parameters:
- in: query
name: "{promo_id}"
type: integer
description: ид акции/новости
required: true
- in: formData
name: files
description: Данные файлов
required: true
type: file
responses:
'200':
description: Возврашает информацию о загруженном файле
schema:
type: object
properties:
file_infos:
description:
type: array
items:
$ref: '#/definitions/FileInfo'
local_ids:
description:
type: array
items:
type: string
'400':
$ref: '#/responses/BadRequest'
'401':
$ref: '#/responses/Unauthorized'
'403':
$ref: '#/responses/Forbidden'
'413':
$ref: '#/responses/TooLarge'
'501':
$ref: '#/responses/NotImplemented'
'/products':
post:
tags:
- products
summary: Создание продукции/товара
description: |
parameters:
- in: body
name: post
description: json
schema:
$ref: '#/definitions/Product'
'/files/products/{product_id}':
post:
tags:
- products
summary: Загрузка медиафайлов продукции/товаров
description: |
consumes: ["multipart/form-data"]
parameters:
- in: query
name: "{product_id}"