-
Notifications
You must be signed in to change notification settings - Fork 2
/
swagger.yaml
556 lines (548 loc) · 17.4 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
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
---
openapi: 3.0.3
info:
version: '2.1.0'
title: Products API Definition
description: Presents a simple product API for educational and research purposes.
license:
name: MIT License
url: https://opensource.org/licenses/MIT
contact:
name: Bug Tracker
url: https://github.com/sergeyklay/provider-pact-example/issues
servers:
- description: Localhost
url: http://127.0.0.1:5000
tags:
- name: products
description: Products related API.
components:
headers:
LastModifiedHeader:
description: |-
The `Last-Modified` HTTP response header contains a date and time when
the origin server believes the resource was last modified.
schema:
type: string
minLength: 29
maxLength: 29
example: Mon, 04 Feb 2016 23:04:04 GMT
LocationHeader:
description: |-
The `Location` HTTP response header used in responses to refer to the
primary resource created by the request.
schema:
type: string
example: https://api.example.com/v1/products/1
ETagHeader:
description: The `ETag` HTTP response header is an identifier for a specific version of a resource.
schema:
type: string
minLength: 2
maxLength: 44
example: '"92cfceb39d57d914ed8b14d0e37643de0797ae56"'
X-Pagination:
description: The `X-Pagination` HTTP response header contains the pagination information.
schema:
type: object
required:
- total
- total_pages
properties:
total:
description: The total number of items across all pages in the paginated collection.
type: integer
format: int32
minimum: 0
total_pages:
description: The total number of pages in the paginated collection.
type: integer
format: int32
minimum: 0
page:
description: The current page number.
type: integer
format: int32
minimum: 1
first_page:
description: The number of the first page in the paginated collection.
type: integer
format: int32
minimum: 1
last_page:
description: The number of the last page in the paginated collection.
type: integer
format: int32
minimum: 1
previous_page:
description: |-
The number of the previous page in the paginated collection.
May not be present if the current page is the first page.
type: integer
format: int32
minimum: 1
next_page:
description: |-
The number of the next page in the paginated collection.
May not be present if the current page is the last page.
type: integer
format: int32
minimum: 1
examples:
multiple_products:
value:
total: 1021
total_pages: 103
first_page: 1
last_page: 103
page: 11
previous_page: 1
next_page: 3
schemas:
Product:
title: Product
type: object
properties:
id:
type: integer
format: int32
minimum: 1
example: 42
name:
type: string
example: iPhone 9
minLength: 1
maxLength: 64
description:
type: string
example: An Apple mobile which is nothing like apple
maxLength: 512
price:
type: number
minimum: 0
example: 549
discount:
type: number
minimum: 0.0
example: 12.96
rating:
type: number
minimum: 0.0
maximum: 5.0
example: 4.69
stock:
type: integer
format: int32
minimum: 0
example: 856
brand_id:
type: integer
format: int32
minimum: 1
example: 7
category_id:
type: integer
format: int32
minimum: 1
example: 13
created_at:
description: Creation date and time in ISO 8601 full-time format
type: string
format: date-time
minimum: 1
example: '1994-11-05T08:15:30.1023Z'
updated_at:
description: Updating date and time in ISO 8601 full-time format
type: string
format: date-time
minimum: 1
example: '2002-01-31T23:00:00.1234Z'
required:
- id
- name
- price
- discount
- rating
- stock
- brand_id
- category_id
- created_at
- updated_at
BasicErrorModel:
title: Basic Error Model
type: object
required:
- code
- status
properties:
code:
title: The HTTP response code indicating an error.
type: integer
format: int32
status:
title: A textual description of the error status that supplements the HTTP response code.
type: string
NotFoundErrorModel:
title: Not Found Error Model
description: |-
The 404 (Not Found) status code means that the requested resource was
not found on the server and cannot be returned in response to the request.
allOf: # Combines the BasicErrorModel and the inline model
- $ref: '#/components/schemas/BasicErrorModel'
- type: object
properties:
code:
example: 404
status:
example: Not Found
message:
title: A message indicating the reason for the error.
type: string
example: Product not found
PreconditionFailedErrorModel:
title: Precondition Failed Error Model
allOf: # Combines the BasicErrorModel and the inline model
- $ref: '#/components/schemas/BasicErrorModel'
- type: object
properties:
code:
example: 412
status:
example: Precondition Failed
UnprocessableEntityErrorModel:
title: Unprocessable Entity Error Model
description: |-
The 422 status code means the server understands the content
type of the request entity, and the syntax of the request entity
is correct but was unable to process the contained instructions.
allOf: # Combines the BasicErrorModel and the inline model
- $ref: '#/components/schemas/BasicErrorModel'
- type: object
properties:
code:
example: 422
errors:
title: Validation errors in parameters or request body.
type: object
example:
json:
brand_id:
- Missing data for required field.
rating:
- Must be greater than or equal to 0.0 and less than or equal to 5.0.
message:
title: A message indicating the reason for the error.
type: string
example: Product with this name already exists
status:
example: Unprocessable Entity
PreconditionRequiredErrorModel:
title: Precondition Required Error Model
allOf: # Combines the BasicErrorModel and the inline model
- $ref: '#/components/schemas/BasicErrorModel'
- type: object
properties:
code:
example: 428
status:
example: Precondition Required
parameters:
ProductIdParameter:
in: path
name: id
description: Product ID param
schema:
type: integer
format: int32
minimum: 1
required: true
examples:
success:
summary: An ID of an existing product
value: 42
not-found:
summary: An ID of an not existing product
value: 10000000
paths:
/v2/products:
get:
summary: Get list of products
description: Returns a list of all products.
operationId: v2.products.list
tags: [products]
parameters:
- in: query
name: cid
description: Filter by product category.
required: false
schema:
type: string
examples:
category_12:
value: 12
summary: Products from Category ID 12
category_13:
value: 13
summary: Products from Category ID 13
- in: query
name: bid
description: Filter by product brand.
required: false
schema:
type: string
examples:
brand_7:
value: 7
summary: Products for Brand ID 7
brand_9:
value: 9
summary: Products for Brand ID 9
- in: query
name: q
description: Search term.
required: false
schema:
type: string
examples:
term:
value: Samsung
summary: A sample search keyword
responses:
'200':
description: List of products
headers:
ETag:
$ref: '#/components/headers/ETagHeader'
X-Pagination:
$ref: '#/components/headers/X-Pagination'
content:
application/json; charset=utf-8:
schema:
type: array
items:
$ref: '#/components/schemas/Product'
examples:
products_list:
value:
- id: 1
name: iPhone 9
description: An Apple mobile which is nothing like apple
price: 549
discount: 12.96
rating: 4.69
stock: 94
brand_id: 7
category_id: 13
created_at: '1994-11-05T08:15:30.2345Z'
updated_at: '2002-01-31T23:00:00.1234Z'
- id: 6
name: Samsung Galaxy Book
description: Samsung Galaxy Book S (2020) Laptop With Intel Lakefield Chip, 8GB of RAM Launched
price: 1499
discount: 4.15
rating: 4.25
stock: 50
brand_id: 8
category_id: 13
created_at: '2010-05-01T01:14:31.876Z'
updated_at: '2016-12-15T20:16:01.987Z'
summary: A response products list
empty_list:
value: []
summary: En empty response
post:
summary: Create product
description: Create a new product in the database.
operationId: v2.products.create
tags: [products]
requestBody:
required: true
content:
application/json; charset=utf-8:
schema:
type: object
required:
- name
- price
- discount
- rating
- stock
- brand_id
- category_id
properties:
name:
type: string
example: iPhone 9
minLength: 1
maxLength: 64
description:
type: string
example: An Apple mobile which is nothing like apple
maxLength: 512
price:
type: number
minimum: 0
example: 549
discount:
type: number
minimum: 0.0
example: 12.96
rating:
type: number
minimum: 0.0
maximum: 5.0
example: 4.69
stock:
type: integer
format: int32
minimum: 0
example: 856
brand_id:
type: integer
format: int32
minimum: 1
example: 7
category_id:
type: integer
format: int32
minimum: 1
example: 13
responses:
'200':
description: A product
headers:
Location:
$ref: '#/components/headers/LocationHeader'
ETag:
$ref: '#/components/headers/ETagHeader'
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Product'
examples:
iPhone:
value:
id: 1
name: iPhone 9
description: An Apple mobile which is nothing like apple
price: 549
discount: 12.96
rating: 4.69
stock: 94
brand_id: 7
category_id: 11
created_at: '1994-11-05T08:15:30.2345Z'
updated_at: '2002-01-31T23:00:00.1234Z'
Samsung:
value:
id: 6
name: Samsung Galaxy Book
description: Samsung Galaxy Book S (2020) Laptop With Intel Lakefield Chip, 8GB of RAM Launched
price: 1499
discount: 4.15
rating: 4.25
stock: 50
brand_id: 9
category_id: 12
created_at: '2010-05-01T01:14:31.876Z'
updated_at: '2016-12-15T20:16:01.987Z'
'422':
description: Unprocessable Entity
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/UnprocessableEntityErrorModel'
'/v2/products/{id}':
get:
summary: Get single product
description: Returns a single product.
operationId: v2.products.read
tags: [products]
parameters:
- $ref: '#/components/parameters/ProductIdParameter'
responses:
'200':
description: A product
headers:
Last-Modified:
$ref: '#/components/headers/LastModifiedHeader'
ETag:
$ref: '#/components/headers/ETagHeader'
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Product'
examples:
iPhone:
value:
id: 1
name: iPhone 9
description: An Apple mobile which is nothing like apple
price: 549
discount: 12.96
rating: 4.69
stock: 94
brand_id: 7
category_id: 11
created_at: '1994-11-05T08:15:30.2345Z'
updated_at: '2002-01-31T23:00:00.1234Z'
Samsung:
value:
id: 6
name: Samsung Galaxy Book
description: Samsung Galaxy Book S (2020) Laptop With Intel Lakefield Chip, 8GB of RAM Launched
price: 1499
discount: 4.15
rating: 4.25
stock: 50
brand_id: 9
category_id: 12
created_at: '2010-05-01T01:14:31.876Z'
updated_at: '2016-12-15T20:16:01.987Z'
'404':
description: Product not found
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/NotFoundErrorModel'
# This request is required to be conditional
delete:
summary: Delete product
description: Deletes a specific product and returns status code 204 if successful, otherwise - 404.
operationId: v2.products.delete
tags: [ products ]
parameters:
- $ref: '#/components/parameters/ProductIdParameter'
- in: header
name: If-Match
description: An identifier for a specific version of a resource.
required: true
schema:
type: string
minLength: 2
maxLength: 44
examples:
simple:
value: '"92cfceb39d57d914ed8b14d0e37643de0797ae56"'
summary: Example of typical ETag header
responses:
'204':
description: Successful operation
'404':
description: Product not found
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/NotFoundErrorModel'
'412':
description: Precondition Failed
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/PreconditionFailedErrorModel'
'428':
description: Precondition Required
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/PreconditionRequiredErrorModel'