1
+ {
2
+ "openapi" : " 3.1.0" ,
3
+ "info" : {
4
+ "title" : " Tic Tac Toe" ,
5
+ "description" : " This API allows writing down marks on a Tic Tac Toe board\n and requesting the state of the board or of individual squares.\n " ,
6
+ "version" : " 1.0.0"
7
+ },
8
+ "tags" : [
9
+ {
10
+ "name" : " Gameplay"
11
+ }
12
+ ],
13
+ "paths" : {
14
+ "/board" : {
15
+ "get" : {
16
+ "summary" : " Get the whole board" ,
17
+ "description" : " Retrieves the current state of the board and the winner." ,
18
+ "tags" : [
19
+ " Gameplay"
20
+ ],
21
+ "operationId" : " get-board" ,
22
+ "responses" : {
23
+ "200" : {
24
+ "description" : " OK" ,
25
+ "content" : {
26
+ "application/json" : {
27
+ "schema" : {
28
+ "$ref" : " #/components/schemas/status"
29
+ }
30
+ }
31
+ }
32
+ }
33
+ },
34
+ "security" : [
35
+ {
36
+ "apiKey" : []
37
+ },
38
+ {
39
+ "app2AppOauth" : [
40
+ " board:read"
41
+ ]
42
+ }
43
+ ]
44
+ }
45
+ },
46
+ "/board/{row}/{column}" : {
47
+ "parameters" : [
48
+ {
49
+ "$ref" : " #/components/parameters/rowParam"
50
+ },
51
+ {
52
+ "$ref" : " #/components/parameters/columnParam"
53
+ }
54
+ ],
55
+ "get" : {
56
+ "summary" : " Get a single board square" ,
57
+ "description" : " Retrieves the requested square." ,
58
+ "tags" : [
59
+ " Gameplay"
60
+ ],
61
+ "operationId" : " get-square" ,
62
+ "responses" : {
63
+ "200" : {
64
+ "description" : " OK" ,
65
+ "content" : {
66
+ "application/json" : {
67
+ "schema" : {
68
+ "$ref" : " #/components/schemas/mark"
69
+ }
70
+ }
71
+ }
72
+ },
73
+ "400" : {
74
+ "description" : " The provided parameters are incorrect" ,
75
+ "content" : {
76
+ "text/html" : {
77
+ "schema" : {
78
+ "$ref" : " #/components/schemas/errorMessage"
79
+ },
80
+ "example" : " Illegal coordinates"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ "security" : [
86
+ {
87
+ "bearerHttpAuthentication" : []
88
+ },
89
+ {
90
+ "user2AppOauth" : [
91
+ " board:read"
92
+ ]
93
+ }
94
+ ]
95
+ },
96
+ "put" : {
97
+ "summary" : " Set a single board square" ,
98
+ "description" : " Places a mark on the board and retrieves the whole board and the winner (if any)." ,
99
+ "tags" : [
100
+ " Gameplay"
101
+ ],
102
+ "operationId" : " put-square" ,
103
+ "requestBody" : {
104
+ "required" : true ,
105
+ "content" : {
106
+ "application/json" : {
107
+ "schema" : {
108
+ "$ref" : " #/components/schemas/mark"
109
+ }
110
+ }
111
+ }
112
+ },
113
+ "responses" : {
114
+ "200" : {
115
+ "description" : " OK" ,
116
+ "content" : {
117
+ "application/json" : {
118
+ "schema" : {
119
+ "$ref" : " #/components/schemas/status"
120
+ }
121
+ }
122
+ }
123
+ },
124
+ "400" : {
125
+ "description" : " The provided parameters are incorrect" ,
126
+ "content" : {
127
+ "text/html" : {
128
+ "schema" : {
129
+ "$ref" : " #/components/schemas/errorMessage"
130
+ },
131
+ "examples" : {
132
+ "illegalCoordinates" : {
133
+ "value" : " Illegal coordinates."
134
+ },
135
+ "notEmpty" : {
136
+ "value" : " Square is not empty."
137
+ },
138
+ "invalidMark" : {
139
+ "value" : " Invalid Mark (X or O)."
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ },
146
+ "security" : [
147
+ {
148
+ "bearerHttpAuthentication" : []
149
+ },
150
+ {
151
+ "user2AppOauth" : [
152
+ " board:write"
153
+ ]
154
+ }
155
+ ]
156
+ }
157
+ }
158
+ },
159
+ "components" : {
160
+ "parameters" : {
161
+ "rowParam" : {
162
+ "description" : " Board row (vertical coordinate)" ,
163
+ "name" : " row" ,
164
+ "in" : " path" ,
165
+ "required" : true ,
166
+ "schema" : {
167
+ "$ref" : " #/components/schemas/coordinate"
168
+ }
169
+ },
170
+ "columnParam" : {
171
+ "description" : " Board column (horizontal coordinate)" ,
172
+ "name" : " column" ,
173
+ "in" : " path" ,
174
+ "required" : true ,
175
+ "schema" : {
176
+ "$ref" : " #/components/schemas/coordinate"
177
+ }
178
+ }
179
+ },
180
+ "schemas" : {
181
+ "errorMessage" : {
182
+ "type" : " string" ,
183
+ "maxLength" : 256 ,
184
+ "description" : " A text message describing an error"
185
+ },
186
+ "coordinate" : {
187
+ "type" : " integer" ,
188
+ "minimum" : 1 ,
189
+ "maximum" : 3 ,
190
+ "example" : 1
191
+ },
192
+ "mark" : {
193
+ "type" : " string" ,
194
+ "enum" : [
195
+ " ." ,
196
+ " X" ,
197
+ " O"
198
+ ],
199
+ "description" : " Possible values for a board square. `.` means empty square." ,
200
+ "example" : " ."
201
+ },
202
+ "board" : {
203
+ "type" : " array" ,
204
+ "maxItems" : 3 ,
205
+ "minItems" : 3 ,
206
+ "items" : {
207
+ "type" : " array" ,
208
+ "maxItems" : 3 ,
209
+ "minItems" : 3 ,
210
+ "items" : {
211
+ "$ref" : " #/components/schemas/mark"
212
+ }
213
+ }
214
+ },
215
+ "winner" : {
216
+ "type" : " string" ,
217
+ "enum" : [
218
+ " ." ,
219
+ " X" ,
220
+ " O"
221
+ ],
222
+ "description" : " Winner of the game. `.` means nobody has won yet." ,
223
+ "example" : " ."
224
+ },
225
+ "status" : {
226
+ "type" : " object" ,
227
+ "properties" : {
228
+ "winner" : {
229
+ "$ref" : " #/components/schemas/winner"
230
+ },
231
+ "board" : {
232
+ "$ref" : " #/components/schemas/board"
233
+ }
234
+ }
235
+ }
236
+ },
237
+ "securitySchemes" : {
238
+ "defaultApiKey" : {
239
+ "description" : " API key provided in console" ,
240
+ "type" : " apiKey" ,
241
+ "name" : " api-key" ,
242
+ "in" : " header"
243
+ },
244
+ "basicHttpAuthentication" : {
245
+ "description" : " Basic HTTP Authentication" ,
246
+ "type" : " http" ,
247
+ "scheme" : " Basic"
248
+ },
249
+ "bearerHttpAuthentication" : {
250
+ "description" : " Bearer token using a JWT" ,
251
+ "type" : " http" ,
252
+ "scheme" : " Bearer" ,
253
+ "bearerFormat" : " JWT"
254
+ },
255
+ "app2AppOauth" : {
256
+ "type" : " oauth2" ,
257
+ "flows" : {
258
+ "clientCredentials" : {
259
+ "tokenUrl" : " https://learn.openapis.org/oauth/2.0/token" ,
260
+ "scopes" : {
261
+ "board:read" : " Read the board"
262
+ }
263
+ }
264
+ }
265
+ },
266
+ "user2AppOauth" : {
267
+ "type" : " oauth2" ,
268
+ "flows" : {
269
+ "authorizationCode" : {
270
+ "authorizationUrl" : " https://learn.openapis.org/oauth/2.0/auth" ,
271
+ "tokenUrl" : " https://learn.openapis.org/oauth/2.0/token" ,
272
+ "scopes" : {
273
+ "board:read" : " Read the board" ,
274
+ "board:write" : " Write to the board"
275
+ }
276
+ }
277
+ }
278
+ }
279
+ }
280
+ }
281
+ }
0 commit comments