-
Notifications
You must be signed in to change notification settings - Fork 3
/
openapi_example.yml
291 lines (290 loc) · 7.85 KB
/
openapi_example.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
---
openapi: 3.0.0
servers:
- description: JokeAPI server example
url: https://joke_api.example.com/
info:
description: |
This simple Joke API allows you to publish joke and vote for you favourite!
version: 1.1.0
title: Simple Joke API
contact:
email: you@your-company.com
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
tags:
- name: admins
description: Secured Admin-only calls
- name: developers
description: Operations available to regular developers
paths:
"/joke":
get:
tags:
- developers
summary: searches jokes
operationId: searchJokes
description: |
By passing in the appropriate options, you can search for
available jokes
parameters:
- in: query
name: searchString
description: pass an optional search string for looking up inventory
required: false
schema:
type: string
- in: query
name: numberofJokes
description: number of jokes to return
schema:
type: integer
format: int32
minimum: 1
default: 25
- in: query
name: category
description: category of jokes to return
example: knockKnock
required: false
schema:
type: string
enum:
- Word game
- Classic
- School
- KnockKnock
- in: query
name: sortBy
example: thumbsUp
required: false
schema:
type: string
enum:
- thumbsUp
- thumbsDown
- dateAdded
- name: sortOrder
in: query
description: "asc is ascending and sorts from A to Z.
desc is descending and sorts from Z to A."
example: desc
required: false
schema:
type: string
enum:
- asc
- desc
responses:
'200':
description: search results matching criteria
content:
application/json:
schema:
type: array
items:
"$ref": "#/components/schemas/Joke"
examples:
Homework:
$ref: "#/components/examples/Homework"
OpenTheDoor:
$ref: "#/components/examples/OpenTheDoor"
'400':
description: bad input parameter
post:
tags:
- admins
summary: adds a joke
operationId: addJoke
description: Adds a joke to the system
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: "#/components/schemas/JokeWithPunchline"
- $ref: "#/components/schemas/Pun"
type: object
required:
- joke
- punchline
properties:
joke:
type: string
example: Knock Knock. Who's there? Hike. Hike Who?
description: The joke
punchline:
example: I didn't know you liked Japanese poetry.
description: The punchline.
type: string
category:
example: knockKnock
description: category of the joke (allowed categories TBD)
type: string
responses:
'201':
description: item created
content:
application/vnd.json:
schema:
"$ref": "#/components/schemas/Joke"
examples:
SmartDog:
$ref: "#/components/examples/SmartDog"
OpenTheDoor:
$ref: "#/components/examples/OpenTheDoor"
'400':
description: invalid input, object invalid
'409':
description: an existing item already exists
"/thumbsUp/{id}":
post:
tags:
- developers
summary: thumbsup a joke
operationId: Thumbs up to a joke
description: Increases Thumbs up count of a joke by one.
parameters:
- name: id
example: ce0b9fbe-7ad8-11eb-9439-0242ac130002
description: The joke ID for the joke you want to thumbsup.
in: path
required: true
schema:
type: string
responses:
'200':
description: Thumbs Up added
"/thumbsDown/{id}":
post:
tags:
- developers
summary: thumbsdown a joke
operationId: Thumbs down to a joke
description: Increases Thumbs down count of a joke by one.
parameters:
- name: id
example: ce0b9fbe-7ad8-11eb-9439-0242ac130002
description: The joke ID for the joke you want to thumbsdown.
in: path
required: true
schema:
type: string
responses:
'200':
description: Thumbs down added
components:
schemas:
Joke:
type: object
required:
- id
- dateAdded
- joke
- punchline
- thumbsUp
- thumbsDown
- category
properties:
id:
type: string
description: The id of the Joke. Assigned when added.
joke:
type: string
description: The lead-in to the joke.
punchline:
type: string
description: This bit should make you laugh :).
category:
type: string
description: the category of the joke.
enum:
- Word game
- Classic
- School
- KnockKnock
- French humour
thumbsUp:
type: integer
description: Count of upvotes for the joke.
thumbsDown:
type: integer
description: Count of down votes for the joke.
dateAdded:
type: string
format: date-time
JokeWithPunchline:
title: Joke with punchline
type: object
required:
- joke
example:
joke: Knock Knock. Who's there? Hike. Hike Who?
punchline: I didn't know you liked Japanese poetry.
category: KnockKnock
properties:
joke:
type: string
description: The joke
punchline:
description: The punchline.
type: string
category:
description: category of the joke
type: string
enum:
- Word game
- Classic
- School
- KnockKnock
Pun:
type: object
required:
- joke
properties:
joke:
type: string
description: The pun, single sentence
category:
description: category of the joke
type: string
enum:
- Word game
- Classic
- School
- KnockKnock
example:
joke: He had a photographic memory but never developed it.
category: Word game
examples:
Homework:
summary: Well done, son
value:
- id: 42
joke: "Teacher: Did your father help you with your homework?"
punchline: "Student: No, he did it all by himself."
category: School
dateAdded: '2015-07-12T20:12:33.001Z'
thumbsUp: 6
thumbsDown: 2
OpenTheDoor:
summary: Open your mind
value:
- id: 42
joke: What is the name to open the door?
punchline: Open your chakra
category: Classic
dateAdded: '1998-07-12T20:12:33.001Z'
thumbsUp: 4
thumbsDown: 2
SmartDog:
summary: Long way top school
value:
- id: 33
joke: "He used to take his dog to school every day, but he finally had to stop. How come?"
punchline: "The dog got graduated."
category: School
dateAdded: '2017-07-12T20:12:33.001Z'
thumbsUp: 3
thumbsDown: 3