Skip to content

Commit 2e7d506

Browse files
th-271: * correct swagger (#301)
Co-authored-by: Alina Kupchyk <[email protected]>
1 parent b50c2f3 commit 2e7d506

File tree

1 file changed

+74
-17
lines changed

1 file changed

+74
-17
lines changed

backend/src/packages/orders/order.controller.ts

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ import {
9090
* startPoint:
9191
* type: string
9292
* minLength: 1
93-
* example: A
93+
* example: "{ \"lat\": \"-34.655\", \"lng\": \"150.590\" }"
9494
* endPoint:
9595
* type: string
9696
* minLength: 1
97-
* example: B
97+
* example: "{ \"lat\": \"-34.655\", \"lng\": \"150.590\" }"
9898
* status:
9999
* type: string
100100
* enum: [pending, confirmed, cancelled, done]
@@ -109,11 +109,6 @@ import {
109109
* format: number
110110
* minimum: 1
111111
* example: 1
112-
* driverId:
113-
* type: number
114-
* format: number
115-
* minimum: 1
116-
* example: 1
117112
* customerName:
118113
* type: string
119114
* pattern: ^[A-Za-z][\s'A-Za-z-]{0,39}$
@@ -124,6 +119,45 @@ import {
124119
* pattern: ^\+\d{8,19}$
125120
* nullable: true
126121
* example: +123456789
122+
* shift:
123+
* type: object
124+
* properties:
125+
* id:
126+
* type: number
127+
* minimum: 1
128+
* example: 1
129+
* driver:
130+
* type: object
131+
* properties:
132+
* id:
133+
* type: number
134+
* minimum: 1
135+
* example: 1
136+
* firstName:
137+
* $ref: '#/components/schemas/Customer-sign-up-request/properties/firstName'
138+
* lastName:
139+
* $ref: '#/components/schemas/Customer-sign-up-request/properties/lastName'
140+
* phone:
141+
* $ref: '#/components/schemas/Customer-sign-up-request/properties/phone'
142+
* email:
143+
* $ref: '#/components/schemas/Customer-sign-up-request/properties/email'
144+
* driverLicenseNumber:
145+
* type: string
146+
* minLength: 10
147+
* example: AAA 123456
148+
* truck:
149+
* type: object
150+
* properties:
151+
* id:
152+
* type: number
153+
* minimum: 1
154+
* example: 1
155+
* licensePlateNumber:
156+
* type: string
157+
* minLength: 3
158+
* maxLength: 10
159+
* pattern: ^(?!.*\\s)[\\dA-ZЁА-Я-]{3,10}}$
160+
* example: DD1111RR
127161
*
128162
* CreateOrderWithRegisteredUser:
129163
* type: object
@@ -187,6 +221,27 @@ import {
187221
* type: string
188222
* enum:
189223
* - Driver does not exist!
224+
*
225+
* TruckNotExistError:
226+
* allOf:
227+
* - $ref: '#/components/schemas/ErrorType'
228+
* - type: object
229+
* properties:
230+
* message:
231+
* type: string
232+
* enum:
233+
* - Truck does not exist!
234+
*
235+
* ShiftNotOpenError:
236+
* allOf:
237+
* - $ref: '#/components/schemas/ErrorType'
238+
* - type: object
239+
* properties:
240+
* message:
241+
* type: string
242+
* enum:
243+
* - This truck is not inactive, please choose another one!
244+
*
190245
* BusinessNotExistError:
191246
* allOf:
192247
* - $ref: '#/components/schemas/ErrorType'
@@ -338,16 +393,16 @@ class OrderController extends Controller {
338393
* application/json:
339394
* schema:
340395
* $ref: '#/components/schemas/Order'
341-
* 400:
396+
* 404:
342397
* description:
343398
* Order creation error
344399
* content:
345400
* application/json:
346401
* schema:
347402
* oneOf:
348403
* - $ref: '#/components/schemas/DriverNotExistError'
349-
* - $ref: '#/components/schemas/OrderCreationError'
350-
*
404+
* - $ref: '#/components/schemas/TruckNotExistError'
405+
* - $ref: '#/components/schemas/ShiftNotOpenError'
351406
*/
352407
private async create(
353408
options: ApiHandlerOptions<{
@@ -460,7 +515,10 @@ class OrderController extends Controller {
460515
* content:
461516
* plain/text:
462517
* schema:
463-
* $ref: '#/components/schemas/OrderDoesNotExist'
518+
* oneOf:
519+
* - $ref: '#/components/schemas/OrderDoesNotExist'
520+
* - $ref: '#/components/schemas/TruckNotExistError'
521+
* - $ref: '#/components/schemas/DriverNotExistError'
464522
* 401:
465523
* UnauthorizedError:
466524
* description:
@@ -505,10 +563,7 @@ class OrderController extends Controller {
505563
* schema:
506564
* type: array
507565
* items:
508-
* type: object
509-
* properties:
510-
* items:
511-
* $ref: '#/components/schemas/Order'
566+
* $ref: '#/components/schemas/Order'
512567
* 401:
513568
* UnauthorizedError:
514569
* description:
@@ -517,7 +572,7 @@ class OrderController extends Controller {
517572
* plain/text:
518573
* schema:
519574
* $ref: '#/components/schemas/UnauthorizedError'
520-
* 400:
575+
* 404:
521576
* UnauthorizedError:
522577
* description:
523578
* You are not authorized
@@ -569,7 +624,9 @@ class OrderController extends Controller {
569624
* content:
570625
* plain/text:
571626
* schema:
572-
* $ref: '#/components/schemas/OrderDoesNotExist'
627+
* oneOf:
628+
* - $ref: '#/components/schemas/OrderDoesNotExist'
629+
* - $ref: '#/components/schemas/BusinessDoesNotExist'
573630
* 401:
574631
* UnauthorizedError:
575632
* description:

0 commit comments

Comments
 (0)