-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.yaml
More file actions
234 lines (216 loc) · 5.31 KB
/
swagger.yaml
File metadata and controls
234 lines (216 loc) · 5.31 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
swagger: '2.0'
info:
version: 1.0.0
title: E-commerce API
description: API for an e-commerce system
host: 127.0.0.1:5000
schemes:
- http
paths:
/login:
post:
summary: Log in
parameters:
- name: body
in: body
required: true
schema:
type: object
properties:
username:
type: string
password:
type: string
responses:
200:
headers:
Set-Cookie:
type: string
description: Logged in successfully
401:
description: Unauthorized. Invalid credentials
/logout:
post:
summary: Log out
responses:
200:
description: Logout successfully
401:
description: Unauthorized. Invalid credentials
/api/products:
get:
summary: Get a list of products
responses:
200:
description: Returns a list of products
schema:
type: array
items:
$ref: '#/definitions/Product'
404:
description: Not Found. No products available.
/api/products/{product_id}:
get:
summary: Get product details by ID
parameters:
- name: product_id
in: path
type: integer
required: true
description: Product ID to retrieve details
responses:
200:
description: Returns product details
schema:
$ref: '#/definitions/Product'
404:
description: Not Found. Product not available.
/api/products/search:
get:
summary: Search for products
parameters:
- name: q
in: query
type: string
required: true
description: Search query
responses:
200:
description: Returns a list of products matching the search query
schema:
type: array
items:
$ref: '#/definitions/Product'
404:
description: Not Found. No products found for the search query.
/api/products/add:
post:
summary: Add a new product
parameters:
- name: body
in: body
required: true
schema:
$ref: '#/definitions/Product'
responses:
201:
description: Product added successfully
400:
description: Failed to add the product
/api/products/update/{product_id}:
put:
summary: Update a product by ID
parameters:
- name: product_id
in: path
type: integer
required: true
description: Product ID to update
- name: body
in: body
required: true
schema:
$ref: '#/definitions/Product'
responses:
200:
description: Product updated successfully
404:
description: Not Found. Product not available
400:
description: Failed to update the product
/api/products/delete/{product_id}:
delete:
summary: Delete a product by ID
parameters:
- name: product_id
in: path
type: integer
required: true
description: Product ID to delete
responses:
200:
description: Product deleted successfully
404:
description: Not Found. Product not available
/api/cart/add/{product_id}:
post:
summary: Add item to the cart
parameters:
- name: product_id
in: path
type: integer
required: true
description: Product ID to add to the cart
responses:
200:
description: Item added to the cart successfully
400:
description: Failed to add item to the cart
/api/cart/remove/{item_id}:
delete:
summary: Remove item from the cart
parameters:
- name: item_id
in: path
type: integer
required: true
description: Cart item ID to remove from the cart
responses:
200:
description: Item removed from the cart successfully
400:
description: Failed to remove item from the cart
/api/cart:
get:
summary: View the user's cart
responses:
200:
description: Returns the user's cart contents
schema:
type: array
items:
$ref: '#/definitions/CartItem'
401:
description: Unauthorized. User not logged in
/api/cart/checkout:
post:
summary: Checkout and clear the cart
responses:
200:
description: Checkout successful. Cart has been cleared.
401:
description: Unauthorized. User not logged in
definitions:
User:
type: object
properties:
id:
type: integer
username:
type: string
password:
type: string
cart:
type: array
items:
$ref: '#/definitions/CartItem'
Product:
type: object
properties:
id:
type: integer
name:
type: string
price:
type: number
description:
type: string
CartItem:
type: object
properties:
id:
type: integer
user_id:
type: integer
product_id:
type: integer