OpenAPI

Renders an OpenAPI 3.x specification as a documentation page. Operations are grouped by their first tag.

Syntax

{{% openapi src="spec.json" %}}

The spec file is loaded via resources.Get, so the path is relative to the site’s assets/ directory. JSON and YAML are both supported.

Example

This API allows writing down marks on a Tic Tac Toe board and requesting the state of the board or of individual squares.

v1.0.0

Security

app2AppOauth
oauth2
Basic HTTP Authentication
basicHttpAuthentication
http Basic
Bearer token using a JWT
bearerHttpAuthentication
http Bearer JWT
API key provided in console
defaultApiKey
apiKey in header (api-key)
user2AppOauth
oauth2

Gameplay

Get the whole board

Retrieves the current state of the board and the winner.

Request (requires defaultApiKey, app2AppOauth)

GET /board

Responses

200: OK

Schema: status

PropertyTypeRequiredDescription
boardboardno
winnerwinnernoWinner of the game. . means nobody has won yet.

Get a single board square

Retrieves the requested square.

Request (requires bearerHttpAuthentication, user2AppOauth)

GET /board/{row}/{column}

Path parameters

Parameter nameValueDescriptionAdditional
rowcoordinateBoard row (vertical coordinate)Required, Example: 1
columncoordinateBoard column (horizontal coordinate)Required, Example: 1

Responses

200: OK

Schema: mark

400: The provided parameters are incorrect

text/html
"Illegal coordinates"

Schema: errorMessage

Set a single board square

Places a mark on the board and retrieves the whole board and the winner (if any).

Request (requires bearerHttpAuthentication, user2AppOauth)

PUT /board/{row}/{column}

Path parameters

Parameter nameValueDescriptionAdditional
rowcoordinateBoard row (vertical coordinate)Required, Example: 1
columncoordinateBoard column (horizontal coordinate)Required, Example: 1

Request body (required)

Schema: mark

Responses

200: OK

Schema: status

PropertyTypeRequiredDescription
boardboardno
winnerwinnernoWinner of the game. . means nobody has won yet.

400: The provided parameters are incorrect

illegalCoordinates

text/html
"Illegal coordinates."

invalidMark

text/html
"Invalid Mark (X or O)."

notEmpty

text/html
"Square is not empty."

Schema: errorMessage

Models

board

Type: array of array of mark

coordinate

Type: integer

errorMessage

A text message describing an error

Type: string

mark

Possible values for a board square. . means empty square.

Type: string (enum: ., X, O)

status

PropertyTypeRequiredDescription
boardboardno
winnerwinnernoWinner of the game. . means nobody has won yet.

winner

Winner of the game. . means nobody has won yet.

Type: string (enum: ., X, O)