-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathproducts_api.yaml
122 lines (121 loc) · 2.85 KB
/
products_api.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
openapi: 3.0.1
info:
title: Order API
version: '2.0'
servers:
- url: 'http://localhost:3000'
paths:
/products:
get:
summary: GET Products based on type
parameters:
- name: type
in: query
schema:
$ref: '#/components/schemas/ProductType'
examples:
GET_PRODUCTS:
value: 'gadget'
responses:
"200":
description: List of products in the response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Product'
examples:
GET_PRODUCTS:
value:
- id: 1
name: 'XYZ Phone'
type: 'gadget'
inventory: 2
"400":
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponseBody'
post:
summary: POST /products
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ProductDetails'
examples:
CREATE_PRODUCT:
value:
name: iPhone
type: gadget
inventory: 100
responses:
"201":
description: POST /products
content:
application/json:
schema:
$ref: '#/components/schemas/ProductId'
examples:
CREATE_PRODUCT:
value:
id: 1
"400":
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponseBody'
components:
schemas:
ProductDetails:
title: Product Details
type: object
properties:
name:
type: string
type:
$ref: '#/components/schemas/ProductType'
inventory:
type: integer
minimum: 1
maximum: 9999
required:
- name
- type
- inventory
ProductType:
type: string
title: Product Type
enum:
- book
- food
- gadget
- other
ProductId:
title: Product Id
type: object
properties:
id:
type: integer
required:
- id
Product:
title: Product
allOf:
- $ref: '#/components/schemas/ProductId'
- $ref: '#/components/schemas/ProductDetails'
ErrorResponseBody:
type: object
properties:
timestamp:
type: string
format: date-time
status:
type: integer
error:
type: string
path:
type: string