-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathopenapi.yaml
More file actions
584 lines (581 loc) · 16.3 KB
/
openapi.yaml
File metadata and controls
584 lines (581 loc) · 16.3 KB
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
openapi: 3.0.3
info:
title: Burger API
description: API for managing burger orders and related operations
version: 1.0.0
servers:
- url: <BURGER_API_HOST>/api
description: Burger API server
paths:
/:
get:
tags:
- utility
summary: Get server status
description: Returns basic server status and order statistics.
operationId: getStatus
responses:
'200':
description: Server status and order statistics
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: up
activeOrders:
type: integer
example: 2
totalOrders:
type: integer
example: 10
registeredUsers:
type: integer
description: Number of registered users in the system
example: 5
timestamp:
type: string
format: date-time
example: '2025-05-06T12:00:00Z'
required:
- status
- activeOrders
- totalOrders
- registeredUsers
- timestamp
/openapi:
get:
tags:
- utility
summary: Get OpenAPI specification
description: |
Returns the OpenAPI specification, by default in YAML format.
To request JSON format, use the query parameter `?format=json` or set the `Accept: application/json` header.
operationId: getOpenApiSpec
responses:
'200':
description: OpenAPI specification in YAML or JSON format
content:
text/yaml:
schema:
type: string
example: |
openapi: 3.0.3
info:
title: Burger API
version: 1.0.0
...
/orders:
get:
tags:
- orders
summary: Get all orders
description: Returns a list of all orders in the system
operationId: getOrders
parameters:
- name: userId
in: query
description: Filter orders by userId
required: false
schema:
type: string
- name: status
in: query
description: Filter orders by status (comma-separated for multiple, e.g. pending,ready)
required: false
schema:
type: string
- name: last
in: query
description: Filter orders created in the last X minutes/hours (e.g. 60m, 2h)
required: false
schema:
type: string
responses:
'200':
description: List of orders
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/OrderResponse'
post:
tags:
- orders
summary: Create a new order
description: |
Places a new order with burgers (requires userId).
French fries are included as a side for every burger order.
Limitations:
- Maximum 5 active orders per user
- Maximum 50 burgers total per order
operationId: createOrder
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateOrderRequest'
responses:
'201':
description: Order created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/OrderResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: User is not registered
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'429':
description: Too many active orders for this user
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/orders/{orderId}:
get:
tags:
- orders
summary: Get order by ID
description: Retrieves an order by its ID
operationId: getOrderById
parameters:
- name: orderId
in: path
description: ID of the order
required: true
schema:
type: string
responses:
'200':
description: Order details found
content:
application/json:
schema:
$ref: '#/components/schemas/OrderResponse'
'404':
description: Order not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
delete:
tags:
- orders
summary: Cancel an order
description: |
Cancels an order if it has not yet been started (status must be 'pending').
The `userId` query parameter is required (e.g., `?userId=user123`).
If `userId` is missing or does not match the `userId` of the order, the request will be rejected.
operationId: cancelOrder
parameters:
- name: orderId
in: path
description: ID of the order
required: true
schema:
type: string
- name: userId
in: query
description: ID of the user requesting the cancellation (required)
required: true
schema:
type: string
responses:
'200':
description: Order cancelled successfully
content:
application/json:
schema:
$ref: '#/components/schemas/OrderResponse'
'403':
description: User is not authorized to cancel this order
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Order not found or cannot be cancelled (not in pending status)
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'400':
description: Order ID or user ID is missing
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/burgers:
get:
tags:
- burgers
summary: Get all burgers
description: Returns a list of all burgers
operationId: getBurgers
responses:
'200':
description: List of burgers
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/MenuItem'
/burgers/{id}:
get:
tags:
- burgers
summary: Get burger by ID
description: Retrieves a specific burger by its ID
operationId: getBurgerById
parameters:
- name: id
in: path
description: ID of the burger
required: true
schema:
type: string
responses:
'200':
description: Burger details found
content:
application/json:
schema:
$ref: '#/components/schemas/MenuItem'
'404':
description: Burger not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/toppings:
get:
tags:
- toppings
summary: Get all toppings
description: Returns a list of all toppings
operationId: getToppings
parameters:
- name: category
in: query
description: Filter toppings by category
required: false
schema:
type: string
responses:
'200':
description: List of toppings
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/MenuItem'
/toppings/categories:
get:
tags:
- toppings
summary: Get all topping categories
description: Returns a list of all topping categories
operationId: getToppingCategories
responses:
'200':
description: List of topping categories
content:
application/json:
schema:
type: array
items:
type: string
/toppings/{id}:
get:
tags:
- toppings
summary: Get topping by ID
description: Retrieves a specific topping by its ID
operationId: getToppingById
parameters:
- name: id
in: path
description: ID of the topping
required: true
schema:
type: string
responses:
'200':
description: Topping details found
content:
application/json:
schema:
$ref: '#/components/schemas/MenuItem'
'404':
description: Topping not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/images/{filepath}:
get:
tags:
- images
summary: Get an image
description: Retrieves an image from Azure Blob Storage
operationId: getImage
parameters:
- name: filepath
in: path
description: Path to the image file in Azure Blob Storage
required: true
schema:
type: string
responses:
'200':
description: Image found and returned
content:
image/jpeg:
schema:
type: string
format: binary
image/png:
schema:
type: string
format: binary
image/gif:
schema:
type: string
format: binary
image/webp:
schema:
type: string
format: binary
image/svg+xml:
schema:
type: string
format: binary
'400':
description: Invalid request - image path is required
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Image not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
MenuCategory:
type: string
enum:
- burger
- drink
- side
- topping
MenuItem:
type: object
properties:
id:
type: string
example: 'burger-1'
category:
$ref: '#/components/schemas/MenuCategory'
name:
type: string
example: 'Margherita Burger'
description:
type: string
example: 'Classic burger with tomato sauce and mozzarella'
price:
type: number
format: float
example: 12.99
required:
- id
- category
- name
- description
- price
OrderStatus:
type: string
enum:
- pending
- in-preparation
- ready
- completed
- cancelled
description: >
- pending: Order has been created but not yet started
- in-preparation: Order is being prepared
- ready: Order is ready for pickup
- completed: Order has been picked up
- cancelled: Order has been cancelled
OrderItem:
type: object
properties:
burgerId:
type: string
example: 'burger-1'
quantity:
type: integer
minimum: 1
example: 1
description: Must be a positive integer (greater than 0). Orders with zero or negative quantity will be rejected with a 400 error.
extraToppingIds:
type: array
items:
type: string
description: Optional list of extra topping IDs to add to the burger
example: ['topping-1', 'topping-2']
required:
- burgerId
- quantity
Order:
type: object
properties:
id:
type: string
example: '1618057820123'
userId:
type: string
example: 'user123'
createdAt:
type: string
format: date-time
description: ISO date string of when the order was created
example: '2025-04-10T14:30:00Z'
items:
type: array
items:
$ref: '#/components/schemas/OrderItem'
estimatedCompletionAt:
type: string
format: date-time
description: ISO date string for estimated completion time
example: '2025-04-10T15:00:00Z'
completedAt:
type: string
format: date-time
description: ISO date string for when the order was completed (undefined until completed)
example: '2025-04-10T15:10:00Z'
readyAt:
type: string
format: date-time
description: ISO date string for when the order was ready (undefined until ready)
example: '2025-04-10T15:05:00Z'
nickname:
type: string
description: Optional nickname for the order
example: 'John'
totalPrice:
type: number
format: float
example: 22.98
status:
$ref: '#/components/schemas/OrderStatus'
required:
- id
- userId
- createdAt
- items
- estimatedCompletionAt
- totalPrice
- status
OrderResponse:
type: object
description: Order object returned by the API (userId is omitted for privacy)
properties:
id:
type: string
createdAt:
type: string
format: date-time
items:
type: array
items:
$ref: '#/components/schemas/OrderItem'
estimatedCompletionAt:
type: string
format: date-time
completedAt:
type: string
format: date-time
description: ISO date string for when the order was completed (undefined until completed)
nickname:
type: string
description: Optional nickname for the order
totalPrice:
type: number
format: float
status:
$ref: '#/components/schemas/OrderStatus'
required:
- id
- createdAt
- items
- estimatedCompletionAt
- totalPrice
- status
CreateOrderRequest:
type: object
properties:
userId:
type: string
example: 'user123'
nickname:
type: string
description: Optional nickname for the order (only first 10 chars displayed)
example: 'John'
items:
type: array
description: List of burger items (maximum 50 burgers total across all items)
items:
type: object
properties:
burgerId:
type: string
example: 'burger-1'
quantity:
type: integer
minimum: 1
example: 1
extraToppingIds:
type: array
items:
type: string
description: Optional list of extra topping IDs to add to the burger
example: ['topping-1', 'topping-2']
required:
- burgerId
- quantity
required:
- userId
- items
ErrorResponse:
type: object
properties:
error:
type: string
example: 'Order must contain at least one item'
required:
- error