-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmb-api-spec.yml
278 lines (257 loc) · 6.9 KB
/
mb-api-spec.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
openapi: "3.1.0"
info:
title: Message Board API
version: "1.0"
components:
securitySchemes:
bearerAuth: # arbitrary name for the security scheme
type: http
scheme: bearer
bearerFormat: JWT # optional, arbitrary value for documentation purposes
schemas:
message:
type: object
description: A message
required:
- name
- msgText
properties:
name:
type: string
minLength: 2
maxLength: 15
pattern: "^[A-Za-z]+$"
description: |
Name of User who created
the message.
example: Fred
msgText:
type: string
description: |
A message's text.
minLength: 2
maxLength: 30
example: Hello World!
messageUpdate:
type: object
description: A message
required:
- msgText
properties:
msgText:
type: string
description: |
A message's text.
minLength: 2
maxLength: 30
example: Hello World!
user:
type: object
description: A user
required:
- email
- username
- password
properties:
email:
type: string
format: email
description: |
The email address of the user
example: C0433735@online.camosun.bc.ca
username:
type: string
minLength: 2
maxLength: 15
pattern: "^[A-Za-z]+$"
description: |
The username,
representing the user
example: DaveTheMedic
password:
type: string
format: password
minLength: 8
maxLength: 64
description: |
The user's password.
example: m&yG*r8tE*mPlE_PWD
login:
type: object
description: A user's login info
required:
- username
- password
properties:
username:
type: string
minLength: 2
maxLength: 50
description: |
The username,
representing the user.
Can also be an email address.
example: DaveTheMedic
password:
type: string
maxLength: 64
description: |
The user's password.
example: m&yG*r8tE*mPlE_PWD
userWithId:
allOf:
- $ref: '#/components/schemas/user'
- type: object
required:
- id
properties:
id:
type: number
description: |
A number, representing the unique user
example: 15
responses:
"429TooManyRequests":
description : |
Too many requests. Rate limited.
paths:
/messages:
description: All the messages
get:
summary: List all messages
description: |
List all the messages in the order
they were posted (newest at top).
responses:
"200":
description: All the messages
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/message"
"400":
description: |
Bad Request.
"429":
$ref: '#/components/responses/429TooManyRequests'
post:
summary: Post a new message
description: |
Add a new message to the API
allowing it to be retrieved by future GET
requestBody:
description: Message's data
content:
application/json:
schema:
$ref: "#/components/schemas/message"
security:
- bearerAuth: []
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/message"
"400":
description: |
Bad Request.
The message in the body of the Request is either missing or malformed.
"429":
$ref: '#/components/responses/429TooManyRequests'
/messages/:messageId:
description: Update a message
post:
summary: Change the message to a new one
description: |
Allows you to update a message, so long
as your username matches the message's username.
requestBody:
description: The new message
content:
application/json:
schema:
$ref: "#/components/schemas/messageUpdate"
responses:
"204":
description: No content / Successful update
"400":
description: |
Bad Request.
The message in the body of the Request is either missing or malformed."
"404":
description: |
Not found.
"401":
description: |
Unauthorized.
"403":
description: |
Username or email already exists.
"429":
$ref: '#/components/responses/429TooManyRequests'
/users:
description: All the users
post:
summary: Post a new user
description: |
Add a new user to the API,
allowing you to log in as it in the future.
requestBody:
description: User's data
content:
application/json:
schema:
$ref: "#/components/schemas/user"
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/userWithId"
"400":
description: |
Bad Request.
The message in the body of the Request is either missing or malformed.
"403":
description: |
Username or email already exists.
"429":
$ref: '#/components/responses/429TooManyRequests'
/#:
description: Authenticate a user
post:
summary: Authenticate a user
description: |
Check credentials against
email/password etc.
requestBody:
description: User's login data
content:
application/json:
schema:
$ref: "#/components/schemas/#"
responses:
"200":
description: Successfully logged in
content:
application/json:
schema:
type: object
description: JWT Token
properties:
token:
type: string
"400":
description: |
Bad Request.
The message in the body of the Request is either missing or malformed.
"401":
description: |
Username or password don't match.
"429":
$ref: '#/components/responses/429TooManyRequests'