-
Notifications
You must be signed in to change notification settings - Fork 1
/
swagger.yml
379 lines (378 loc) · 8.8 KB
/
swagger.yml
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
---
swagger: "2.0"
info:
description: e-Commerce application for XenElectronic
title: XenElectronic
version: 1.0.0
consumes:
- application/xenelectronic.v1+json
produces:
- application/xenelectronic.v1+json
schemes:
- http
paths:
/categories:
get:
description: List available categories
tags:
- categories
operationId: listCategories
responses:
200:
description: list the categories
schema:
type: array
items:
$ref: "#/definitions/Category"
default:
description: generic error response
schema:
$ref: "#/definitions/Error"
/categories/{category_id}/products:
get:
description: List Products of a category
tags:
- categories
operationId: listProductsOfCategory
parameters:
- name: category_id
in: path
required: true
type: integer
format: int64
- name: since
in: query
type: integer
format: int64
default: 0
- name: limit
in: query
type: integer
format: int32
default: 20
responses:
200:
description: list the products of selected category
schema:
type: array
items:
$ref: "#/definitions/Product"
default:
description: generic error response
schema:
$ref: "#/definitions/Error"
/carts:
post:
description: Create new cart
tags:
- carts
operationId: createCart
responses:
200:
description: created new cart
schema:
type: object
required:
- cart_id
properties:
cart_id:
type: string
format: uuid
default:
description: generic error response
schema:
$ref: "#/definitions/Error"
/carts/{cart_id}/products:
parameters:
- name: cart_id
in: path
required: true
type: string
format: uuid
get:
description: List Products in the cart
tags:
- carts
operationId: listProductsInCart
responses:
200:
description: list the products in the cart
schema:
$ref: "#/definitions/CartItems"
default:
description: generic error response
schema:
$ref: "#/definitions/Error"
post:
description: Add a Product into cart
tags:
- carts
operationId: addOneProductIntoCart
parameters:
- name: body
in: body
required: true
schema:
type: object
required:
- product_id
properties:
product_id:
type: integer
format: int64
responses:
200:
description: add one product into the cart
schema:
$ref: "#/definitions/CartItem"
default:
description: generic error response
schema:
$ref: "#/definitions/Error"
/carts/{cart_id}/products/{product_id}:
delete:
description: Delete a Product from cart
tags:
- carts
operationId: removeOneProductFromCart
parameters:
- name: cart_id
in: path
required: true
type: string
format: uuid
- name: product_id
in: path
required: true
type: integer
format: int64
responses:
204:
description: product is deleted from cart
default:
description: error
schema:
$ref: "#/definitions/Error"
/orders:
post:
description: Create order for the cart
tags:
- orders
operationId: checkout
parameters:
- name: body
in: body
required: true
schema:
type: object
required:
- cart_id
- customer_name
- customer_email
- customer_address
properties:
cart_id:
type: string
format: uuid
customer_name:
type: string
minLength: 1
customer_email:
type: string
format: email
minLength: 1
customer_address:
type: string
minLength: 1
responses:
201:
description: Created new order from cart
schema:
$ref: "#/definitions/Order"
default:
description: error
schema:
$ref: "#/definitions/Error"
/orders/{orderId}:
get:
description: View order details
tags:
- orders
operationId: viewOneOrder
parameters:
- name: orderId
in: path
required: true
type: string
format: uuid
responses:
200:
description: Returned one order
schema:
$ref: "#/definitions/Order"
default:
description: error
schema:
$ref: "#/definitions/Error"
definitions:
Category:
type: object
required:
- name
properties:
id:
type: integer
format: int64
readOnly: true
name:
type: string
minLength: 1
Product:
type: object
required:
- name
- description
- price
- category_id
properties:
id:
type: integer
format: int64
readOnly: true
name:
type: string
minLength: 1
description:
type: string
minLength: 1
price:
type: integer
format: int64
photo:
type: string
category_id:
type: integer
format: int64
CartItem:
type: object
required:
- product_id
properties:
id:
type: integer
format: int64
readOnly: true
product_id:
type: integer
format: int64
product:
readOnly: true
$ref: "#/definitions/Product"
CartItems:
type: array
items:
$ref: "#/definitions/CartItem"
example:
- id: 1000
product_id: 500
product:
category_id: 1
id: 500
name: Samsung LED TV
description: Samsung LED TV
price: 5000000
photo: https://samsung.com
- id: 1001
product_id: 550
product:
category_id: 10
id: 550
name: Samsung Galaxy S20 Ultra
description: Samsung Galaxy S20 Ultra
price: 20000000
photo: https://samsung.com
- id: 1002
product_id: 555
product:
category_id: 0
id: 555
name: iPhone 11 Pro
description: iPhone 11 Pro
price: 20000000
photo: https://apple.com
Order:
type: object
required:
- customer_name
- customer_email
- customer_address
properties:
id:
type: string
format: uuid
readOnly: true
customer_name:
type: string
minLength: 1
customer_email:
type: string
format: email
minLength: 1
customer_address:
type: string
minLength: 1
cart_items:
$ref: "#/definitions/CartItems"
payment_amount:
type: integer
format: int64
payment_method:
type: string
payment_account_number:
type: string
example:
id: aaaaaaaa-bbbb-cccc-dddd-eeeedeadbeef
customer_name: John Doe
customer_email: john@example.com
customer_address: 1 Hacker Way
payment_amount: 45000000
payment_method: Bank Transfer
payment_account_number: 232 555 8965
cart_items:
- id: 1000
product_id: 500
product:
category_id: 1
id: 500
name: Samsung LED TV
description: Samsung LED TV
price: 5000000
photo: https://samsung.com
- id: 1001
product_id: 550
product:
category_id: 10
id: 550
name: Samsung Galaxy S20 Ultra
description: Samsung Galaxy S20 Ultra
price: 20000000
photo: https://samsung.com
- id: 1002
product_id: 555
product:
category_id: 0
id: 555
name: iPhone 11 Pro
description: iPhone 11 Pro
price: 20000000
photo: https://apple.com
Error:
type: object
required:
- message
properties:
code:
type: integer
format: int64
message:
type: string