From a70e2e32d04ba146715d0337ad92c69cf8aa7bf9 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 5 Jan 2023 23:43:25 +0100 Subject: [PATCH] added swagger doc for get avatar --- routers/routes/v1/user/useravatar.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/routers/routes/v1/user/useravatar.go b/routers/routes/v1/user/useravatar.go index 382f329..b01f597 100644 --- a/routers/routes/v1/user/useravatar.go +++ b/routers/routes/v1/user/useravatar.go @@ -11,11 +11,26 @@ import ( ) func GetAvatar(c *fiber.Ctx) error { + // swagger:operation GET /avatars/:userId/:fileName?size= user userGetAvatar + // --- + // summary: Get avatar from a user + // consumes: + // - application/json + // produces: + // - application/json + // responses: + // '200': + // description: Avatar from user + // '400': + // description: Avatar does not exist + // '422': + // description: Invalid userId or fileName + userId := c.Params("userId") if len(userId) != structs.LenUserId { logrus.Debugln("UserId is longer than allowed") - return c.SendStatus(fiber.StatusBadRequest) + return c.SendStatus(fiber.StatusUnprocessableEntity) } fileName := c.Params("fileName") @@ -23,7 +38,7 @@ func GetAvatar(c *fiber.Ctx) error { // check if the filename length has not been manipulated by the user if len(fileName) > image.MaxFileNameLen { logrus.Debugln("Filename is longer than allowed") - return c.SendStatus(fiber.StatusBadRequest) + return c.SendStatus(fiber.StatusUnprocessableEntity) } // image resolution