-
Notifications
You must be signed in to change notification settings - Fork 67
/
tictactoe.yaml
186 lines (186 loc) · 4.92 KB
/
tictactoe.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
openapi: 3.1.0
info:
title: Tic Tac Toe
description: |
This API allows writing down marks on a Tic Tac Toe board
and requesting the state of the board or of individual squares.
version: 1.0.0
tags:
- name: Gameplay
paths:
# Whole board operations
/board:
get:
summary: Get the whole board
description: Retrieves the current state of the board and the winner.
tags:
- Gameplay
operationId: get-board
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/status'
security:
- defaultApiKey: []
- app2AppOauth:
- board:read
# Single square operations
/board/{row}/{column}:
parameters:
- $ref: '#/components/parameters/rowParam'
- $ref: '#/components/parameters/columnParam'
get:
summary: Get a single board square
description: Retrieves the requested square.
tags:
- Gameplay
operationId: get-square
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/mark'
'400':
description: The provided parameters are incorrect
content:
text/html:
schema:
$ref: '#/components/schemas/errorMessage'
example: Illegal coordinates
security:
- bearerHttpAuthentication: []
- user2AppOauth:
- board:read
put:
summary: Set a single board square
description: Places a mark on the board and retrieves the whole board and the winner (if any).
tags:
- Gameplay
operationId: put-square
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/mark'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/status'
'400':
description: The provided parameters are incorrect
content:
text/html:
schema:
$ref: '#/components/schemas/errorMessage'
examples:
illegalCoordinates:
value: Illegal coordinates.
notEmpty:
value: Square is not empty.
invalidMark:
value: Invalid Mark (X or O).
security:
- bearerHttpAuthentication: []
- user2AppOauth:
- board:write
components:
parameters:
rowParam:
description: Board row (vertical coordinate)
name: row
in: path
required: true
schema:
$ref: '#/components/schemas/coordinate'
columnParam:
description: Board column (horizontal coordinate)
name: column
in: path
required: true
schema:
$ref: '#/components/schemas/coordinate'
schemas:
errorMessage:
type: string
maxLength: 256
description: A text message describing an error
coordinate:
type: integer
minimum: 1
maximum: 3
example: 1
mark:
type: string
enum:
- .
- X
- O
description: Possible values for a board square. `.` means empty square.
example: .
board:
type: array
maxItems: 3
minItems: 3
items:
type: array
maxItems: 3
minItems: 3
items:
$ref: '#/components/schemas/mark'
winner:
type: string
enum:
- .
- X
- O
description: Winner of the game. `.` means nobody has won yet.
example: .
status:
type: object
properties:
winner:
$ref: '#/components/schemas/winner'
board:
$ref: '#/components/schemas/board'
securitySchemes:
defaultApiKey:
description: API key provided in console
type: apiKey
name: api-key
in: header
basicHttpAuthentication:
description: Basic HTTP Authentication
type: http
scheme: Basic
bearerHttpAuthentication:
description: Bearer token using a JWT
type: http
scheme: Bearer
bearerFormat: JWT
app2AppOauth:
type: oauth2
flows:
clientCredentials:
tokenUrl: https://learn.openapis.org/oauth/2.0/token
scopes:
# Only reading the board allow with delegated access
board:read: Read the board
user2AppOauth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://learn.openapis.org/oauth/2.0/auth
tokenUrl: https://learn.openapis.org/oauth/2.0/token
scopes:
# Reads and writes permitted via authorization code flow
board:read: Read the board
board:write: Write to the board