From a8418fd2ef91f99c1c1138c59e82841dc1442a36 Mon Sep 17 00:00:00 2001 From: Daithi Hearn Date: Sun, 21 Apr 2024 12:49:35 +0200 Subject: [PATCH 1/2] updating swagger docs --- docs/docs.go | 519 ++++++++++++++++++++++++++++++++++++++-------- docs/swagger.json | 519 ++++++++++++++++++++++++++++++++++++++-------- docs/swagger.yaml | 347 +++++++++++++++++++++++++------ 3 files changed, 1159 insertions(+), 226 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index b5de1ac..64c737c 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -15,7 +15,7 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/admin/game": { + "/game": { "put": { "security": [ { @@ -66,21 +66,66 @@ const docTemplate = `{ } } }, - "/admin/stats/gameStatsForPlayer": { + "/game/all": { "get": { - "description": "Returns stats for a player", + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns all games", "produces": [ "application/json" ], "tags": [ - "Stats" + "Game" ], - "operationId": "get-stats-for-player", + "operationId": "get-all-games", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/game.Game" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns a game with the given ID", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "get-game", "parameters": [ { "type": "string", - "description": "Player ID", - "name": "playerId", + "description": "Game ID", + "name": "gameId", "in": "path", "required": true } @@ -89,8 +134,46 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/game.PlayerStats" + "$ref": "#/definitions/game.Game" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes a game with the given ID", + "tags": [ + "Game" + ], + "operationId": "delete-game", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" }, "400": { "description": "Bad Request", @@ -107,29 +190,35 @@ const docTemplate = `{ } } }, - "/game/all": { - "get": { + "/game/{gameId}/buy": { + "put": { "security": [ { "Bearer": [] } ], - "description": "Returns all games", + "description": "When in the Buying state, the Goer can buy cards from the deck", "produces": [ "application/json" ], "tags": [ "Game" ], - "operationId": "get-all-games", + "operationId": "buy", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/game.Game" - } + "$ref": "#/definitions/game.State" } }, "400": { @@ -147,21 +236,127 @@ const docTemplate = `{ } } }, - "/game/{gameId}": { + "/game/{gameId}/call": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Makes a call for the current user in the game with the given ID", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "call", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Call", + "name": "call", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/game.State" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}/play": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "When in the Playing state, the current player can play a card", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "play", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Card", + "name": "card", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/game.State" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}/state": { "get": { "security": [ { "Bearer": [] } ], - "description": "Returns a game with the given ID", + "description": "Returns the state of a game with the given ID for the current user", "produces": [ "application/json" ], "tags": [ "Game" ], - "operationId": "get-game", + "operationId": "get-game-state", "parameters": [ { "type": "string", @@ -169,13 +364,68 @@ const docTemplate = `{ "name": "gameId", "in": "path", "required": true + }, + { + "type": "integer", + "description": "Revision", + "name": "revision", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/game.Game" + "$ref": "#/definitions/game.State" + } + }, + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}/suit": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "When in the Called state, the Goer can select the suit and what cards they want to keep from their hand and the dummy hand", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "select-suit", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/game.State" } }, "400": { @@ -208,6 +458,14 @@ const docTemplate = `{ "Profile" ], "operationId": "get-profile", + "parameters": [ + { + "type": "string", + "description": "Player ID", + "name": "playerId", + "in": "query" + } + ], "responses": { "200": { "description": "OK", @@ -291,26 +549,29 @@ const docTemplate = `{ } } }, - "/profile/has": { + "/profile/all": { "get": { "security": [ { "Bearer": [] } ], - "description": "Returns a boolean indicating if the user has a profile or not.", + "description": "Returns all profiles.", "produces": [ "application/json" ], "tags": [ "Profile" ], - "operationId": "has-profile", + "operationId": "get-all-profiles", "responses": { "200": { "description": "OK", "schema": { - "type": "boolean" + "type": "array", + "items": { + "$ref": "#/definitions/profile.Profile" + } } }, "400": { @@ -426,7 +687,7 @@ const docTemplate = `{ } } }, - "/stats/gameStatsForPlayer": { + "/stats": { "get": { "security": [ { @@ -445,7 +706,48 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/game.PlayerStats" + "$ref": "#/definitions/stats.PlayerStats" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/stats/{playerId}": { + "get": { + "description": "Returns stats for a player", + "produces": [ + "application/json" + ], + "tags": [ + "Stats" + ], + "operationId": "get-stats-for-player", + "parameters": [ + { + "type": "string", + "description": "Player ID", + "name": "playerId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/stats.PlayerStats" } }, "400": { @@ -473,22 +775,23 @@ const docTemplate = `{ } } }, - "game.Card": { - "type": "object", - "properties": { - "coldValue": { - "type": "integer" - }, - "renegable": { - "type": "boolean" - }, - "suit": { - "$ref": "#/definitions/game.Suit" - }, - "value": { - "type": "integer" - } - } + "game.Call": { + "type": "integer", + "enum": [ + 0 + ], + "x-enum-varnames": [ + "Pass" + ] + }, + "game.CardName": { + "type": "string", + "enum": [ + "EMPTY" + ], + "x-enum-varnames": [ + "EMPTY_CARD" + ] }, "game.CreateGameRequest": { "type": "object", @@ -496,7 +799,7 @@ const docTemplate = `{ "name": { "type": "string" }, - "playerIds": { + "players": { "type": "array", "items": { "type": "string" @@ -510,15 +813,6 @@ const docTemplate = `{ "adminId": { "type": "string" }, - "completedRounds": { - "type": "array", - "items": { - "$ref": "#/definitions/game.Round" - } - }, - "currentRound": { - "$ref": "#/definitions/game.Round" - }, "id": { "type": "string" }, @@ -531,10 +825,13 @@ const docTemplate = `{ "$ref": "#/definitions/game.Player" } }, + "revision": { + "type": "integer" + }, "status": { "$ref": "#/definitions/game.Status" }, - "timeStamp": { + "timestamp": { "type": "string" } } @@ -546,7 +843,7 @@ const docTemplate = `{ "type": "string" }, "leadOut": { - "$ref": "#/definitions/game.Card" + "$ref": "#/definitions/game.CardName" }, "playedCards": { "type": "array", @@ -554,7 +851,7 @@ const docTemplate = `{ "$ref": "#/definitions/game.PlayedCard" } }, - "timeStamp": { + "timestamp": { "type": "string" } } @@ -563,7 +860,7 @@ const docTemplate = `{ "type": "object", "properties": { "card": { - "$ref": "#/definitions/game.Card" + "$ref": "#/definitions/game.CardName" }, "playerId": { "type": "string" @@ -574,7 +871,7 @@ const docTemplate = `{ "type": "object", "properties": { "call": { - "type": "integer" + "$ref": "#/definitions/game.Call" }, "cardsBought": { "type": "integer" @@ -599,26 +896,6 @@ const docTemplate = `{ } } }, - "game.PlayerStats": { - "type": "object", - "properties": { - "gameId": { - "type": "string" - }, - "rings": { - "type": "integer" - }, - "score": { - "type": "integer" - }, - "timeStamp": { - "type": "string" - }, - "winner": { - "type": "boolean" - } - } - }, "game.Round": { "type": "object", "properties": { @@ -649,27 +926,80 @@ const docTemplate = `{ "suit": { "$ref": "#/definitions/game.Suit" }, - "timeStamp": { + "timestamp": { "type": "string" } } }, "game.RoundStatus": { - "type": "integer", + "type": "string", "enum": [ - 0 + "CALLING" ], "x-enum-varnames": [ - "CALLING" + "Calling" ] }, + "game.State": { + "type": "object", + "properties": { + "cards": { + "type": "array", + "items": { + "$ref": "#/definitions/game.CardName" + } + }, + "iamAdmin": { + "type": "boolean" + }, + "iamDealer": { + "type": "boolean" + }, + "iamGoer": { + "type": "boolean" + }, + "iamSpectator": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "isMyGo": { + "type": "boolean" + }, + "maxCall": { + "$ref": "#/definitions/game.Call" + }, + "me": { + "$ref": "#/definitions/game.Player" + }, + "players": { + "type": "array", + "items": { + "$ref": "#/definitions/game.Player" + } + }, + "previousRound": { + "$ref": "#/definitions/game.Round" + }, + "revision": { + "type": "integer" + }, + "round": { + "$ref": "#/definitions/game.Round" + }, + "status": { + "$ref": "#/definitions/game.Status" + } + } + }, "game.Status": { "type": "string", "enum": [ "ACTIVE" ], "x-enum-varnames": [ - "ACTIVE" + "Active" ] }, "game.Suit": { @@ -678,12 +1008,15 @@ const docTemplate = `{ "EMPTY" ], "x-enum-varnames": [ - "EMPTY" + "Empty" ] }, "profile.Profile": { "type": "object", "properties": { + "id": { + "type": "string" + }, "lastAccess": { "type": "string" }, @@ -722,6 +1055,26 @@ const docTemplate = `{ "type": "boolean" } } + }, + "stats.PlayerStats": { + "type": "object", + "properties": { + "gameId": { + "type": "string" + }, + "rings": { + "type": "integer" + }, + "score": { + "type": "integer" + }, + "timestamp": { + "type": "string" + }, + "winner": { + "type": "boolean" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.json b/docs/swagger.json index a89f61d..e3cedd9 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -8,7 +8,7 @@ }, "basePath": "/api/v1", "paths": { - "/admin/game": { + "/game": { "put": { "security": [ { @@ -59,21 +59,66 @@ } } }, - "/admin/stats/gameStatsForPlayer": { + "/game/all": { "get": { - "description": "Returns stats for a player", + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns all games", "produces": [ "application/json" ], "tags": [ - "Stats" + "Game" ], - "operationId": "get-stats-for-player", + "operationId": "get-all-games", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/game.Game" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Returns a game with the given ID", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "get-game", "parameters": [ { "type": "string", - "description": "Player ID", - "name": "playerId", + "description": "Game ID", + "name": "gameId", "in": "path", "required": true } @@ -82,8 +127,46 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/game.PlayerStats" + "$ref": "#/definitions/game.Game" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" } + } + } + }, + "delete": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes a game with the given ID", + "tags": [ + "Game" + ], + "operationId": "delete-game", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" }, "400": { "description": "Bad Request", @@ -100,29 +183,35 @@ } } }, - "/game/all": { - "get": { + "/game/{gameId}/buy": { + "put": { "security": [ { "Bearer": [] } ], - "description": "Returns all games", + "description": "When in the Buying state, the Goer can buy cards from the deck", "produces": [ "application/json" ], "tags": [ "Game" ], - "operationId": "get-all-games", + "operationId": "buy", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/game.Game" - } + "$ref": "#/definitions/game.State" } }, "400": { @@ -140,21 +229,127 @@ } } }, - "/game/{gameId}": { + "/game/{gameId}/call": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Makes a call for the current user in the game with the given ID", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "call", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Call", + "name": "call", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/game.State" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}/play": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "When in the Playing state, the current player can play a card", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "play", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Card", + "name": "card", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/game.State" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}/state": { "get": { "security": [ { "Bearer": [] } ], - "description": "Returns a game with the given ID", + "description": "Returns the state of a game with the given ID for the current user", "produces": [ "application/json" ], "tags": [ "Game" ], - "operationId": "get-game", + "operationId": "get-game-state", "parameters": [ { "type": "string", @@ -162,13 +357,68 @@ "name": "gameId", "in": "path", "required": true + }, + { + "type": "integer", + "description": "Revision", + "name": "revision", + "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/game.Game" + "$ref": "#/definitions/game.State" + } + }, + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/game/{gameId}/suit": { + "put": { + "security": [ + { + "Bearer": [] + } + ], + "description": "When in the Called state, the Goer can select the suit and what cards they want to keep from their hand and the dummy hand", + "produces": [ + "application/json" + ], + "tags": [ + "Game" + ], + "operationId": "select-suit", + "parameters": [ + { + "type": "string", + "description": "Game ID", + "name": "gameId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/game.State" } }, "400": { @@ -201,6 +451,14 @@ "Profile" ], "operationId": "get-profile", + "parameters": [ + { + "type": "string", + "description": "Player ID", + "name": "playerId", + "in": "query" + } + ], "responses": { "200": { "description": "OK", @@ -284,26 +542,29 @@ } } }, - "/profile/has": { + "/profile/all": { "get": { "security": [ { "Bearer": [] } ], - "description": "Returns a boolean indicating if the user has a profile or not.", + "description": "Returns all profiles.", "produces": [ "application/json" ], "tags": [ "Profile" ], - "operationId": "has-profile", + "operationId": "get-all-profiles", "responses": { "200": { "description": "OK", "schema": { - "type": "boolean" + "type": "array", + "items": { + "$ref": "#/definitions/profile.Profile" + } } }, "400": { @@ -419,7 +680,7 @@ } } }, - "/stats/gameStatsForPlayer": { + "/stats": { "get": { "security": [ { @@ -438,7 +699,48 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/game.PlayerStats" + "$ref": "#/definitions/stats.PlayerStats" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.ErrorResponse" + } + } + } + } + }, + "/stats/{playerId}": { + "get": { + "description": "Returns stats for a player", + "produces": [ + "application/json" + ], + "tags": [ + "Stats" + ], + "operationId": "get-stats-for-player", + "parameters": [ + { + "type": "string", + "description": "Player ID", + "name": "playerId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/stats.PlayerStats" } }, "400": { @@ -466,22 +768,23 @@ } } }, - "game.Card": { - "type": "object", - "properties": { - "coldValue": { - "type": "integer" - }, - "renegable": { - "type": "boolean" - }, - "suit": { - "$ref": "#/definitions/game.Suit" - }, - "value": { - "type": "integer" - } - } + "game.Call": { + "type": "integer", + "enum": [ + 0 + ], + "x-enum-varnames": [ + "Pass" + ] + }, + "game.CardName": { + "type": "string", + "enum": [ + "EMPTY" + ], + "x-enum-varnames": [ + "EMPTY_CARD" + ] }, "game.CreateGameRequest": { "type": "object", @@ -489,7 +792,7 @@ "name": { "type": "string" }, - "playerIds": { + "players": { "type": "array", "items": { "type": "string" @@ -503,15 +806,6 @@ "adminId": { "type": "string" }, - "completedRounds": { - "type": "array", - "items": { - "$ref": "#/definitions/game.Round" - } - }, - "currentRound": { - "$ref": "#/definitions/game.Round" - }, "id": { "type": "string" }, @@ -524,10 +818,13 @@ "$ref": "#/definitions/game.Player" } }, + "revision": { + "type": "integer" + }, "status": { "$ref": "#/definitions/game.Status" }, - "timeStamp": { + "timestamp": { "type": "string" } } @@ -539,7 +836,7 @@ "type": "string" }, "leadOut": { - "$ref": "#/definitions/game.Card" + "$ref": "#/definitions/game.CardName" }, "playedCards": { "type": "array", @@ -547,7 +844,7 @@ "$ref": "#/definitions/game.PlayedCard" } }, - "timeStamp": { + "timestamp": { "type": "string" } } @@ -556,7 +853,7 @@ "type": "object", "properties": { "card": { - "$ref": "#/definitions/game.Card" + "$ref": "#/definitions/game.CardName" }, "playerId": { "type": "string" @@ -567,7 +864,7 @@ "type": "object", "properties": { "call": { - "type": "integer" + "$ref": "#/definitions/game.Call" }, "cardsBought": { "type": "integer" @@ -592,26 +889,6 @@ } } }, - "game.PlayerStats": { - "type": "object", - "properties": { - "gameId": { - "type": "string" - }, - "rings": { - "type": "integer" - }, - "score": { - "type": "integer" - }, - "timeStamp": { - "type": "string" - }, - "winner": { - "type": "boolean" - } - } - }, "game.Round": { "type": "object", "properties": { @@ -642,27 +919,80 @@ "suit": { "$ref": "#/definitions/game.Suit" }, - "timeStamp": { + "timestamp": { "type": "string" } } }, "game.RoundStatus": { - "type": "integer", + "type": "string", "enum": [ - 0 + "CALLING" ], "x-enum-varnames": [ - "CALLING" + "Calling" ] }, + "game.State": { + "type": "object", + "properties": { + "cards": { + "type": "array", + "items": { + "$ref": "#/definitions/game.CardName" + } + }, + "iamAdmin": { + "type": "boolean" + }, + "iamDealer": { + "type": "boolean" + }, + "iamGoer": { + "type": "boolean" + }, + "iamSpectator": { + "type": "boolean" + }, + "id": { + "type": "string" + }, + "isMyGo": { + "type": "boolean" + }, + "maxCall": { + "$ref": "#/definitions/game.Call" + }, + "me": { + "$ref": "#/definitions/game.Player" + }, + "players": { + "type": "array", + "items": { + "$ref": "#/definitions/game.Player" + } + }, + "previousRound": { + "$ref": "#/definitions/game.Round" + }, + "revision": { + "type": "integer" + }, + "round": { + "$ref": "#/definitions/game.Round" + }, + "status": { + "$ref": "#/definitions/game.Status" + } + } + }, "game.Status": { "type": "string", "enum": [ "ACTIVE" ], "x-enum-varnames": [ - "ACTIVE" + "Active" ] }, "game.Suit": { @@ -671,12 +1001,15 @@ "EMPTY" ], "x-enum-varnames": [ - "EMPTY" + "Empty" ] }, "profile.Profile": { "type": "object", "properties": { + "id": { + "type": "string" + }, "lastAccess": { "type": "string" }, @@ -715,6 +1048,26 @@ "type": "boolean" } } + }, + "stats.PlayerStats": { + "type": "object", + "properties": { + "gameId": { + "type": "string" + }, + "rings": { + "type": "integer" + }, + "score": { + "type": "integer" + }, + "timestamp": { + "type": "string" + }, + "winner": { + "type": "boolean" + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 207db70..e573b2a 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -5,22 +5,23 @@ definitions: message: type: string type: object - game.Card: - properties: - coldValue: - type: integer - renegable: - type: boolean - suit: - $ref: '#/definitions/game.Suit' - value: - type: integer - type: object + game.Call: + enum: + - 0 + type: integer + x-enum-varnames: + - Pass + game.CardName: + enum: + - EMPTY + type: string + x-enum-varnames: + - EMPTY_CARD game.CreateGameRequest: properties: name: type: string - playerIds: + players: items: type: string type: array @@ -29,12 +30,6 @@ definitions: properties: adminId: type: string - completedRounds: - items: - $ref: '#/definitions/game.Round' - type: array - currentRound: - $ref: '#/definitions/game.Round' id: type: string name: @@ -43,9 +38,11 @@ definitions: items: $ref: '#/definitions/game.Player' type: array + revision: + type: integer status: $ref: '#/definitions/game.Status' - timeStamp: + timestamp: type: string type: object game.Hand: @@ -53,25 +50,25 @@ definitions: currentPlayerId: type: string leadOut: - $ref: '#/definitions/game.Card' + $ref: '#/definitions/game.CardName' playedCards: items: $ref: '#/definitions/game.PlayedCard' type: array - timeStamp: + timestamp: type: string type: object game.PlayedCard: properties: card: - $ref: '#/definitions/game.Card' + $ref: '#/definitions/game.CardName' playerId: type: string type: object game.Player: properties: call: - type: integer + $ref: '#/definitions/game.Call' cardsBought: type: integer id: @@ -87,19 +84,6 @@ definitions: winner: type: boolean type: object - game.PlayerStats: - properties: - gameId: - type: string - rings: - type: integer - score: - type: integer - timeStamp: - type: string - winner: - type: boolean - type: object game.Round: properties: completedHands: @@ -120,29 +104,66 @@ definitions: $ref: '#/definitions/game.RoundStatus' suit: $ref: '#/definitions/game.Suit' - timeStamp: + timestamp: type: string type: object game.RoundStatus: enum: - - 0 - type: integer - x-enum-varnames: - CALLING + type: string + x-enum-varnames: + - Calling + game.State: + properties: + cards: + items: + $ref: '#/definitions/game.CardName' + type: array + iamAdmin: + type: boolean + iamDealer: + type: boolean + iamGoer: + type: boolean + iamSpectator: + type: boolean + id: + type: string + isMyGo: + type: boolean + maxCall: + $ref: '#/definitions/game.Call' + me: + $ref: '#/definitions/game.Player' + players: + items: + $ref: '#/definitions/game.Player' + type: array + previousRound: + $ref: '#/definitions/game.Round' + revision: + type: integer + round: + $ref: '#/definitions/game.Round' + status: + $ref: '#/definitions/game.Status' + type: object game.Status: enum: - ACTIVE type: string x-enum-varnames: - - ACTIVE + - Active game.Suit: enum: - EMPTY type: string x-enum-varnames: - - EMPTY + - Empty profile.Profile: properties: + id: + type: string lastAccess: type: string name: @@ -168,6 +189,19 @@ definitions: autoBuyCards: type: boolean type: object + stats.PlayerStats: + properties: + gameId: + type: string + rings: + type: integer + score: + type: integer + timestamp: + type: string + winner: + type: boolean + type: object info: contact: {} description: An API for playing the card game called 110. 110 is a game based on @@ -175,7 +209,7 @@ info: title: Cards 110 API version: 8.0.0 paths: - /admin/game: + /game: put: consumes: - application/json @@ -207,14 +241,38 @@ paths: - Bearer: [] tags: - Game - /admin/stats/gameStatsForPlayer: + /game/{gameId}: + delete: + description: Deletes a game with the given ID + operationId: delete-game + parameters: + - description: Game ID + in: path + name: gameId + required: true + type: string + responses: + "200": + description: OK + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.ErrorResponse' + security: + - Bearer: [] + tags: + - Game get: - description: Returns stats for a player - operationId: get-stats-for-player + description: Returns a game with the given ID + operationId: get-game parameters: - - description: Player ID + - description: Game ID in: path - name: playerId + name: gameId required: true type: string produces: @@ -223,7 +281,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/game.PlayerStats' + $ref: '#/definitions/game.Game' "400": description: Bad Request schema: @@ -232,25 +290,160 @@ paths: description: Internal Server Error schema: $ref: '#/definitions/api.ErrorResponse' + security: + - Bearer: [] tags: - - Stats - /game/{gameId}: + - Game + /game/{gameId}/buy: + put: + description: When in the Buying state, the Goer can buy cards from the deck + operationId: buy + parameters: + - description: Game ID + in: path + name: gameId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/game.State' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.ErrorResponse' + security: + - Bearer: [] + tags: + - Game + /game/{gameId}/call: + put: + description: Makes a call for the current user in the game with the given ID + operationId: call + parameters: + - description: Game ID + in: path + name: gameId + required: true + type: string + - description: Call + in: query + name: call + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/game.State' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.ErrorResponse' + security: + - Bearer: [] + tags: + - Game + /game/{gameId}/play: + put: + description: When in the Playing state, the current player can play a card + operationId: play + parameters: + - description: Game ID + in: path + name: gameId + required: true + type: string + - description: Card + in: query + name: card + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/game.State' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.ErrorResponse' + security: + - Bearer: [] + tags: + - Game + /game/{gameId}/state: get: - description: Returns a game with the given ID - operationId: get-game + description: Returns the state of a game with the given ID for the current user + operationId: get-game-state parameters: - description: Game ID in: path name: gameId required: true type: string + - description: Revision + in: query + name: revision + type: integer produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/game.Game' + $ref: '#/definitions/game.State' + "204": + description: No Content + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.ErrorResponse' + security: + - Bearer: [] + tags: + - Game + /game/{gameId}/suit: + put: + description: When in the Called state, the Goer can select the suit and what + cards they want to keep from their hand and the dummy hand + operationId: select-suit + parameters: + - description: Game ID + in: path + name: gameId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/game.State' "400": description: Bad Request schema: @@ -292,6 +485,11 @@ paths: get: description: Returns the user's profile. operationId: get-profile + parameters: + - description: Player ID + in: query + name: playerId + type: string produces: - application/json responses: @@ -350,17 +548,19 @@ paths: - Bearer: [] tags: - Profile - /profile/has: + /profile/all: get: - description: Returns a boolean indicating if the user has a profile or not. - operationId: has-profile + description: Returns all profiles. + operationId: get-all-profiles produces: - application/json responses: "200": description: OK schema: - type: boolean + items: + $ref: '#/definitions/profile.Profile' + type: array "400": description: Bad Request schema: @@ -435,7 +635,7 @@ paths: - Bearer: [] tags: - Settings - /stats/gameStatsForPlayer: + /stats: get: description: Returns stats for the current user operationId: get-stats @@ -445,7 +645,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/game.PlayerStats' + $ref: '#/definitions/stats.PlayerStats' "400": description: Bad Request schema: @@ -458,6 +658,33 @@ paths: - Bearer: [] tags: - Stats + /stats/{playerId}: + get: + description: Returns stats for a player + operationId: get-stats-for-player + parameters: + - description: Player ID + in: path + name: playerId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/stats.PlayerStats' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.ErrorResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.ErrorResponse' + tags: + - Stats securityDefinitions: Bearer: in: header From 071a065793f4ba1e5fbef647e9830d4dc5862cf1 Mon Sep 17 00:00:00 2001 From: Daithi Hearn Date: Sun, 21 Apr 2024 12:51:57 +0200 Subject: [PATCH 2/2] updating dependencies --- go.mod | 2 +- go.sum | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 97c2dca..bcea6a3 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/auth0/go-jwt-middleware/v2 v2.2.0 github.com/gin-contrib/cors v1.5.0 github.com/gin-gonic/gin v1.9.1 + github.com/go-redis/redis/v8 v8.11.5 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/joho/godotenv v1.5.1 github.com/swaggo/files v1.0.1 @@ -32,7 +33,6 @@ require ( github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.15.5 // indirect - github.com/go-redis/redis/v8 v8.11.5 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang/snappy v0.0.1 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index 3a43c9a..b31fbec 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gin-contrib/cors v1.5.0 h1:DgGKV7DDoOn36DFkNtbHrjoRiT5ExCe+PC9/xp7aKvk= @@ -101,6 +103,12 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -202,6 +210,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/go-jose/go-jose.v2 v2.6.1 h1:qEzJlIDmG9q5VO0M/o8tGS65QMHMS1w01TQJB1VPJ4U= gopkg.in/go-jose/go-jose.v2 v2.6.1/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=