|
| 1 | +openapi: 3.1.0 |
| 2 | +info: |
| 3 | + title: Tic Tac Toe |
| 4 | + description: | |
| 5 | + This API allows writing down marks on a Tic Tac Toe board |
| 6 | + and requesting the state of the board or of individual squares. |
| 7 | + version: 1.0.0 |
| 8 | +tags: |
| 9 | + - name: Gameplay |
| 10 | +paths: |
| 11 | + # Whole board operations |
| 12 | + /board: |
| 13 | + get: |
| 14 | + summary: Get the whole board |
| 15 | + description: Retrieves the current state of the board and the winner. |
| 16 | + tags: |
| 17 | + - Gameplay |
| 18 | + operationId: get-board |
| 19 | + responses: |
| 20 | + "200": |
| 21 | + description: "OK" |
| 22 | + content: |
| 23 | + application/json: |
| 24 | + schema: |
| 25 | + $ref: "#/components/schemas/status" |
| 26 | + |
| 27 | + # Single square operations |
| 28 | + /board/{row}/{column}: |
| 29 | + parameters: |
| 30 | + - $ref: "#/components/parameters/rowParam" |
| 31 | + - $ref: "#/components/parameters/columnParam" |
| 32 | + get: |
| 33 | + summary: Get a single board square |
| 34 | + description: Retrieves the requested square. |
| 35 | + tags: |
| 36 | + - Gameplay |
| 37 | + operationId: get-square |
| 38 | + responses: |
| 39 | + "200": |
| 40 | + description: "OK" |
| 41 | + content: |
| 42 | + application/json: |
| 43 | + schema: |
| 44 | + $ref: "#/components/schemas/mark" |
| 45 | + "400": |
| 46 | + description: The provided parameters are incorrect |
| 47 | + content: |
| 48 | + text/html: |
| 49 | + schema: |
| 50 | + $ref: "#/components/schemas/errorMessage" |
| 51 | + example: "Illegal coordinates" |
| 52 | + put: |
| 53 | + summary: Set a single board square |
| 54 | + description: Places a mark on the board and retrieves the whole board and the winner (if any). |
| 55 | + tags: |
| 56 | + - Gameplay |
| 57 | + operationId: put-square |
| 58 | + requestBody: |
| 59 | + required: true |
| 60 | + content: |
| 61 | + application/json: |
| 62 | + schema: |
| 63 | + $ref: "#/components/schemas/mark" |
| 64 | + responses: |
| 65 | + "200": |
| 66 | + description: "OK" |
| 67 | + content: |
| 68 | + application/json: |
| 69 | + schema: |
| 70 | + $ref: "#/components/schemas/status" |
| 71 | + "400": |
| 72 | + description: The provided parameters are incorrect |
| 73 | + content: |
| 74 | + text/html: |
| 75 | + schema: |
| 76 | + $ref: "#/components/schemas/errorMessage" |
| 77 | + examples: |
| 78 | + illegalCoordinates: |
| 79 | + value: "Illegal coordinates." |
| 80 | + notEmpty: |
| 81 | + value: "Square is not empty." |
| 82 | + invalidMark: |
| 83 | + value: "Invalid Mark (X or O)." |
| 84 | + |
| 85 | +components: |
| 86 | + parameters: |
| 87 | + rowParam: |
| 88 | + description: Board row (vertical coordinate) |
| 89 | + name: row |
| 90 | + in: path |
| 91 | + required: true |
| 92 | + schema: |
| 93 | + $ref: "#/components/schemas/coordinate" |
| 94 | + columnParam: |
| 95 | + description: Board column (horizontal coordinate) |
| 96 | + name: column |
| 97 | + in: path |
| 98 | + required: true |
| 99 | + schema: |
| 100 | + $ref: "#/components/schemas/coordinate" |
| 101 | + schemas: |
| 102 | + errorMessage: |
| 103 | + type: string |
| 104 | + maxLength: 256 |
| 105 | + description: A text message describing an error |
| 106 | + coordinate: |
| 107 | + type: integer |
| 108 | + minimum: 1 |
| 109 | + maximum: 3 |
| 110 | + example: 1 |
| 111 | + mark: |
| 112 | + type: string |
| 113 | + enum: [".", "X", "O"] |
| 114 | + description: Possible values for a board square. `.` means empty square. |
| 115 | + example: "." |
| 116 | + board: |
| 117 | + type: array |
| 118 | + maxItems: 3 |
| 119 | + minItems: 3 |
| 120 | + items: |
| 121 | + type: array |
| 122 | + maxItems: 3 |
| 123 | + minItems: 3 |
| 124 | + items: |
| 125 | + $ref: "#/components/schemas/mark" |
| 126 | + winner: |
| 127 | + type: string |
| 128 | + enum: [".", "X", "O"] |
| 129 | + description: Winner of the game. `.` means nobody has won yet. |
| 130 | + example: "." |
| 131 | + status: |
| 132 | + type: object |
| 133 | + properties: |
| 134 | + winner: |
| 135 | + $ref: "#/components/schemas/winner" |
| 136 | + board: |
| 137 | + $ref: "#/components/schemas/board" |
0 commit comments