-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi.yaml
362 lines (362 loc) · 11 KB
/
openapi.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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
openapi: "3.0.0"
info:
title: "Question Service API"
description: "This is the API for the Question Service. It describes the models it employs and data it returns"
version: "1.0.0"
servers:
- url: https://question-service-develop.azurewebsites.net
description: Development server
- url: https://question-service-master.azurewebsites.net
description: Staging server
- url: https://question-service.azurewebsites.net
description: Production server
paths:
/questions/{questionId}:
parameters:
- name: "questionId"
in: "path"
description: "id of question to be found. This will be a kebab-case human readable string"
required: true
schema:
type: string
example: 'a-hard-question'
get:
summary: "returns a question with the matching id"
responses:
'200':
description: the returned question
content:
application/json:
schema:
$ref: '#/components/schemas/Question'
'404':
description: A question with the specified ID was not found
put:
summary: "updates the question with the specific id"
description: Updates the properties of an existing question
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
body:
type: string
sampleAnswer:
type: string
successRate:
type: number
format: float
difficulty:
type: string
enum:
- easy
- medium
- hard
hints:
type: array
items:
type: string
parentTopicTitle:
type: string
questionAnswerOptions:
type: array
items:
type: string
responses:
'204':
description: OK
'400':
description: Bad request
content:
text/plain:
schema:
type: string
examples:
bad-request-body:
summary: Error response if one or more properties are illegal
value: "Bad request: One or more parameters and their types are not present in a question"
update-error:
summary: Error response if one or more properties cannot be updated
value: "Bad request: One or more parameters could not be updated"
'403':
description: Forbidden
delete:
summary: "deletes a question with the matching id"
responses:
'204':
description: the question was successfully deleted
'403':
description: Forbidden
'404':
description: A question with the specified ID was not found
/questions:
post:
summary: "creates a new question"
requestBody:
description: parameters of the question to be created
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Question'
responses:
'201':
description: the created question
content:
application/json:
schema:
$ref: '#/components/schemas/Question'
'400':
description: Bad request
content:
text/plain:
schema:
type: string
examples:
duplicate-question-creation-attempt:
summary: Error response for attempting to duplicate a question
value: "Bad request: Question with id and title already exists"
bad-request-body:
summary: Error response for incorrectly specifying the question to create
value: "Bad request: Bad parameters in request body"
'403':
description: Forbidden
get:
parameters:
- in: query
name: title
schema:
type: string
required: true
- in: query
name: difficulty
schema:
type: array
items:
type: string
enum: [easy, medium, hard]
required: false
summary: "search for a question by string and difficulty level"
responses:
'200':
description: an array of the returned questions (or empty if none found)
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Question'
/topics/{topicId}:
parameters:
- name: "topicId"
in: "path"
description: "id of topic to be found. This will be a kebab-case human readable string"
required: true
schema:
type: string
example: 'a-hard-topic'
get:
summary: "returns a topic with the matching id"
responses:
'200':
description: the returned topic
content:
application/json:
schema:
$ref: '#/components/schemas/Topic'
'404':
description: A topic with the specified ID was not found
put:
summary: "updates the topic with the specific id"
description: Updates the properties of an existing topic
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
body:
type: string
questions:
type: array
items:
type: string
description: questionId
example: "a-kebab-case-question-id"
responses:
'204':
description: OK
'400':
description: Bad request
content:
text/plain:
schema:
type: string
examples:
bad-request-body:
summary: Error response if one or more properties are illegal
value: "Bad request: One or more parameters and their types are not present in a topic"
update-error:
summary: Error response if one or more properties cannot be updated
value: "Bad request: One or more parameters could not be updated"
'403':
description: Forbidden
delete:
summary: "deletes a topic with the matching id"
parameters:
- in: query
required: false
name: delete_children
schema:
type: boolean
responses:
'204':
description: the topic was successfully deleted
'400':
description: Bad request
content:
text/plain:
schema:
type: string
examples:
parent-topic-deletion-attempt:
summary: Error response for attempting to delete a topic that still has child questions
value: "Bad request: Attempted to delete a topic that still has child questions. Use the delete_children: true flag to remove these as well."
'403':
description: Forbidden
'404':
description: A topic with the specified ID was not found
/topics:
post:
summary: "creates a new topic"
requestBody:
description: parameters of the topic to be created
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Topic'
responses:
'201':
description: the created topic
content:
application/json:
schema:
$ref: '#/components/schemas/Topic'
'400':
description: Bad request
content:
text/plain:
schema:
type: string
examples:
duplicate-topic-creation-attempt:
summary: Error response for attempting to duplicate a topic
value: "Bad request: Topic with id and title already exists"
bad-request-body:
summary: Error response for incorrectly specifying the topic to create
value: "Bad request: Bad parameters in request body"
'403':
description: Forbidden
get:
parameters:
- in: query
name: title
schema:
type: string
default: ""
required: false
summary: "search for a topic by title"
responses:
'200':
description: an array of the returned topics (or empty if none found)
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Topic'
/topics/{topicId}/questions:
parameters:
- name: "topicId"
in: "path"
description: "id of topic to be found. This will be a kebab-case human readable string"
required: true
schema:
type: string
example: 'a-hard-topic'
get:
summary: "returns full details for all questions contained in a topic"
parameters:
- in: query
name: title
schema:
type: string
default: ""
required: false
- in: query
name: difficulty
schema:
type: array
items:
type: string
enum: [easy, medium, hard]
responses:
'200':
description: the returned questions
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Question'
'404':
description: A topic with the specified ID was not found
components:
schemas:
Question:
type: object
properties:
id:
type: string
title:
type: string
body:
type: string
sampleAnswer:
type: string
successRate:
type: number
format: float
difficulty:
type: string
enum:
- easy
- medium
- hard
hints:
type: array
items:
type: string
parentTopicTitle:
type: string
questionAnswerOptions:
type: array
items:
type: string
Topic:
type: object
properties:
id:
type: string
title:
type: string
body:
type: string
questions:
type: array
items:
$ref: '#/components/schemas/Question'