aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--backend/api/generated.go149
-rw-r--r--backend/api/handler_wrapper.go44
-rw-r--r--backend/api/handlers.go24
-rw-r--r--backend/gen/api_handler_wrapper_gen.go8
-rw-r--r--frontend/app/.server/api/schema.d.ts277
-rw-r--r--openapi.yaml249
6 files changed, 237 insertions, 514 deletions
diff --git a/backend/api/generated.go b/backend/api/generated.go
index 47dd905..a643833 100644
--- a/backend/api/generated.go
+++ b/backend/api/generated.go
@@ -54,6 +54,11 @@ const (
AdminPutGameJSONBodyStateWaitingStart AdminPutGameJSONBodyState = "waiting_start"
)
+// Error defines model for Error.
+type Error struct {
+ Message string `json:"message"`
+}
+
// Game defines model for Game.
type Game struct {
DisplayName string `json:"display_name"`
@@ -213,6 +218,18 @@ type HeaderAuthorization = string
// 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
+
// AdminGetGamesParams defines parameters for AdminGetGames.
type AdminGetGamesParams struct {
Authorization HeaderAuthorization `json:"Authorization"`
@@ -953,6 +970,14 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL
}
+type BadRequestJSONResponse Error
+
+type ForbiddenJSONResponse Error
+
+type NotFoundJSONResponse Error
+
+type UnauthorizedJSONResponse Error
+
type AdminGetGamesRequestObject struct {
Params AdminGetGamesParams
}
@@ -972,9 +997,7 @@ func (response AdminGetGames200JSONResponse) VisitAdminGetGamesResponse(w http.R
return json.NewEncoder(w).Encode(response)
}
-type AdminGetGames401JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminGetGames401JSONResponse struct{ UnauthorizedJSONResponse }
func (response AdminGetGames401JSONResponse) VisitAdminGetGamesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -983,9 +1006,7 @@ func (response AdminGetGames401JSONResponse) VisitAdminGetGamesResponse(w http.R
return json.NewEncoder(w).Encode(response)
}
-type AdminGetGames403JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminGetGames403JSONResponse struct{ ForbiddenJSONResponse }
func (response AdminGetGames403JSONResponse) VisitAdminGetGamesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1014,9 +1035,7 @@ func (response AdminGetGame200JSONResponse) VisitAdminGetGameResponse(w http.Res
return json.NewEncoder(w).Encode(response)
}
-type AdminGetGame401JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminGetGame401JSONResponse struct{ UnauthorizedJSONResponse }
func (response AdminGetGame401JSONResponse) VisitAdminGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1025,9 +1044,7 @@ func (response AdminGetGame401JSONResponse) VisitAdminGetGameResponse(w http.Res
return json.NewEncoder(w).Encode(response)
}
-type AdminGetGame403JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminGetGame403JSONResponse struct{ ForbiddenJSONResponse }
func (response AdminGetGame403JSONResponse) VisitAdminGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1036,9 +1053,7 @@ func (response AdminGetGame403JSONResponse) VisitAdminGetGameResponse(w http.Res
return json.NewEncoder(w).Encode(response)
}
-type AdminGetGame404JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminGetGame404JSONResponse struct{ NotFoundJSONResponse }
func (response AdminGetGame404JSONResponse) VisitAdminGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1065,9 +1080,7 @@ func (response AdminPutGame204Response) VisitAdminPutGameResponse(w http.Respons
return nil
}
-type AdminPutGame400JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminPutGame400JSONResponse struct{ BadRequestJSONResponse }
func (response AdminPutGame400JSONResponse) VisitAdminPutGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1076,9 +1089,7 @@ func (response AdminPutGame400JSONResponse) VisitAdminPutGameResponse(w http.Res
return json.NewEncoder(w).Encode(response)
}
-type AdminPutGame401JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminPutGame401JSONResponse struct{ UnauthorizedJSONResponse }
func (response AdminPutGame401JSONResponse) VisitAdminPutGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1087,9 +1098,7 @@ func (response AdminPutGame401JSONResponse) VisitAdminPutGameResponse(w http.Res
return json.NewEncoder(w).Encode(response)
}
-type AdminPutGame403JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminPutGame403JSONResponse struct{ ForbiddenJSONResponse }
func (response AdminPutGame403JSONResponse) VisitAdminPutGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1098,9 +1107,7 @@ func (response AdminPutGame403JSONResponse) VisitAdminPutGameResponse(w http.Res
return json.NewEncoder(w).Encode(response)
}
-type AdminPutGame404JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminPutGame404JSONResponse struct{ NotFoundJSONResponse }
func (response AdminPutGame404JSONResponse) VisitAdminPutGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1128,9 +1135,7 @@ func (response AdminGetUsers200JSONResponse) VisitAdminGetUsersResponse(w http.R
return json.NewEncoder(w).Encode(response)
}
-type AdminGetUsers401JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminGetUsers401JSONResponse struct{ UnauthorizedJSONResponse }
func (response AdminGetUsers401JSONResponse) VisitAdminGetUsersResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1139,9 +1144,7 @@ func (response AdminGetUsers401JSONResponse) VisitAdminGetUsersResponse(w http.R
return json.NewEncoder(w).Encode(response)
}
-type AdminGetUsers403JSONResponse struct {
- Message string `json:"message"`
-}
+type AdminGetUsers403JSONResponse struct{ ForbiddenJSONResponse }
func (response AdminGetUsers403JSONResponse) VisitAdminGetUsersResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1169,9 +1172,7 @@ func (response GetGames200JSONResponse) VisitGetGamesResponse(w http.ResponseWri
return json.NewEncoder(w).Encode(response)
}
-type GetGames401JSONResponse struct {
- Message string `json:"message"`
-}
+type GetGames401JSONResponse struct{ UnauthorizedJSONResponse }
func (response GetGames401JSONResponse) VisitGetGamesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1180,9 +1181,7 @@ func (response GetGames401JSONResponse) VisitGetGamesResponse(w http.ResponseWri
return json.NewEncoder(w).Encode(response)
}
-type GetGames403JSONResponse struct {
- Message string `json:"message"`
-}
+type GetGames403JSONResponse struct{ ForbiddenJSONResponse }
func (response GetGames403JSONResponse) VisitGetGamesResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1211,9 +1210,7 @@ func (response GetGame200JSONResponse) VisitGetGameResponse(w http.ResponseWrite
return json.NewEncoder(w).Encode(response)
}
-type GetGame401JSONResponse struct {
- Message string `json:"message"`
-}
+type GetGame401JSONResponse struct{ UnauthorizedJSONResponse }
func (response GetGame401JSONResponse) VisitGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1222,9 +1219,7 @@ func (response GetGame401JSONResponse) VisitGetGameResponse(w http.ResponseWrite
return json.NewEncoder(w).Encode(response)
}
-type GetGame403JSONResponse struct {
- Message string `json:"message"`
-}
+type GetGame403JSONResponse struct{ ForbiddenJSONResponse }
func (response GetGame403JSONResponse) VisitGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1233,9 +1228,7 @@ func (response GetGame403JSONResponse) VisitGetGameResponse(w http.ResponseWrite
return json.NewEncoder(w).Encode(response)
}
-type GetGame404JSONResponse struct {
- Message string `json:"message"`
-}
+type GetGame404JSONResponse struct{ NotFoundJSONResponse }
func (response GetGame404JSONResponse) VisitGetGameResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1263,9 +1256,7 @@ func (response PostLogin200JSONResponse) VisitPostLoginResponse(w http.ResponseW
return json.NewEncoder(w).Encode(response)
}
-type PostLogin401JSONResponse struct {
- Message string `json:"message"`
-}
+type PostLogin401JSONResponse struct{ UnauthorizedJSONResponse }
func (response PostLogin401JSONResponse) VisitPostLoginResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1293,9 +1284,7 @@ func (response GetToken200JSONResponse) VisitGetTokenResponse(w http.ResponseWri
return json.NewEncoder(w).Encode(response)
}
-type GetToken401JSONResponse struct {
- Message string `json:"message"`
-}
+type GetToken401JSONResponse struct{ UnauthorizedJSONResponse }
func (response GetToken401JSONResponse) VisitGetTokenResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
@@ -1560,32 +1549,32 @@ func (sh *strictHandler) GetToken(ctx echo.Context, params GetTokenParams) error
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
- "H4sIAAAAAAAC/+xZbW/bthP/KvrzP6AboMUPCYrO77Ksyzp0m9E02IsiMGjpbDOjSJWkmniBvvtAUg+W",
- "Rdu0oybZ4L4oYvHu+LtH3pEPKOJJyhkwJdHoAaVY4AQUCPNrATgGMcGZWnBB/saKcKa/E4ZGxSIKEcMJ",
- "oBE6b1CFSMDnjAiI0UiJDEIkowUkWLOrZaoZpBKEzVGehyjFajGZ4wQmJK420B9r8eWqh2DCFMxBoFyL",
- "tqtGnUsj6QGlgqcgFAHzNSYypXg5YcUq3OMkpVqOpg8GKFwHHKI4E0bNiYSIs1g2+E5f98MWlBCtqFeR",
- "DlyEqeBTCokm/EbADI3Q/3u1l3qFQr1xQaZ1VFgoiCdYNaT/cPb69ZuzN30nHKmwsvqyLEGjTyiiXIK2",
- "7x0mirD5BJgS2kb1F7MP0gghxQJQsbM2itHP/jEjjMgFxOgmXDFmJb7t/dqhn1bcbAGGTf84TH9TieTT",
-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4IGqOTo+HREJmxuQ7RQNsdLHBqQrYAnRQqinp89SpW9tSeC5AX",
+ "eldozfq39EbNloHzXUBxvTFgHw2He017babV+ImEVPhcXM3dhDDneOWc8IktAbFnyK+JkAGbB0aiCNHp",
+ "8HgbhPrMA3vyrIROuoXWBvSqpuRpivmqglDaL0IrqoNP5ayy8IpvT+ENO+WsNzefgQ5+JHAE3SvmZ9rb",
+ "DxZsJXHaLVG/srHZcQEywDXgLN9GgUn+xSmg3548Z2Z8d2D0H+pNyfaS7NV4drwK8WteH8mrEUe+2C9b",
+ "i1Z+n7Z6InRp2ux5niSrIM9iLKtsGXZzf+0N7deRlVf6gHViNte26hO6i/GV3vUYi3GN36sY69axqxgb",
+ "lfsUYyPx5YoxTpIKg4rs7gbrW2/1FfVWvl3Vt4bqf9FQKUokbGF+dGZMOJgwYUK+1lv6anEyLMQt4/HG",
+ "WLN8ejw6cfU49/wRSysyl6avDyr792GhZH/DxuzkTv0drf3vHidpJT6UtNoRRTegUkGtGLc3Te3yL4AH",
+ "hjiaQ/Xhtl0m7/SGx1gh/lNxMbktlozLnxPyEeIAa3OBAVgURfFvAAAA//89QklP/CgAAA==",
}
// GetSwagger returns the content of the embedded swagger specification file
diff --git a/backend/api/handler_wrapper.go b/backend/api/handler_wrapper.go
index 37a199b..939e37a 100644
--- a/backend/api/handler_wrapper.go
+++ b/backend/api/handler_wrapper.go
@@ -43,12 +43,16 @@ func (h *ApiHandlerWrapper) AdminGetGame(ctx context.Context, request AdminGetGa
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return AdminGetGame401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
if !user.IsAdmin {
return AdminGetGame403JSONResponse{
- Message: "Forbidden",
+ ForbiddenJSONResponse: ForbiddenJSONResponse{
+ Message: "Forbidden",
+ },
}, nil
}
return h.innerHandler.AdminGetGame(ctx, request, user)
@@ -58,12 +62,16 @@ func (h *ApiHandlerWrapper) AdminGetGames(ctx context.Context, request AdminGetG
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return AdminGetGames401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
if !user.IsAdmin {
return AdminGetGames403JSONResponse{
- Message: "Forbidden",
+ ForbiddenJSONResponse: ForbiddenJSONResponse{
+ Message: "Forbidden",
+ },
}, nil
}
return h.innerHandler.AdminGetGames(ctx, request, user)
@@ -73,12 +81,16 @@ func (h *ApiHandlerWrapper) AdminGetUsers(ctx context.Context, request AdminGetU
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return AdminGetUsers401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
if !user.IsAdmin {
return AdminGetUsers403JSONResponse{
- Message: "Forbidden",
+ ForbiddenJSONResponse: ForbiddenJSONResponse{
+ Message: "Forbidden",
+ },
}, nil
}
return h.innerHandler.AdminGetUsers(ctx, request, user)
@@ -88,12 +100,16 @@ func (h *ApiHandlerWrapper) AdminPutGame(ctx context.Context, request AdminPutGa
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return AdminPutGame401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
if !user.IsAdmin {
return AdminPutGame403JSONResponse{
- Message: "Forbidden",
+ ForbiddenJSONResponse: ForbiddenJSONResponse{
+ Message: "Forbidden",
+ },
}, nil
}
return h.innerHandler.AdminPutGame(ctx, request, user)
@@ -103,7 +119,9 @@ func (h *ApiHandlerWrapper) GetGame(ctx context.Context, request GetGameRequestO
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return GetGame401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
return h.innerHandler.GetGame(ctx, request, user)
@@ -113,7 +131,9 @@ func (h *ApiHandlerWrapper) GetGames(ctx context.Context, request GetGamesReques
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return GetGames401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
return h.innerHandler.GetGames(ctx, request, user)
@@ -123,7 +143,9 @@ func (h *ApiHandlerWrapper) GetToken(ctx context.Context, request GetTokenReques
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return GetToken401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
return h.innerHandler.GetToken(ctx, request, user)
diff --git a/backend/api/handlers.go b/backend/api/handlers.go
index 26f7a7d..35fc9f7 100644
--- a/backend/api/handlers.go
+++ b/backend/api/handlers.go
@@ -66,7 +66,9 @@ func (h *ApiHandler) AdminGetGame(ctx context.Context, request AdminGetGameReque
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return AdminGetGame404JSONResponse{
- Message: "Game not found",
+ NotFoundJSONResponse: NotFoundJSONResponse{
+ Message: "Game not found",
+ },
}, nil
} else {
return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error())
@@ -113,7 +115,9 @@ func (h *ApiHandler) AdminPutGame(ctx context.Context, request AdminPutGameReque
if err != nil {
if err == pgx.ErrNoRows {
return AdminPutGame404JSONResponse{
- Message: "Game not found",
+ NotFoundJSONResponse: NotFoundJSONResponse{
+ Message: "Game not found",
+ },
}, nil
} else {
return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error())
@@ -175,7 +179,9 @@ func (h *ApiHandler) AdminPutGame(ctx context.Context, request AdminPutGameReque
})
if err != nil {
return AdminPutGame400JSONResponse{
- Message: err.Error(),
+ BadRequestJSONResponse: BadRequestJSONResponse{
+ Message: err.Error(),
+ },
}, nil
}
@@ -208,14 +214,18 @@ func (h *ApiHandler) PostLogin(ctx context.Context, request PostLoginRequestObje
userID, err := auth.Login(ctx, h.q, username, password)
if err != nil {
return PostLogin401JSONResponse{
- Message: "Invalid username or password",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Invalid username or password",
+ },
}, nil
}
user, err := h.q.GetUserById(ctx, int32(userID))
if err != nil {
return PostLogin401JSONResponse{
- Message: "Invalid username or password",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Invalid username or password",
+ },
}, nil
}
@@ -283,7 +293,9 @@ func (h *ApiHandler) GetGame(ctx context.Context, request GetGameRequestObject,
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return GetGame404JSONResponse{
- Message: "Game not found",
+ NotFoundJSONResponse: NotFoundJSONResponse{
+ Message: "Game not found",
+ },
}, nil
} else {
return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error())
diff --git a/backend/gen/api_handler_wrapper_gen.go b/backend/gen/api_handler_wrapper_gen.go
index 01d05bf..7fd34b2 100644
--- a/backend/gen/api_handler_wrapper_gen.go
+++ b/backend/gen/api_handler_wrapper_gen.go
@@ -145,13 +145,17 @@ func parseJWTClaimsFromAuthorizationHeader(authorization string) (*auth.JWTClaim
user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization)
if err != nil {
return {{ .Name }}401JSONResponse{
- Message: "Unauthorized",
+ UnauthorizedJSONResponse: UnauthorizedJSONResponse{
+ Message: "Unauthorized",
+ },
}, nil
}
{{ if .RequiresAdminRole -}}
if !user.IsAdmin {
return {{ .Name }}403JSONResponse{
- Message: "Forbidden",
+ ForbiddenJSONResponse: ForbiddenJSONResponse{
+ Message: "Forbidden",
+ },
}, nil
}
{{ end -}}
diff --git a/frontend/app/.server/api/schema.d.ts b/frontend/app/.server/api/schema.d.ts
index 37e9b8c..6198064 100644
--- a/frontend/app/.server/api/schema.d.ts
+++ b/frontend/app/.server/api/schema.d.ts
@@ -128,6 +128,10 @@ export interface paths {
export type webhooks = Record<string, never>;
export interface components {
schemas: {
+ Error: {
+ /** @example Invalid request */
+ message: string;
+ };
User: {
/** @example 123 */
user_id: number;
@@ -258,7 +262,44 @@ export interface components {
stderr: string;
};
};
- responses: never;
+ responses: {
+ /** @description Bad request */
+ BadRequest: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["Error"];
+ };
+ };
+ /** @description Unauthorized */
+ Unauthorized: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["Error"];
+ };
+ };
+ /** @description Forbidden */
+ Forbidden: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["Error"];
+ };
+ };
+ /** @description Not found */
+ NotFound: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["Error"];
+ };
+ };
+ };
parameters: {
header_authorization: string;
path_game_id: number;
@@ -299,18 +340,7 @@ export interface operations {
};
};
};
- /** @description Invalid username or password */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Invalid credentials */
- message: string;
- };
- };
- };
+ 401: components["responses"]["Unauthorized"];
};
};
getToken: {
@@ -336,18 +366,7 @@ export interface operations {
};
};
};
- /** @description Unauthorized */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Unauthorized */
- message: string;
- };
- };
- };
+ 401: components["responses"]["Unauthorized"];
};
};
getGames: {
@@ -372,30 +391,8 @@ export interface operations {
};
};
};
- /** @description Unauthorized */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Unauthorized */
- message: string;
- };
- };
- };
- /** @description Forbidden */
- 403: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Forbidden operation */
- message: string;
- };
- };
- };
+ 401: components["responses"]["Unauthorized"];
+ 403: components["responses"]["Forbidden"];
};
};
getGame: {
@@ -422,42 +419,9 @@ export interface operations {
};
};
};
- /** @description Unauthorized */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Unauthorized */
- message: string;
- };
- };
- };
- /** @description Forbidden */
- 403: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Forbidden operation */
- message: string;
- };
- };
- };
- /** @description Not found */
- 404: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Not found */
- message: string;
- };
- };
- };
+ 401: components["responses"]["Unauthorized"];
+ 403: components["responses"]["Forbidden"];
+ 404: components["responses"]["NotFound"];
};
};
adminGetUsers: {
@@ -482,30 +446,8 @@ export interface operations {
};
};
};
- /** @description Unauthorized */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Unauthorized */
- message: string;
- };
- };
- };
- /** @description Forbidden */
- 403: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Forbidden operation */
- message: string;
- };
- };
- };
+ 401: components["responses"]["Unauthorized"];
+ 403: components["responses"]["Forbidden"];
};
};
adminGetGames: {
@@ -530,30 +472,8 @@ export interface operations {
};
};
};
- /** @description Unauthorized */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Unauthorized */
- message: string;
- };
- };
- };
- /** @description Forbidden */
- 403: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Forbidden operation */
- message: string;
- };
- };
- };
+ 401: components["responses"]["Unauthorized"];
+ 403: components["responses"]["Forbidden"];
};
};
adminGetGame: {
@@ -580,42 +500,9 @@ export interface operations {
};
};
};
- /** @description Unauthorized */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Unauthorized */
- message: string;
- };
- };
- };
- /** @description Forbidden */
- 403: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Forbidden operation */
- message: string;
- };
- };
- };
- /** @description Not found */
- 404: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Not found */
- message: string;
- };
- };
- };
+ 401: components["responses"]["Unauthorized"];
+ 403: components["responses"]["Forbidden"];
+ 404: components["responses"]["NotFound"];
};
};
adminPutGame: {
@@ -656,54 +543,10 @@ export interface operations {
};
content?: never;
};
- /** @description Invalid request */
- 400: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Invalid request */
- message: string;
- };
- };
- };
- /** @description Unauthorized */
- 401: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Unauthorized */
- message: string;
- };
- };
- };
- /** @description Forbidden */
- 403: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Forbidden operation */
- message: string;
- };
- };
- };
- /** @description Not found */
- 404: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": {
- /** @example Not found */
- message: string;
- };
- };
- };
+ 400: components["responses"]["BadRequest"];
+ 401: components["responses"]["Unauthorized"];
+ 403: components["responses"]["Forbidden"];
+ 404: components["responses"]["NotFound"];
};
};
}
diff --git a/openapi.yaml b/openapi.yaml
index 1dd4614..683fadf 100644
--- a/openapi.yaml
+++ b/openapi.yaml
@@ -37,17 +37,7 @@ paths:
required:
- token
'401':
- description: Invalid username or password
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Invalid credentials"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
/token:
get:
operationId: getToken
@@ -68,17 +58,7 @@ paths:
required:
- token
'401':
- description: Unauthorized
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Unauthorized"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
/games:
get:
operationId: getGames
@@ -100,29 +80,9 @@ paths:
required:
- games
'401':
- description: Unauthorized
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Unauthorized"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
'403':
- description: Forbidden
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Forbidden operation"
- required:
- - message
+ $ref: '#/components/responses/Forbidden'
/games/{game_id}:
get:
operationId: getGame
@@ -143,41 +103,11 @@ paths:
required:
- game
'401':
- description: Unauthorized
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Unauthorized"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
'403':
- description: Forbidden
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Forbidden operation"
- required:
- - message
+ $ref: '#/components/responses/Forbidden'
'404':
- description: Not found
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Not found"
- required:
- - message
+ $ref: '#/components/responses/NotFound'
/admin/users:
get:
operationId: adminGetUsers
@@ -199,29 +129,9 @@ paths:
required:
- users
'401':
- description: Unauthorized
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Unauthorized"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
'403':
- description: Forbidden
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Forbidden operation"
- required:
- - message
+ $ref: '#/components/responses/Forbidden'
/admin/games:
get:
operationId: adminGetGames
@@ -243,29 +153,9 @@ paths:
required:
- games
'401':
- description: Unauthorized
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Unauthorized"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
'403':
- description: Forbidden
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Forbidden operation"
- required:
- - message
+ $ref: '#/components/responses/Forbidden'
/admin/games/{game_id}:
get:
operationId: adminGetGame
@@ -286,41 +176,11 @@ paths:
required:
- game
'401':
- description: Unauthorized
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Unauthorized"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
'403':
- description: Forbidden
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Forbidden operation"
- required:
- - message
+ $ref: '#/components/responses/Forbidden'
'404':
- description: Not found
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Not found"
- required:
- - message
+ $ref: '#/components/responses/NotFound'
put:
operationId: adminPutGame
summary: Update a game
@@ -363,53 +223,13 @@ paths:
'204':
description: Successfully updated
'400':
- description: Invalid request
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Invalid request"
- required:
- - message
+ $ref: '#/components/responses/BadRequest'
'401':
- description: Unauthorized
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Unauthorized"
- required:
- - message
+ $ref: '#/components/responses/Unauthorized'
'403':
- description: Forbidden
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Forbidden operation"
- required:
- - message
+ $ref: '#/components/responses/Forbidden'
'404':
- description: Not found
- content:
- application/json:
- schema:
- type: object
- properties:
- message:
- type: string
- example: "Not found"
- required:
- - message
+ $ref: '#/components/responses/NotFound'
components:
parameters:
header_authorization:
@@ -424,7 +244,40 @@ components:
schema:
type: integer
required: true
+ responses:
+ BadRequest:
+ description: Bad request
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Error'
+ Unauthorized:
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Error'
+ Forbidden:
+ description: Forbidden
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Error'
+ NotFound:
+ description: Not found
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Error'
schemas:
+ Error:
+ type: object
+ properties:
+ message:
+ type: string
+ example: "Invalid request"
+ required:
+ - message
User:
type: object
properties: