-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_result.yaml
386 lines (373 loc) · 11 KB
/
3_result.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
openapi: 3.0.0
info:
title: Coffee Shop API
version: 1.0.0
description: API for managing orders and menu in a coffee shop.
contact:
name: CoffeShop API Support
url: https://www.coffeeshop.com/support
email: [email protected]
security:
- basicAuth: [] # Apply basic authentication to all paths
tags:
- name: Orders
description: Operations with orders
- name: Menu
description: Operations with menu
- name: Customers
description: Operations with customers
- name: Recipes
description: Operations with coffee recipes
servers:
- url: https://api.coffeshop.com/v1
description: Production server (uses live data)
- url: https://sandbox-api.coffeshop.com:8443/v1
description: Sandbox server (uses test data)
paths:
/orders:
get:
tags:
- Orders
summary: Retrieve a list of all orders
description: Returns an array of all orders placed in the coffee shop.
operationId: getOrders
responses:
"200":
description: List of all orders
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Order"
"500":
description: Internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/orders/{orderId}:
delete:
tags:
- Orders
summary: Delete an order by its ID
description: Removes an order from the coffee shop system using the provided orderId.
operationId: deleteOrderById
parameters:
- name: orderId
in: path
required: true
schema:
type: integer
example: 123
responses:
"204":
description: Order deleted successfully
"404":
description: Order not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/menu{menuId}:
get:
tags:
- Menu
summary: Get menu by ID
description: Returns the menu of the coffee shop by ID.
operationId: getMenuById
parameters:
- name: menuId
in: path
required: true
schema:
type: integer
example: 123
responses:
"200":
description: Menu of the coffee shop
content:
application/json:
schema:
$ref: "#/components/schemas/MenuItem" # Reference to MenuItem schema
"404":
description: Menu not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error" # Reference to Error schema
put: # UPDATE menu endpoint
tags:
- Menu
summary: Update the menu
description: Updates the entire menu of the coffee shop.
operationId: updateMenu
parameters:
- name: menuId
in: path
required: true
schema:
type: integer
example: 123
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/MenuItem"
responses:
"200":
description: Menu updated successfully
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/MenuItem"
"400":
description: Bad request (e.g., invalid menu data)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/menu:
get:
tags:
- Menu
summary: Get menu
description: Returns the current menu of the coffee shop.
operationId: getMenu
responses:
"200":
description: Menu of the coffee shop
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/MenuItem" # Reference to MenuItem schema
"500":
description: Server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error" # Reference to Error schema
post: # CREATE menu endpoint
tags:
- Menu
summary: Create a new menu item
description: Creates a new menu item in the coffee shop.
operationId: createMenuItem
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/MenuItem"
responses:
"200":
description: Menu updated successfully
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/MenuItem"
"400":
description: Bad request (e.g., invalid menu data)
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
"500":
description: Server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
# Security Schemes
# Basic authentication is used for all endpoints.
components:
securitySchemes:
basicAuth:
type: http
scheme: basic
# Define reusable schemas
schemas:
Order: # Schema for Order object
type: object
properties:
id:
type: integer
description: Order ID
example: 123
customer_name:
type: string
description: Customer name
example: John Doe
minLength: 3
maxLength: 50
items:
type: array
description: Items in the order
items:
$ref: "#/components/schemas/OrderItem"
total_price:
type: number
format: float
description: Total order price
example: 10.50
OrderItem: # Schema for OrderItem object
type: object
properties:
menu_item_id:
type: integer
description: Menu item ID
example: 456
quantity:
type: integer
description: Quantity
example: 2
MenuItem: # Schema for MenuItem object from previous exercises
description: "A schema representing a menu item."
# Indicates that the data should be an object
type: "object"
# Defines the properties of the object
properties:
# An integer that serves as the menu item ID; marked as read-only
id:
type: integer
description: "Menu item ID"
example: 456
# A string representing the name of the item, with a length between 3 and 50 characters
name:
type: string
description: "Name of the item"
minLength: 3
maxLength: 50
example: "Cappuccino"
# An optional string (nullable) describing the item, with a maximum length of 100 characters
description:
type: string
description: "Description of the item"
maxLength: 100
nullable: true
example: "A delicious cappuccino made with our finest espresso."
# A number representing the price of the item, which must be at least 0
price:
type: number
description: "Price of the item"
minimum: 0
example: 3.50
# An optional string indicating the size of the item; must be one of the specified values
size:
type: string
description: "Size of the item"
enum:
- Small
- Medium
- Large
example: "Medium"
# An optional array of strings representing additional items that can be added; allows 0 to 5 items
extraItems:
type: array
description: "Additional items that can be added to the menu item"
items:
type: string
minItems: 0
maxItems: 5
example:
- "Extra Shot"
- "Soy Milk"
# An optional array of objects representing modifiers for the menu item
modifiers:
type: array
description: "Modifiers for the menu item"
items:
type: object
properties:
# The name of the modifier (e.g., "Milk Type", "Syrup Flavor")
name:
type: string
description: "Name of the modifier"
# A list of possible options for this modifier (e.g., ["Whole Milk", "Skim Milk", "Soy Milk"])
options:
type: array
description: "Possible options for the modifier"
items:
type: string
minItems: 1
uniqueItems: true
required:
- name
- options
# An optional object representing promotion details
promotion:
type: object
description: "Details of the promotion applied to the menu item"
# The promotion object must match exactly one of the following schemas
oneOf:
# Discount Promotion schema
- type: object
properties:
type:
type: string
enum:
- discount
description: "Type of promotion"
amount:
type: number
description: "Discount amount"
required:
- type
- amount
# Buy One Get One Free Promotion schema
- type: object
properties:
type:
type: string
enum:
- bogo
description: "Type of promotion"
description:
type: string
description: "Description of the promotion"
required:
- type
- description
# Specifies that the 'id', 'name', and 'price' properties are mandatory
required:
- id
- name
- price
Error: # Schema for Error object
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
description: Error code
example: 500
message:
type: string
description: Error message
example: Internal server error