-
Notifications
You must be signed in to change notification settings - Fork 0
/
users-api-v1.yaml
342 lines (338 loc) · 10.1 KB
/
users-api-v1.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
openapi: 3.0.3
info:
version: 0.1.0
title: Monki Projects' Users API
servers:
- description: Monki Projects' Users API v1 (production)
url: 'https://api.monkiprojects.com/users/v1'
- description: Monki Projects' Users API v1 (staging / development)
url: 'https://staging.api.monkiprojects.com/users/v1'
tags:
- name: users
description: Endpoints related to users.
paths:
'/':
post:
summary: Create User
description: Creates a user.
operationId: createUser
tags:
- users
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User.Create'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/User.Private'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: 'schemas.yaml#/Error'
examples:
InvalidEmail:
value:
error: true
reason: Your email address is invalid.
'401':
$ref: '#/components/responses/UnauthorizedError'
'409':
description: Conflict with other user
content:
application/json:
schema:
$ref: 'schemas.yaml#/Error'
examples:
UsernameNotAvailable:
value:
error: true
reason: Email or username already taken
EmailNotAvailable:
value:
error: true
reason: Email or username already taken
get:
summary: List Users
description: Returns the list of all users.
operationId: listUsers
tags:
- users
parameters:
- $ref: 'parameters.yaml#/PaginatePage'
- $ref: 'parameters.yaml#/PaginatePerPage'
# - $ref: '#/components/parameters/UsersOrder'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/UsersPage'
'/{userId}':
get:
summary: Get User Details
description: Returns details about a particular user.
operationId: getUser
tags:
- users
parameters:
- $ref: '#/components/parameters/UserId'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/User.Public.Full'
'404':
description: Not Found
content:
application/json:
schema:
$ref: 'schemas.yaml#/Error'
examples:
User not found:
value:
error: true
reason: User not found.
'422':
description: Bad user ID
content:
application/json:
schema:
$ref: 'schemas.yaml#/Error'
examples:
Unprocessable Entity:
value:
error: true
reason: Unprocessable Entity
delete:
summary: Delete User
description: Deletes a user.
operationId: deleteUser
tags:
- users
security:
- BearerAuth: []
parameters:
- $ref: '#/components/parameters/UserId'
responses:
'204':
description: Success
'401':
$ref: '#/components/responses/UnauthorizedError'
'422':
description: User ID malformatted
content:
application/json:
schema:
$ref: 'schemas.yaml#/Error'
examples:
Unprocessable Entity:
value:
error: true
reason: Unprocessable Entity
components:
schemas:
# ===== Atoms =====
User.ID:
$ref: 'schemas.yaml#/ID'
User.Username:
description: A username (`@`).
type: string
minLength: 3
maxLength: 32
pattern: '^[a-z0-9._-]{3,32}$'
example: lorem_ipsum
User.DisplayName:
description: A user display name.
type: string
minLength: 3
maxLength: 32
# TODO: Add pattern
example: Lorem Ipsum
User.Country:
description: The country of a user. Will generally show as a flag next to the user's display name.
type: string
# TODO: Add pattern
example: FR
User.Kind:
description: The kind of a user. Either a regular user or a bot.
type: string
enum: [user, bot]
default: user
User.Bio:
description: A user's bio (profile description).
type: string
User.Location:
description: A user's location. It's not formatted nor checked as an existing place, so it could be anything.
type: string
# ===== Molecules =====
User.Experience:
type: object
# TODO: Describe Dictionary
User.SocialUsernames:
type: object
# TODO: Describe Dictionary
# ===== Organisms =====
User.Public.Small:
description: Public informations about a user (only required ones).
type: object
required: [id, username, display_name, kind, updated_at]
properties:
id:
$ref: '#/components/schemas/User.ID'
username:
$ref: '#/components/schemas/User.Username'
display_name:
$ref: '#/components/schemas/User.DisplayName'
avatar:
$ref: 'schemas.yaml#/AvatarSource'
country:
$ref: '#/components/schemas/User.Country'
kind:
$ref: '#/components/schemas/User.Kind'
updated_at:
$ref: 'schemas.yaml#/DateTime'
User.Details:
description: Details about a user.
type: object
required: [experience, social_usernames, created_at]
properties:
bio:
$ref: '#/components/schemas/User.Bio'
location:
$ref: '#/components/schemas/User.Location'
experience:
$ref: '#/components/schemas/User.Experience'
social_usernames:
$ref: '#/components/schemas/User.SocialUsernames'
created_at:
$ref: 'schemas.yaml#/DateTime'
User.Public.Full:
description: Public informations about a user (including all details).
type: object
required: [id, username, display_name, kind, updated_at, details]
properties:
id:
$ref: '#/components/schemas/User.ID'
username:
$ref: '#/components/schemas/User.Username'
display_name:
$ref: '#/components/schemas/User.DisplayName'
avatar:
$ref: 'schemas.yaml#/AvatarSource'
country:
$ref: '#/components/schemas/User.Country'
kind:
$ref: '#/components/schemas/User.Kind'
updated_at:
$ref: 'schemas.yaml#/DateTime'
details:
$ref: '#/components/schemas/User.Details'
User.Private:
description: Private details about a user.
type: object
required: [id, username, display_name, kind, updated_at, details, email]
properties:
id:
$ref: '#/components/schemas/User.ID'
username:
$ref: '#/components/schemas/User.Username'
display_name:
$ref: '#/components/schemas/User.DisplayName'
avatar:
$ref: 'schemas.yaml#/AvatarSource'
country:
$ref: '#/components/schemas/User.Country'
kind:
$ref: '#/components/schemas/User.Kind'
updated_at:
$ref: 'schemas.yaml#/DateTime'
details:
$ref: '#/components/schemas/User.Details'
email:
$ref: 'schemas.yaml#/Email'
User.Create:
description: Informations required to create a user.
type: object
required: [username, display_name, email, password, confirm_password]
properties:
username:
$ref: '#/components/schemas/User.Username'
display_name:
$ref: '#/components/schemas/User.DisplayName'
email:
$ref: 'schemas.yaml#/Email'
password:
$ref: 'schemas.yaml#/Password'
confirm_password:
$ref: 'schemas.yaml#/Password'
example:
username: vapor
display_name: Vapor
email: [email protected]
password: password
confirm_password: password
# ===== Arrays =====
ArrayOfUsers:
description: An array of users (without unnecessary details).
type: array
items:
$ref: '#/components/schemas/User.Public.Small'
# ===== Pagination =====
# === Paginated Arrays ===
UsersPage:
description: A paginated array of users.
type: object
required: [items, metadata]
properties:
items:
$ref: '#/components/schemas/ArrayOfUsers'
metadata:
$ref: 'schemas.yaml#/PaginateMetadata'
# === Ordering ===
# UsersOrder:
# description: >-
# The order of the users in an array:
# * `last_joined`: From the latest created review to the oldest one
# * `first_joined`: From the first created review to the latest one
# type: string
# enum: [last_joined, first_joined]
responses:
UnauthorizedError:
description: Authentication information is missing or is invalid.
content:
application/json:
schema:
$ref: 'schemas.yaml#/Error'
examples:
Unauthorized:
value:
error: true
reason: Unauthorized
parameters:
UserId:
in: path
name: userId
description: A user ID.
required: true
schema:
$ref: 'schemas.yaml#/ID'
# UsersOrder:
# in: query
# name: sort_by
# description: The results order. If not set, results won't be ordered.
# schema:
# $ref: '#/components/schemas/UsersOrder'
securitySchemes:
BearerAuth:
type: http
scheme: bearer