-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.yaml
153 lines (149 loc) · 4.13 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
openapi: 3.0.0
tags:
- name: "Contact"
description: "CRUD operation on contact"
paths:
/api/contact/:
post:
tags:
- "Contact"
summary: "Create new Contact"
consumes:
- "application/json"
produces:
- "application/json"
requestBody:
content:
application/json:
schema:
type: "object"
properties:
firstName:
type: string
lastName:
type: string
phoneNumber:
type: string
example:
firstName: "Jessica"
lastName: "Smith"
phoneNumber: "09221234322"
responses:
"201":
description: "Contact created successfully."
"400":
description: "BAD REQUEST, all required input are not entered or format of phone number is wrong."
patch:
tags:
- "Contact"
summary: "Edit contact based on fields entered"
description: "Edit firstName or lastName or phoneNumber of contact."
consumes:
- "application/json"
produces:
- "application/json"
requestBody:
content:
application/json:
schema:
type: "object"
properties:
contactID:
type: string
required: true
firstName:
type: string
lastName:
type: string
phoneNumber:
type: string
example:
contactID: "507f191e810c19729de860ea"
firstName: "Jessica"
lastName: "Smith"
phoneNumber: "09221234322"
responses:
"200":
description: "Contact edited successfully"
content:
application/json:
schema:
$ref: "#/components/schemas/Contact"
"400":
description: "All require input are not entered, or contactID is not valid or phoneNumber format is wrong"
"404":
description: "Contact not found!"
get:
tags:
- "Contact"
summary: "Get Contacts based on text entered (Inverted Index)"
description: "text query should be entered to getting the related contact."
parameters:
- in: query
name: text
required: true
schema:
type: string
responses:
"200":
description: "contact fetched successfully"
"400":
description: "text query is not entered"
/api/contact/ordinary/:
get:
tags:
- "Contact"
summary: "Get Contacts based on text entered (Ordinary approach)"
description: "text query should be entered to getting the related contact."
parameters:
- in: query
name: text
required: true
schema:
type: string
responses:
"200":
description: "contact fetched successfully"
"400":
description: "text query is not entered"
/api/contact/{contact_id}:
delete:
tags:
- "Contact"
summary: "Delete contact by its ID"
produces:
- "application/json"
parameters:
- in: path
name: contact_id # Note the name is the same as in the path
required: true
schema:
type: string
example: "507f191e810c19729de860ea"
responses:
"200":
description: "Contact deleted successfully"
"400":
description: "Contact_id is not valid"
"404":
description: "Contact not found!"
components:
schemas:
Contact:
type: "object"
properties:
_id:
type: string
firstName:
type: string
lastName:
type: string
phoneNumber:
type: string
example:
_id: "507f191e810c19729de860ea"
firstName: "Jessica"
lastName: "Smith"
phoneNumber: "09221234321"
createdAt: "2021-09-03T16:27:39.128Z"
updateddAt: "2021-09-03T16:27:39.128Z"