aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-14 20:32:47 +0900
committernsfisis <nsfisis@gmail.com>2026-02-14 20:32:47 +0900
commit9185367fcd7d95af89fac36dd892d8b064dbd94f (patch)
tree6085f0c4ab695d0f83348f32b49b5481f1da6548 /backend
parent6bd35e345a4c5d74578b0f8a5c969027e7e15f02 (diff)
downloadphperkaigi-2026-albatross-9185367fcd7d95af89fac36dd892d8b064dbd94f.tar.gz
phperkaigi-2026-albatross-9185367fcd7d95af89fac36dd892d8b064dbd94f.tar.zst
phperkaigi-2026-albatross-9185367fcd7d95af89fac36dd892d8b064dbd94f.zip
feat(openapi): generate OpenAPI specs from TypeSpec sources
Migrate hand-written OpenAPI YAML to TypeSpec (.tsp) source files. TypeSpec compiles to OpenAPI 3.0 YAML, enabling type-safe API definitions. - Add typespec/ directory with api-server and fortee definitions - Integrate TypeSpec build into `just gen` and `just build` pipelines - Update backend handler code to match new generated type names (inlined error responses, separate GameType/ProblemLanguage enums) - Regenerate frontend TypeScript types from new OpenAPI output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'backend')
-rw-r--r--backend/api/generated.go254
-rw-r--r--backend/api/handler.go28
-rw-r--r--backend/api/handler_wrapper.go40
-rw-r--r--backend/gen/api/handler_wrapper_gen.go8
4 files changed, 133 insertions, 197 deletions
diff --git a/backend/api/generated.go b/backend/api/generated.go
index 781e709..1cc692c 100644
--- a/backend/api/generated.go
+++ b/backend/api/generated.go
@@ -34,10 +34,10 @@ const (
WrongAnswer ExecutionStatus = "wrong_answer"
)
-// Defines values for GameGameType.
+// Defines values for GameType.
const (
- Multiplayer GameGameType = "multiplayer"
- N1V1 GameGameType = "1v1"
+ Multiplayer GameType = "multiplayer"
+ N1V1 GameType = "1v1"
)
// Defines values for ProblemLanguage.
@@ -56,18 +56,18 @@ type ExecutionStatus string
// Game defines model for Game.
type Game struct {
- DisplayName string `json:"display_name"`
- DurationSeconds int `json:"duration_seconds"`
- GameID int `json:"game_id"`
- GameType GameGameType `json:"game_type"`
- IsPublic bool `json:"is_public"`
- MainPlayers []User `json:"main_players"`
- Problem Problem `json:"problem"`
- StartedAt *int64 `json:"started_at,omitempty"`
+ DisplayName string `json:"display_name"`
+ DurationSeconds int `json:"duration_seconds"`
+ GameID int `json:"game_id"`
+ GameType GameType `json:"game_type"`
+ IsPublic bool `json:"is_public"`
+ MainPlayers []User `json:"main_players"`
+ Problem Problem `json:"problem"`
+ StartedAt *int64 `json:"started_at,omitempty"`
}
-// GameGameType defines model for Game.GameType.
-type GameGameType string
+// GameType defines model for GameType.
+type GameType string
// LatestGameState defines model for LatestGameState.
type LatestGameState struct {
@@ -86,7 +86,7 @@ type Problem struct {
Title string `json:"title"`
}
-// ProblemLanguage defines model for Problem.Language.
+// ProblemLanguage defines model for ProblemLanguage.
type ProblemLanguage string
// RankingEntry defines model for RankingEntry.
@@ -122,21 +122,6 @@ type User struct {
Username string `json:"username"`
}
-// PathGameID defines model for path_game_id.
-type PathGameID = int
-
-// BadRequest defines model for BadRequest.
-type BadRequest = Error
-
-// Forbidden defines model for Forbidden.
-type Forbidden = Error
-
-// NotFound defines model for NotFound.
-type NotFound = Error
-
-// Unauthorized defines model for Unauthorized.
-type Unauthorized = Error
-
// PostGamePlayCodeJSONBody defines parameters for PostGamePlayCode.
type PostGamePlayCodeJSONBody struct {
Code string `json:"code"`
@@ -173,37 +158,37 @@ type PostLoginJSONRequestBody PostLoginJSONBody
// ServerInterface represents all server handlers.
type ServerInterface interface {
- // List games
+
// (GET /games)
GetGames(ctx echo.Context) error
- // Get a game
+
// (GET /games/{game_id})
- GetGame(ctx echo.Context, gameID PathGameID) error
- // Post the latest code
+ GetGame(ctx echo.Context, gameID int) error
+
// (POST /games/{game_id}/play/code)
- PostGamePlayCode(ctx echo.Context, gameID PathGameID) error
- // Get the latest execution result for player
+ PostGamePlayCode(ctx echo.Context, gameID int) error
+
// (GET /games/{game_id}/play/latest_state)
- GetGamePlayLatestState(ctx echo.Context, gameID PathGameID) error
- // Submit the answer
+ GetGamePlayLatestState(ctx echo.Context, gameID int) error
+
// (POST /games/{game_id}/play/submit)
- PostGamePlaySubmit(ctx echo.Context, gameID PathGameID) error
- // Get all the latest game states of the main players
+ PostGamePlaySubmit(ctx echo.Context, gameID int) error
+
// (GET /games/{game_id}/watch/latest_states)
- GetGameWatchLatestStates(ctx echo.Context, gameID PathGameID) error
- // Get the latest player ranking
+ GetGameWatchLatestStates(ctx echo.Context, gameID int) error
+
// (GET /games/{game_id}/watch/ranking)
- GetGameWatchRanking(ctx echo.Context, gameID PathGameID) error
- // User login
+ GetGameWatchRanking(ctx echo.Context, gameID int) error
+
// (POST /login)
PostLogin(ctx echo.Context) error
- // User logout
+
// (POST /logout)
PostLogout(ctx echo.Context) error
- // Get current user
+
// (GET /me)
GetMe(ctx echo.Context) error
- // Get tournament bracket data
+
// (GET /tournament)
GetTournament(ctx echo.Context, params GetTournamentParams) error
}
@@ -226,7 +211,7 @@ func (w *ServerInterfaceWrapper) GetGames(ctx echo.Context) error {
func (w *ServerInterfaceWrapper) GetGame(ctx echo.Context) error {
var err error
// ------------- Path parameter "game_id" -------------
- var gameID PathGameID
+ var gameID int
err = runtime.BindStyledParameterWithOptions("simple", "game_id", ctx.Param("game_id"), &gameID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@@ -242,7 +227,7 @@ func (w *ServerInterfaceWrapper) GetGame(ctx echo.Context) error {
func (w *ServerInterfaceWrapper) PostGamePlayCode(ctx echo.Context) error {
var err error
// ------------- Path parameter "game_id" -------------
- var gameID PathGameID
+ var gameID int
err = runtime.BindStyledParameterWithOptions("simple", "game_id", ctx.Param("game_id"), &gameID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@@ -258,7 +243,7 @@ func (w *ServerInterfaceWrapper) PostGamePlayCode(ctx echo.Context) error {
func (w *ServerInterfaceWrapper) GetGamePlayLatestState(ctx echo.Context) error {
var err error
// ------------- Path parameter "game_id" -------------
- var gameID PathGameID
+ var gameID int
err = runtime.BindStyledParameterWithOptions("simple", "game_id", ctx.Param("game_id"), &gameID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@@ -274,7 +259,7 @@ func (w *ServerInterfaceWrapper) GetGamePlayLatestState(ctx echo.Context) error
func (w *ServerInterfaceWrapper) PostGamePlaySubmit(ctx echo.Context) error {
var err error
// ------------- Path parameter "game_id" -------------
- var gameID PathGameID
+ var gameID int
err = runtime.BindStyledParameterWithOptions("simple", "game_id", ctx.Param("game_id"), &gameID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@@ -290,7 +275,7 @@ func (w *ServerInterfaceWrapper) PostGamePlaySubmit(ctx echo.Context) error {
func (w *ServerInterfaceWrapper) GetGameWatchLatestStates(ctx echo.Context) error {
var err error
// ------------- Path parameter "game_id" -------------
- var gameID PathGameID
+ var gameID int
err = runtime.BindStyledParameterWithOptions("simple", "game_id", ctx.Param("game_id"), &gameID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@@ -306,7 +291,7 @@ func (w *ServerInterfaceWrapper) GetGameWatchLatestStates(ctx echo.Context) erro
func (w *ServerInterfaceWrapper) GetGameWatchRanking(ctx echo.Context) error {
var err error
// ------------- Path parameter "game_id" -------------
- var gameID PathGameID
+ var gameID int
err = runtime.BindStyledParameterWithOptions("simple", "game_id", ctx.Param("game_id"), &gameID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
@@ -353,35 +338,35 @@ func (w *ServerInterfaceWrapper) GetTournament(ctx echo.Context) error {
var params GetTournamentParams
// ------------- Required query parameter "game1" -------------
- err = runtime.BindQueryParameter("form", true, true, "game1", ctx.QueryParams(), &params.Game1)
+ err = runtime.BindQueryParameter("form", false, true, "game1", ctx.QueryParams(), &params.Game1)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter game1: %s", err))
}
// ------------- Required query parameter "game2" -------------
- err = runtime.BindQueryParameter("form", true, true, "game2", ctx.QueryParams(), &params.Game2)
+ err = runtime.BindQueryParameter("form", false, true, "game2", ctx.QueryParams(), &params.Game2)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter game2: %s", err))
}
// ------------- Required query parameter "game3" -------------
- err = runtime.BindQueryParameter("form", true, true, "game3", ctx.QueryParams(), &params.Game3)
+ err = runtime.BindQueryParameter("form", false, true, "game3", ctx.QueryParams(), &params.Game3)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter game3: %s", err))
}
// ------------- Required query parameter "game4" -------------
- err = runtime.BindQueryParameter("form", true, true, "game4", ctx.QueryParams(), &params.Game4)
+ err = runtime.BindQueryParameter("form", false, true, "game4", ctx.QueryParams(), &params.Game4)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter game4: %s", err))
}
// ------------- Required query parameter "game5" -------------
- err = runtime.BindQueryParameter("form", true, true, "game5", ctx.QueryParams(), &params.Game5)
+ err = runtime.BindQueryParameter("form", false, true, "game5", ctx.QueryParams(), &params.Game5)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter game5: %s", err))
}
@@ -433,14 +418,6 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL
}
-type BadRequestJSONResponse Error
-
-type ForbiddenJSONResponse Error
-
-type NotFoundJSONResponse Error
-
-type UnauthorizedJSONResponse Error
-
type GetGamesRequestObject struct {
}
@@ -459,7 +436,7 @@ func (response GetGames200JSONResponse) VisitGetGamesResponse(w http.ResponseWri
return json.NewEncoder(w).Encode(response)
}
-type GetGames401JSONResponse struct{ UnauthorizedJSONResponse }
+type GetGames401JSONResponse Error
func (response GetGames401JSONResponse) VisitGetGamesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -468,7 +445,7 @@ func (response GetGames401JSONResponse) VisitGetGamesResponse(w http.ResponseWri
return json.NewEncoder(w).Encode(response)
}
-type GetGames403JSONResponse struct{ ForbiddenJSONResponse }
+type GetGames403JSONResponse Error
func (response GetGames403JSONResponse) VisitGetGamesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -478,7 +455,7 @@ func (response GetGames403JSONResponse) VisitGetGamesResponse(w http.ResponseWri
}
type GetGameRequestObject struct {
- GameID PathGameID `json:"game_id"`
+ GameID int `json:"game_id"`
}
type GetGameResponseObject interface {
@@ -496,7 +473,7 @@ func (response GetGame200JSONResponse) VisitGetGameResponse(w http.ResponseWrite
return json.NewEncoder(w).Encode(response)
}
-type GetGame401JSONResponse struct{ UnauthorizedJSONResponse }
+type GetGame401JSONResponse Error
func (response GetGame401JSONResponse) VisitGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -505,7 +482,7 @@ func (response GetGame401JSONResponse) VisitGetGameResponse(w http.ResponseWrite
return json.NewEncoder(w).Encode(response)
}
-type GetGame403JSONResponse struct{ ForbiddenJSONResponse }
+type GetGame403JSONResponse Error
func (response GetGame403JSONResponse) VisitGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -514,7 +491,7 @@ func (response GetGame403JSONResponse) VisitGetGameResponse(w http.ResponseWrite
return json.NewEncoder(w).Encode(response)
}
-type GetGame404JSONResponse struct{ NotFoundJSONResponse }
+type GetGame404JSONResponse Error
func (response GetGame404JSONResponse) VisitGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -524,7 +501,7 @@ func (response GetGame404JSONResponse) VisitGetGameResponse(w http.ResponseWrite
}
type PostGamePlayCodeRequestObject struct {
- GameID PathGameID `json:"game_id"`
+ GameID int `json:"game_id"`
Body *PostGamePlayCodeJSONRequestBody
}
@@ -540,7 +517,7 @@ func (response PostGamePlayCode200Response) VisitPostGamePlayCodeResponse(w http
return nil
}
-type PostGamePlayCode401JSONResponse struct{ UnauthorizedJSONResponse }
+type PostGamePlayCode401JSONResponse Error
func (response PostGamePlayCode401JSONResponse) VisitPostGamePlayCodeResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -549,7 +526,7 @@ func (response PostGamePlayCode401JSONResponse) VisitPostGamePlayCodeResponse(w
return json.NewEncoder(w).Encode(response)
}
-type PostGamePlayCode403JSONResponse struct{ ForbiddenJSONResponse }
+type PostGamePlayCode403JSONResponse Error
func (response PostGamePlayCode403JSONResponse) VisitPostGamePlayCodeResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -558,7 +535,7 @@ func (response PostGamePlayCode403JSONResponse) VisitPostGamePlayCodeResponse(w
return json.NewEncoder(w).Encode(response)
}
-type PostGamePlayCode404JSONResponse struct{ NotFoundJSONResponse }
+type PostGamePlayCode404JSONResponse Error
func (response PostGamePlayCode404JSONResponse) VisitPostGamePlayCodeResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -568,7 +545,7 @@ func (response PostGamePlayCode404JSONResponse) VisitPostGamePlayCodeResponse(w
}
type GetGamePlayLatestStateRequestObject struct {
- GameID PathGameID `json:"game_id"`
+ GameID int `json:"game_id"`
}
type GetGamePlayLatestStateResponseObject interface {
@@ -586,7 +563,7 @@ func (response GetGamePlayLatestState200JSONResponse) VisitGetGamePlayLatestStat
return json.NewEncoder(w).Encode(response)
}
-type GetGamePlayLatestState401JSONResponse struct{ UnauthorizedJSONResponse }
+type GetGamePlayLatestState401JSONResponse Error
func (response GetGamePlayLatestState401JSONResponse) VisitGetGamePlayLatestStateResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -595,7 +572,7 @@ func (response GetGamePlayLatestState401JSONResponse) VisitGetGamePlayLatestStat
return json.NewEncoder(w).Encode(response)
}
-type GetGamePlayLatestState403JSONResponse struct{ ForbiddenJSONResponse }
+type GetGamePlayLatestState403JSONResponse Error
func (response GetGamePlayLatestState403JSONResponse) VisitGetGamePlayLatestStateResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -604,7 +581,7 @@ func (response GetGamePlayLatestState403JSONResponse) VisitGetGamePlayLatestStat
return json.NewEncoder(w).Encode(response)
}
-type GetGamePlayLatestState404JSONResponse struct{ NotFoundJSONResponse }
+type GetGamePlayLatestState404JSONResponse Error
func (response GetGamePlayLatestState404JSONResponse) VisitGetGamePlayLatestStateResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -614,7 +591,7 @@ func (response GetGamePlayLatestState404JSONResponse) VisitGetGamePlayLatestStat
}
type PostGamePlaySubmitRequestObject struct {
- GameID PathGameID `json:"game_id"`
+ GameID int `json:"game_id"`
Body *PostGamePlaySubmitJSONRequestBody
}
@@ -630,7 +607,7 @@ func (response PostGamePlaySubmit200Response) VisitPostGamePlaySubmitResponse(w
return nil
}
-type PostGamePlaySubmit401JSONResponse struct{ UnauthorizedJSONResponse }
+type PostGamePlaySubmit401JSONResponse Error
func (response PostGamePlaySubmit401JSONResponse) VisitPostGamePlaySubmitResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -639,7 +616,7 @@ func (response PostGamePlaySubmit401JSONResponse) VisitPostGamePlaySubmitRespons
return json.NewEncoder(w).Encode(response)
}
-type PostGamePlaySubmit403JSONResponse struct{ ForbiddenJSONResponse }
+type PostGamePlaySubmit403JSONResponse Error
func (response PostGamePlaySubmit403JSONResponse) VisitPostGamePlaySubmitResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -648,7 +625,7 @@ func (response PostGamePlaySubmit403JSONResponse) VisitPostGamePlaySubmitRespons
return json.NewEncoder(w).Encode(response)
}
-type PostGamePlaySubmit404JSONResponse struct{ NotFoundJSONResponse }
+type PostGamePlaySubmit404JSONResponse Error
func (response PostGamePlaySubmit404JSONResponse) VisitPostGamePlaySubmitResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -658,7 +635,7 @@ func (response PostGamePlaySubmit404JSONResponse) VisitPostGamePlaySubmitRespons
}
type GetGameWatchLatestStatesRequestObject struct {
- GameID PathGameID `json:"game_id"`
+ GameID int `json:"game_id"`
}
type GetGameWatchLatestStatesResponseObject interface {
@@ -676,7 +653,7 @@ func (response GetGameWatchLatestStates200JSONResponse) VisitGetGameWatchLatestS
return json.NewEncoder(w).Encode(response)
}
-type GetGameWatchLatestStates401JSONResponse struct{ UnauthorizedJSONResponse }
+type GetGameWatchLatestStates401JSONResponse Error
func (response GetGameWatchLatestStates401JSONResponse) VisitGetGameWatchLatestStatesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -685,7 +662,7 @@ func (response GetGameWatchLatestStates401JSONResponse) VisitGetGameWatchLatestS
return json.NewEncoder(w).Encode(response)
}
-type GetGameWatchLatestStates403JSONResponse struct{ ForbiddenJSONResponse }
+type GetGameWatchLatestStates403JSONResponse Error
func (response GetGameWatchLatestStates403JSONResponse) VisitGetGameWatchLatestStatesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -694,7 +671,7 @@ func (response GetGameWatchLatestStates403JSONResponse) VisitGetGameWatchLatestS
return json.NewEncoder(w).Encode(response)
}
-type GetGameWatchLatestStates404JSONResponse struct{ NotFoundJSONResponse }
+type GetGameWatchLatestStates404JSONResponse Error
func (response GetGameWatchLatestStates404JSONResponse) VisitGetGameWatchLatestStatesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -704,7 +681,7 @@ func (response GetGameWatchLatestStates404JSONResponse) VisitGetGameWatchLatestS
}
type GetGameWatchRankingRequestObject struct {
- GameID PathGameID `json:"game_id"`
+ GameID int `json:"game_id"`
}
type GetGameWatchRankingResponseObject interface {
@@ -722,7 +699,7 @@ func (response GetGameWatchRanking200JSONResponse) VisitGetGameWatchRankingRespo
return json.NewEncoder(w).Encode(response)
}
-type GetGameWatchRanking401JSONResponse struct{ UnauthorizedJSONResponse }
+type GetGameWatchRanking401JSONResponse Error
func (response GetGameWatchRanking401JSONResponse) VisitGetGameWatchRankingResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -731,7 +708,7 @@ func (response GetGameWatchRanking401JSONResponse) VisitGetGameWatchRankingRespo
return json.NewEncoder(w).Encode(response)
}
-type GetGameWatchRanking403JSONResponse struct{ ForbiddenJSONResponse }
+type GetGameWatchRanking403JSONResponse Error
func (response GetGameWatchRanking403JSONResponse) VisitGetGameWatchRankingResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -740,7 +717,7 @@ func (response GetGameWatchRanking403JSONResponse) VisitGetGameWatchRankingRespo
return json.NewEncoder(w).Encode(response)
}
-type GetGameWatchRanking404JSONResponse struct{ NotFoundJSONResponse }
+type GetGameWatchRanking404JSONResponse Error
func (response GetGameWatchRanking404JSONResponse) VisitGetGameWatchRankingResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -768,7 +745,7 @@ func (response PostLogin200JSONResponse) VisitPostLoginResponse(w http.ResponseW
return json.NewEncoder(w).Encode(response)
}
-type PostLogin401JSONResponse struct{ UnauthorizedJSONResponse }
+type PostLogin401JSONResponse Error
func (response PostLogin401JSONResponse) VisitPostLoginResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -792,7 +769,7 @@ func (response PostLogout200Response) VisitPostLogoutResponse(w http.ResponseWri
return nil
}
-type PostLogout401JSONResponse struct{ UnauthorizedJSONResponse }
+type PostLogout401JSONResponse Error
func (response PostLogout401JSONResponse) VisitPostLogoutResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -819,7 +796,7 @@ func (response GetMe200JSONResponse) VisitGetMeResponse(w http.ResponseWriter) e
return json.NewEncoder(w).Encode(response)
}
-type GetMe401JSONResponse struct{ UnauthorizedJSONResponse }
+type GetMe401JSONResponse Error
func (response GetMe401JSONResponse) VisitGetMeResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -847,7 +824,7 @@ func (response GetTournament200JSONResponse) VisitGetTournamentResponse(w http.R
return json.NewEncoder(w).Encode(response)
}
-type GetTournament401JSONResponse struct{ UnauthorizedJSONResponse }
+type GetTournament401JSONResponse Error
func (response GetTournament401JSONResponse) VisitGetTournamentResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -856,7 +833,7 @@ func (response GetTournament401JSONResponse) VisitGetTournamentResponse(w http.R
return json.NewEncoder(w).Encode(response)
}
-type GetTournament403JSONResponse struct{ ForbiddenJSONResponse }
+type GetTournament403JSONResponse Error
func (response GetTournament403JSONResponse) VisitGetTournamentResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -865,7 +842,7 @@ func (response GetTournament403JSONResponse) VisitGetTournamentResponse(w http.R
return json.NewEncoder(w).Encode(response)
}
-type GetTournament404JSONResponse struct{ NotFoundJSONResponse }
+type GetTournament404JSONResponse Error
func (response GetTournament404JSONResponse) VisitGetTournamentResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -876,37 +853,37 @@ func (response GetTournament404JSONResponse) VisitGetTournamentResponse(w http.R
// StrictServerInterface represents all server handlers.
type StrictServerInterface interface {
- // List games
+
// (GET /games)
GetGames(ctx context.Context, request GetGamesRequestObject) (GetGamesResponseObject, error)
- // Get a game
+
// (GET /games/{game_id})
GetGame(ctx context.Context, request GetGameRequestObject) (GetGameResponseObject, error)
- // Post the latest code
+
// (POST /games/{game_id}/play/code)
PostGamePlayCode(ctx context.Context, request PostGamePlayCodeRequestObject) (PostGamePlayCodeResponseObject, error)
- // Get the latest execution result for player
+
// (GET /games/{game_id}/play/latest_state)
GetGamePlayLatestState(ctx context.Context, request GetGamePlayLatestStateRequestObject) (GetGamePlayLatestStateResponseObject, error)
- // Submit the answer
+
// (POST /games/{game_id}/play/submit)
PostGamePlaySubmit(ctx context.Context, request PostGamePlaySubmitRequestObject) (PostGamePlaySubmitResponseObject, error)
- // Get all the latest game states of the main players
+
// (GET /games/{game_id}/watch/latest_states)
GetGameWatchLatestStates(ctx context.Context, request GetGameWatchLatestStatesRequestObject) (GetGameWatchLatestStatesResponseObject, error)
- // Get the latest player ranking
+
// (GET /games/{game_id}/watch/ranking)
GetGameWatchRanking(ctx context.Context, request GetGameWatchRankingRequestObject) (GetGameWatchRankingResponseObject, error)
- // User login
+
// (POST /login)
PostLogin(ctx context.Context, request PostLoginRequestObject) (PostLoginResponseObject, error)
- // User logout
+
// (POST /logout)
PostLogout(ctx context.Context, request PostLogoutRequestObject) (PostLogoutResponseObject, error)
- // Get current user
+
// (GET /me)
GetMe(ctx context.Context, request GetMeRequestObject) (GetMeResponseObject, error)
- // Get tournament bracket data
+
// (GET /tournament)
GetTournament(ctx context.Context, request GetTournamentRequestObject) (GetTournamentResponseObject, error)
}
@@ -947,7 +924,7 @@ func (sh *strictHandler) GetGames(ctx echo.Context) error {
}
// GetGame operation middleware
-func (sh *strictHandler) GetGame(ctx echo.Context, gameID PathGameID) error {
+func (sh *strictHandler) GetGame(ctx echo.Context, gameID int) error {
var request GetGameRequestObject
request.GameID = gameID
@@ -972,7 +949,7 @@ func (sh *strictHandler) GetGame(ctx echo.Context, gameID PathGameID) error {
}
// PostGamePlayCode operation middleware
-func (sh *strictHandler) PostGamePlayCode(ctx echo.Context, gameID PathGameID) error {
+func (sh *strictHandler) PostGamePlayCode(ctx echo.Context, gameID int) error {
var request PostGamePlayCodeRequestObject
request.GameID = gameID
@@ -1003,7 +980,7 @@ func (sh *strictHandler) PostGamePlayCode(ctx echo.Context, gameID PathGameID) e
}
// GetGamePlayLatestState operation middleware
-func (sh *strictHandler) GetGamePlayLatestState(ctx echo.Context, gameID PathGameID) error {
+func (sh *strictHandler) GetGamePlayLatestState(ctx echo.Context, gameID int) error {
var request GetGamePlayLatestStateRequestObject
request.GameID = gameID
@@ -1028,7 +1005,7 @@ func (sh *strictHandler) GetGamePlayLatestState(ctx echo.Context, gameID PathGam
}
// PostGamePlaySubmit operation middleware
-func (sh *strictHandler) PostGamePlaySubmit(ctx echo.Context, gameID PathGameID) error {
+func (sh *strictHandler) PostGamePlaySubmit(ctx echo.Context, gameID int) error {
var request PostGamePlaySubmitRequestObject
request.GameID = gameID
@@ -1059,7 +1036,7 @@ func (sh *strictHandler) PostGamePlaySubmit(ctx echo.Context, gameID PathGameID)
}
// GetGameWatchLatestStates operation middleware
-func (sh *strictHandler) GetGameWatchLatestStates(ctx echo.Context, gameID PathGameID) error {
+func (sh *strictHandler) GetGameWatchLatestStates(ctx echo.Context, gameID int) error {
var request GetGameWatchLatestStatesRequestObject
request.GameID = gameID
@@ -1084,7 +1061,7 @@ func (sh *strictHandler) GetGameWatchLatestStates(ctx echo.Context, gameID PathG
}
// GetGameWatchRanking operation middleware
-func (sh *strictHandler) GetGameWatchRanking(ctx echo.Context, gameID PathGameID) error {
+func (sh *strictHandler) GetGameWatchRanking(ctx echo.Context, gameID int) error {
var request GetGameWatchRankingRequestObject
request.GameID = gameID
@@ -1211,33 +1188,28 @@ func (sh *strictHandler) GetTournament(ctx echo.Context, params GetTournamentPar
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
- "H4sIAAAAAAAC/+xaW2/buBL+KwTPAfqixs7lBD3Zp7TbFl20hdELFouiEGhpbDOlSJWk6noL/ffFkJJ1",
- "t+XELRJg3yKJM5yZ75vhDOMfNFJJqiRIa+jVD5oyzRKwoIsnuwqXLIGQx/jMJb1yL2lAJUuAXtHya0A1",
- "fM24hpheWZ1BQE20goShmN2kuJRLC0vQNM9zXG1SJQ24fZ6y+B18zcBYfIqUtCDdnyxNBY+Y5UpOboyS",
- "+K7S+18NC3pF/z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KGgBZfKESOKbUxsEqZI1/lSKeafHlx",
+ "yI0DmgdYZ1w9B1dG+fXrKzfxlyAeQAQJZoyrYElYGqgqLZAGAiTXIoE+uE9NdZ6Ws1TOpQf5C+5OCguK",
+ "t7+72fk1KWBN/42n22egv2cG9h0E/FBvGr3zU/PMhzfKB2pPx5Esj8ZDDcGwwp2m3Un6RPrD3rehWLdv",
+ "CdoEckLOzeKHIoc7so5rF5/c2nPDODeMt8qJDVbJutExDp4u/zJbaj1DnlTTsL9wmhKzBdNFY8VR3aRL",
+ "JE97OR9yfzQuCXfvO4pFxR3xqRCo5tqoq6DGFfihK6FS+Jkvb5UvlK/cdW//5HVnl7zUWJRjKTdcpN77",
+ "5+Ouhll5eVZIfMYY9Z3OaDn2M5DH/JNn1R5BXKuDEHL/nnDaI6xzOBs8wH8EdIbYC0dcNT5V9kW+9kGz",
+ "07vhMaf2PLbEVELoevk3DWLbbOYXx7XycLzky1eTfPVqkq9fTfIv/+fI1ITTuO/aHXrVhJynozc5He12",
+ "/wYAAP//Hl9qBRMoAAA=",
}
// GetSwagger returns the content of the embedded swagger specification file
diff --git a/backend/api/handler.go b/backend/api/handler.go
index 3b04665..25aea01 100644
--- a/backend/api/handler.go
+++ b/backend/api/handler.go
@@ -53,18 +53,14 @@ func (h *Handler) PostLogin(ctx context.Context, request PostLoginRequestObject)
msg = "ユーザー名またはパスワードが誤っています"
}
return PostLogin401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: msg,
- },
+ Message: msg,
}, nil
}
dbUser, err := h.q.GetUserByID(ctx, int32(userID))
if err != nil {
return PostLogin401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "ログインに失敗しました",
- },
+ Message: "ログインに失敗しました",
}, nil
}
@@ -100,9 +96,7 @@ func (h *Handler) GetMe(ctx context.Context, _ GetMeRequestObject, claims *auth.
dbUser, err := h.q.GetUserByID(ctx, int32(claims.UserID))
if err != nil {
return GetMe401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return GetMe200JSONResponse{
@@ -157,7 +151,7 @@ func (h *Handler) GetGames(ctx context.Context, _ GetGamesRequestObject, _ *auth
}
games[i] = Game{
GameID: int(row.GameID),
- GameType: GameGameType(row.GameType),
+ GameType: GameType(row.GameType),
IsPublic: row.IsPublic,
DisplayName: row.DisplayName,
DurationSeconds: int(row.DurationSeconds),
@@ -200,18 +194,14 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return GetGame404JSONResponse{
- NotFoundJSONResponse: NotFoundJSONResponse{
- Message: "Game not found",
- },
+ Message: "Game not found",
}, nil
}
return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error())
}
if !row.IsPublic && !user.IsAdmin {
return GetGame404JSONResponse{
- NotFoundJSONResponse: NotFoundJSONResponse{
- Message: "Game not found",
- },
+ Message: "Game not found",
}, nil
}
var startedAt *int64
@@ -236,7 +226,7 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use
}
game := Game{
GameID: int(row.GameID),
- GameType: GameGameType(row.GameType),
+ GameType: GameType(row.GameType),
IsPublic: row.IsPublic,
DisplayName: row.DisplayName,
DurationSeconds: int(row.DurationSeconds),
@@ -312,9 +302,7 @@ func (h *Handler) GetGameWatchLatestStates(ctx context.Context, request GetGameW
if int(row.UserID) == user.UserID && !user.IsAdmin {
return GetGameWatchLatestStates403JSONResponse{
- ForbiddenJSONResponse: ForbiddenJSONResponse{
- Message: "You are one of the main players of this game",
- },
+ Message: "You are one of the main players of this game",
}, nil
}
}
diff --git a/backend/api/handler_wrapper.go b/backend/api/handler_wrapper.go
index b88ddb2..5feaac7 100644
--- a/backend/api/handler_wrapper.go
+++ b/backend/api/handler_wrapper.go
@@ -29,9 +29,7 @@ func (h *HandlerWrapper) GetGame(ctx context.Context, request GetGameRequestObje
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return GetGame401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.GetGame(ctx, request, user)
@@ -41,9 +39,7 @@ func (h *HandlerWrapper) GetGamePlayLatestState(ctx context.Context, request Get
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return GetGamePlayLatestState401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.GetGamePlayLatestState(ctx, request, user)
@@ -53,9 +49,7 @@ func (h *HandlerWrapper) GetGameWatchLatestStates(ctx context.Context, request G
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return GetGameWatchLatestStates401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.GetGameWatchLatestStates(ctx, request, user)
@@ -65,9 +59,7 @@ func (h *HandlerWrapper) GetGameWatchRanking(ctx context.Context, request GetGam
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return GetGameWatchRanking401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.GetGameWatchRanking(ctx, request, user)
@@ -77,9 +69,7 @@ func (h *HandlerWrapper) GetGames(ctx context.Context, request GetGamesRequestOb
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return GetGames401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.GetGames(ctx, request, user)
@@ -89,9 +79,7 @@ func (h *HandlerWrapper) GetMe(ctx context.Context, request GetMeRequestObject)
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return GetMe401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.GetMe(ctx, request, user)
@@ -101,9 +89,7 @@ func (h *HandlerWrapper) GetTournament(ctx context.Context, request GetTournamen
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return GetTournament401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.GetTournament(ctx, request, user)
@@ -113,9 +99,7 @@ func (h *HandlerWrapper) PostGamePlayCode(ctx context.Context, request PostGameP
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return PostGamePlayCode401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.PostGamePlayCode(ctx, request, user)
@@ -125,9 +109,7 @@ func (h *HandlerWrapper) PostGamePlaySubmit(ctx context.Context, request PostGam
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return PostGamePlaySubmit401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.PostGamePlaySubmit(ctx, request, user)
@@ -141,9 +123,7 @@ func (h *HandlerWrapper) PostLogout(ctx context.Context, request PostLogoutReque
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return PostLogout401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
return h.impl.PostLogout(ctx, request, user)
diff --git a/backend/gen/api/handler_wrapper_gen.go b/backend/gen/api/handler_wrapper_gen.go
index 5a5ce2d..c6e3e8a 100644
--- a/backend/gen/api/handler_wrapper_gen.go
+++ b/backend/gen/api/handler_wrapper_gen.go
@@ -131,17 +131,13 @@ func NewHandler(queries *db.Queries, hub GameHubInterface, conf *config.Config)
user, ok := GetJWTClaimsFromContext(ctx)
if !ok {
return {{ .Name }}401JSONResponse{
- UnauthorizedJSONResponse: UnauthorizedJSONResponse{
- Message: "Unauthorized",
- },
+ Message: "Unauthorized",
}, nil
}
{{ if .RequiresAdminRole -}}
if !user.IsAdmin {
return {{ .Name }}403JSONResponse{
- ForbiddenJSONResponse: ForbiddenJSONResponse{
- Message: "Forbidden",
- },
+ Message: "Forbidden",
}, nil
}
{{ end -}}