-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
188 lines (188 loc) · 4.89 KB
/
swagger.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
openapi: 3.0.0
servers:
- url: 'http://localhost:8080'
info:
description: 'REST API for product storage management'
version: "1.0.0"
title: 'Products API'
contact:
email: 'yy.lgnd@gmail.com'
paths:
/v1/products/{id}:
get:
tags:
- products
summary: 'Search a product by their identifier'
operationId: searchProduct
description: 'Search a product by their identifier'
parameters:
- in: path
name: id
schema:
type: string
required: true
responses:
'200':
description: 'OK'
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
'404':
description: 'Product does not exist'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
tags:
- products
summary: 'Delete product'
operationId: deleteProduct
description: 'Removes a product from the storage'
parameters:
- in: path
name: id
schema:
type: string
required: true
responses:
'200':
description: 'Success'
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
'400':
description: 'Invalid product sku'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: 'Product does not exist'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/v1/products:
get:
tags:
- products
summary: 'List all products'
operationId: searchProducts
description: 'List all products from the storage'
responses:
'200':
description: 'OK'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Product'
post:
tags:
- products
summary: 'Add a new product'
operationId: addProduct
description: 'Add a new product to the storage'
responses:
'201':
description: 'Created product'
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
'400':
description: 'Invalid product data'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: 'Duplicated record'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
description: 'Product data'
put:
tags:
- products
summary: 'Update product'
operationId: updateProduct
description: 'Update an existing product'
responses:
'200':
description: 'Product updated'
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
'400':
description: 'Invalid product data'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
description: 'Product data'
components:
schemas:
Message:
type: object
properties:
message:
type: string
example: "OK"
Error:
type: object
properties:
error:
type: string
example: "unexpected error"
Product:
type: object
required:
- sku
- name
- brand
- price
- principalImage
properties:
sku:
type: string
example: "FAL-12345678"
pattern: '^FAL-[0-9]+$'
name:
type: string
example: 'Shoes'
brand:
type: string
example: 'Nike'
size:
type: string
example: 'M'
price:
type: number
example: 10.5
principalImage:
type: string
example: 'https://example.com'
otherImages:
type: array
items:
type: string
example:
- 'https://a.example.com'
- 'https://b.example.com'