-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.yml
348 lines (348 loc) · 9.41 KB
/
swagger.yml
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
swagger: "2.0"
info:
description: "Small project management API built for an interview tech challenge."
version: "1.0.0"
title: "airtouch challenge"
contact:
email: "[email protected]"
host: "localhost:3000"
schemes:
- http
securityDefinitions:
Bearer:
type: apiKey
name: Authorization
in: header
basePath: "/"
tags:
- name: "Authentication"
description: "Authentication endpoints"
- name: "User"
description: "User endpoints"
- name: "Project"
description: "Project endpoints"
- name: "Role"
description: "Role endpoints"
paths:
/register:
post:
tags:
- "Authentication"
summary: "Create an account"
description: ""
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "User object to be registered on the board."
required: true
schema:
$ref: "#/definitions/RegistrationRequest"
responses:
201:
description: "Registered successfully"
headers:
Location:
type: string
description: "The URL of the newly created user"
schema:
$ref: "#/definitions/AuthenticationResponse"
400:
description: "Your request body was malformed"
403:
description: "Username already taken"
500:
description: "An unknown error occured while processing your request"
/login:
post:
tags:
- "Authentication"
summary: "Login into your account"
description: "Authenticate to your account using your username and password. You will receive a JWT that you can use in your future requests to prove your identity."
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Your username and password"
required: true
schema:
$ref: "#/definitions/LoginRequest"
responses:
200:
description: "Login successful, JWT received"
schema:
$ref: "#/definitions/LoginResponse"
400:
description: "Your request body was malformed"
500:
description: "An unknown error occured while processing your request"
/users/me:
get:
tags:
- "User"
summary: "Retrieves data about you"
description: "Get all profile data about you."
produces:
- "application/json"
responses:
200:
description: "Request successful, User received"
schema:
$ref: "#/definitions/User"
401:
description: "You do not have the required privileges to view this resource"
400:
description: "Your request body was malformed"
500:
description: "An unknown error occured while processing your request"
security:
- Bearer: []
/users/{id}:
get:
tags:
- "User"
summary: "[Admin] Retrieves data about a user"
description: "Get all profile data about a user."
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "The ID of the user you want to see info about"
required: true
type: "string"
format: "ObjectID"
responses:
200:
description: "Request successful, User received"
schema:
$ref: "#/definitions/User"
400:
description: "Your request body was malformed"
401:
description: "You do not have the required privileges to view this resource"
404:
description: "User does not exist"
500:
description: "An unknown error occured while processing your request"
security:
- Bearer: []
/users:
get:
tags:
- "User"
summary: "[Admin] Retrieves all registered users"
description: "Get profile data about all registered user."
produces:
- "application/json"
responses:
200:
description: "Request successful, User received"
schema:
$ref: "#/definitions/User"
400:
description: "Your request body was malformed"
401:
description: "You do not have the required privileges to view this resource"
404:
description: "User does not exist"
500:
description: "An unknown error occured while processing your request"
security:
- Bearer: []
/projects:
get:
tags:
- "Project"
summary: "Retrieves all existing projects"
produces:
- "application/json"
responses:
200:
description: "Request successful, projects received"
schema:
type: array
items:
$ref: '#/definitions/Project'
400:
description: "Your request body was malformed"
404:
description: "No projects exist"
500:
description: "An unknown error occured while processing your request"
post:
tags:
- "Project"
summary: "[Admin] Create a new project"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "User object to be registered on the board."
required: true
schema:
$ref: "#/definitions/Project"
responses:
201:
description: "Request successful, project created"
401:
description: "You do not have the required privileges to view this resource"
400:
description: "Your request body was malformed"
500:
description: "An unknown error occured while processing your request"
security:
- Bearer: []
/roles:
post:
tags:
- "Role"
summary: "[Admin] Create a new authorization role"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Role object"
required: true
schema:
$ref: "#/definitions/Role"
responses:
201:
description: "Request successful, project created"
headers:
Location:
type: string
description: "The URL of the newly created role"
400:
description: "Your request body was malformed"
401:
description: "You do not have the required privileges to view this resource"
500:
description: "An unknown error occured while processing your request"
security:
- Bearer: []
/roles/{id}:
get:
tags:
- "Role"
summary: "[Admin] Retrieves an authorization role"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "The ID of the user you want to see info about"
required: true
type: "string"
format: "ObjectID"
responses:
200:
description: "Request successful, role updated"
schema:
$ref: "#/definitions/Role"
400:
description: "Your request body was malformed"
401:
description: "You do not have the required privileges to view this resource"
500:
description: "An unknown error occured while processing your request"
security:
- Bearer: []
put:
tags:
- "Role"
summary: "[Admin] Modify an existing authorization role"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "The ID of the user for which you want to modify role."
required: true
type: "string"
format: "ObjectID"
- in: "body"
name: "body"
description: "Role object"
required: true
schema:
$ref: "#/definitions/Role"
responses:
200:
description: "Request successful, role updated"
schema:
$ref: "#/definitions/Role"
400:
description: "Your request body was malformed"
401:
description: "You do not have the required privileges to view this resource"
500:
description: "An unknown error occured while processing your request"
security:
- Bearer: []
definitions:
User:
type: "object"
properties:
_id:
type: string
username:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string
Project:
type: "object"
properties:
_id:
type: string
name:
type: string
company:
type: string
Role:
type: "object"
properties:
_id:
type: string
userId:
type: string
role:
type: number
enum: [0, 1]
LoginRequest:
type: "object"
properties:
username:
type: string
password:
type: string
AuthenticationResponse:
type: "object"
properties:
token:
type: string
RegistrationRequest:
type: "object"
properties:
username:
type: string
password:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string