tictactoe.yaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. security:
  27. apiKey: []
  28. app2AppOauth:
  29. - board:read
  30. # Single square operations
  31. /board/{row}/{column}:
  32. parameters:
  33. - $ref: "#/components/parameters/rowParam"
  34. - $ref: "#/components/parameters/columnParam"
  35. get:
  36. summary: Get a single board square
  37. description: Retrieves the requested square.
  38. tags:
  39. - Gameplay
  40. operationId: get-square
  41. responses:
  42. "200":
  43. description: "OK"
  44. content:
  45. application/json:
  46. schema:
  47. $ref: "#/components/schemas/mark"
  48. "400":
  49. description: The provided parameters are incorrect
  50. content:
  51. text/html:
  52. schema:
  53. $ref: "#/components/schemas/errorMessage"
  54. example: "Illegal coordinates"
  55. security:
  56. bearerHttpAuthentication: []
  57. user2AppOauth:
  58. - board:read
  59. put:
  60. summary: Set a single board square
  61. description: Places a mark on the board and retrieves the whole board and the winner (if any).
  62. tags:
  63. - Gameplay
  64. operationId: put-square
  65. requestBody:
  66. required: true
  67. content:
  68. application/json:
  69. schema:
  70. $ref: "#/components/schemas/mark"
  71. responses:
  72. "200":
  73. description: "OK"
  74. content:
  75. application/json:
  76. schema:
  77. $ref: "#/components/schemas/status"
  78. "400":
  79. description: The provided parameters are incorrect
  80. content:
  81. text/html:
  82. schema:
  83. $ref: "#/components/schemas/errorMessage"
  84. examples:
  85. illegalCoordinates:
  86. value: "Illegal coordinates."
  87. notEmpty:
  88. value: "Square is not empty."
  89. invalidMark:
  90. value: "Invalid Mark (X or O)."
  91. security:
  92. bearerHttpAuthentication: []
  93. user2AppOauth:
  94. - board:write
  95. components:
  96. parameters:
  97. rowParam:
  98. description: Board row (vertical coordinate)
  99. name: row
  100. in: path
  101. required: true
  102. schema:
  103. $ref: "#/components/schemas/coordinate"
  104. columnParam:
  105. description: Board column (horizontal coordinate)
  106. name: column
  107. in: path
  108. required: true
  109. schema:
  110. $ref: "#/components/schemas/coordinate"
  111. schemas:
  112. errorMessage:
  113. type: string
  114. maxLength: 256
  115. description: A text message describing an error
  116. coordinate:
  117. type: integer
  118. minimum: 1
  119. maximum: 3
  120. example: 1
  121. mark:
  122. type: string
  123. enum: [".", "X", "O"]
  124. description: Possible values for a board square. `.` means empty square.
  125. example: "."
  126. board:
  127. type: array
  128. maxItems: 3
  129. minItems: 3
  130. items:
  131. type: array
  132. maxItems: 3
  133. minItems: 3
  134. items:
  135. $ref: "#/components/schemas/mark"
  136. winner:
  137. type: string
  138. enum: [".", "X", "O"]
  139. description: Winner of the game. `.` means nobody has won yet.
  140. example: "."
  141. status:
  142. type: object
  143. properties:
  144. winner:
  145. $ref: "#/components/schemas/winner"
  146. board:
  147. $ref: "#/components/schemas/board"
  148. securitySchemes:
  149. defaultApiKey:
  150. description: API key provided in console
  151. type: apiKey
  152. name: api-key
  153. in: header
  154. basicHttpAuthentication:
  155. description: Basic HTTP Authentication
  156. type: http
  157. scheme: Basic
  158. bearerHttpAuthentication:
  159. description: Bearer token using a JWT
  160. type: http
  161. scheme: Bearer
  162. bearerFormat: JWT
  163. app2AppOauth:
  164. type: oauth2
  165. flows:
  166. clientCredentials:
  167. tokenUrl: https://learn.openapis.org/oauth/2.0/token
  168. scopes:
  169. # Only reading the board allow with delegated access
  170. board:read: Read the board
  171. user2AppOauth:
  172. type: oauth2
  173. flows:
  174. authorizationCode:
  175. authorizationUrl: https://learn.openapis.org/oauth/2.0/auth
  176. tokenUrl: https://learn.openapis.org/oauth/2.0/token
  177. scopes:
  178. # Reads and writes permitted via authorization code flow
  179. board:read: Read the board
  180. board:write: Write to the board