{ "swagger": "2.0", "info": { "description": "This is a sample server celler server.", "title": "API Docs", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "url": "http://www.swagger.io/support", "email": "support@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "host": "localhost:8080", "basePath": "/api", "paths": { "/api/exercise": { "get": { "description": "Returns a paginated list of exercises", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Exercises" ], "summary": "Get all exercises", "parameters": [ { "type": "integer", "description": "Page number (default: 1)", "name": "page", "in": "query" } ], "responses": { "200": { "description": "List of exercises", "schema": { "$ref": "#/definitions/documentModel.ListExerciseResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/forum/:id": { "delete": { "description": "Admin can Delete forum base on its id", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Delete a forum base on its id", "parameters": [ { "type": "integer", "description": "Forum id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "Forum", "schema": { "$ref": "#/definitions/documentModel.DeleteForumResponse" } }, "400": { "description": "Bad Request - validation error", "schema": { "$ref": "#/definitions/documentModel.ErrorBadRequest" } }, "404": { "description": "Not Found - forum not found", "schema": { "$ref": "#/definitions/documentModel.ErrorNotFound" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/forum/create": { "post": { "description": "Admin can make a new forum", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Create forum by admin", "parameters": [ { "description": "Forum details", "name": "user", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.CreateForumRequest" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/documentModel.ResponseForum" } }, "400": { "description": "Bad Request - validation error", "schema": { "$ref": "#/definitions/documentModel.ErrorBadRequest" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/forum/update": { "put": { "description": "Admin can update forum base on its id", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Update a forum base on its id", "parameters": [ { "description": "Forum details", "name": "forum", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.UpdateForumRequest" } } ], "responses": { "200": { "description": "Forum", "schema": { "$ref": "#/definitions/documentModel.UpdateForumResponse" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/forum/{forum_id}/posts": { "get": { "description": "Get all posts in forum by forum id", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Get all posts in forum", "parameters": [ { "type": "integer", "description": "Forum ID", "name": "forum_id", "in": "path", "required": true }, { "type": "integer", "description": "Page number (default: 1)", "name": "page", "in": "query" } ], "responses": { "200": { "description": "The result", "schema": { "$ref": "#/definitions/documentModel.ListPostForumResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/documentModel.ErrorBadRequest" } }, "404": { "description": "Forum or user not found", "schema": { "$ref": "#/definitions/documentModel.ErrorNotFound" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/forums": { "get": { "description": "Allows users to fetch a paginated list of forums. Pagination is controlled using the `page` query parameter.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Get a paginated list of forums from the database 'api/forums?page=1", "parameters": [ { "type": "integer", "example": 1, "description": "Page number to fetch forums", "name": "page", "in": "query", "required": true } ], "responses": { "200": { "description": "List Forum", "schema": { "$ref": "#/definitions/documentModel.ResponseListForum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/forums/{forum_id}/posts": { "post": { "description": "Create a new post in a specific forum with optional images", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Create a post", "parameters": [ { "type": "integer", "description": "Forum ID", "name": "forum_id", "in": "path", "required": true }, { "description": "Post data", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.CreatePostRequest" } } ], "responses": { "200": { "description": "The result", "schema": { "$ref": "#/definitions/documentModel.ForumPostResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/documentModel.ErrorBadRequest" } }, "404": { "description": "Forum or user not found", "schema": { "$ref": "#/definitions/documentModel.ErrorNotFound" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/login": { "post": { "description": "Login using email and password", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Accounts" ], "summary": "Login using email and password", "parameters": [ { "description": "The login credentials", "name": "login", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.UserLoginRequest" } } ], "responses": { "200": { "description": "Successful login response with Paseto", "schema": { "$ref": "#/definitions/documentModel.LoginResponse" } }, "400": { "description": "Bad Request - validation error", "schema": { "$ref": "#/definitions/documentModel.ErrorAuth" } }, "401": { "description": "Unauthorized - wrong email or password", "schema": { "$ref": "#/definitions/documentModel.ErrorAuth" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/documentModel.ErrorToken" } } } } }, "/api/post/{post_id}/comments": { "get": { "description": "Get comment in posts", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Get comments in post", "parameters": [ { "type": "integer", "description": "Post ID", "name": "post_id", "in": "path", "required": true }, { "type": "integer", "description": "Page number (default: 1)", "name": "page", "in": "query" } ], "responses": { "200": { "description": "The result", "schema": { "$ref": "#/definitions/documentModel.ListPostForumResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/documentModel.ErrorBadRequest" } }, "404": { "description": "Forum or user not found", "schema": { "$ref": "#/definitions/documentModel.ErrorNotFound" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/posts/{post_id}/comments": { "post": { "description": "Create a new Comment in a specific post with optional images", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Forums" ], "summary": "Create a Comment", "parameters": [ { "type": "integer", "description": "Post ID", "name": "forum_id", "in": "path", "required": true }, { "description": "Post data", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.CreateCommentRequest" } } ], "responses": { "200": { "description": "The result", "schema": { "$ref": "#/definitions/documentModel.ForumCommentResponse" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/documentModel.ErrorBadRequest" } }, "404": { "description": "Forum or user not found", "schema": { "$ref": "#/definitions/documentModel.ErrorNotFound" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } }, "/api/user_info": { "get": { "security": [ { "BearerAuth": [] } ], "description": "Retrieves information about the currently authorized user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Accounts" ], "summary": "Get user information", "responses": { "200": { "description": "User information retrieved successfully", "schema": { "$ref": "#/definitions/documentModel.UserPayload" } }, "401": { "description": "Unauthorized - User not logged in", "schema": { "$ref": "#/definitions/documentModel.ErrorUnauthorized" } } } } }, "/api/users/{id}": { "post": { "security": [ { "BearerAuth": [] } ], "description": "Allows authorized users or admins to update user information", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Accounts" ], "summary": "Update user information", "parameters": [ { "type": "integer", "description": "ID of the user to update", "name": "id", "in": "path", "required": true }, { "description": "Updated user information", "name": "user", "in": "body", "required": true, "schema": { "$ref": "#/definitions/api.UpdateUserRequest" } } ], "responses": { "200": { "description": "User updated successfully", "schema": { "$ref": "#/definitions/api.ResponseAPI" } }, "400": { "description": "Bad Request - Invalid update payload", "schema": { "$ref": "#/definitions/documentModel.ErrorGoal" } }, "401": { "description": "Unauthorized - User not authorized to update", "schema": { "$ref": "#/definitions/documentModel.ErrorUnauthorized" } }, "500": { "description": "Internal Server Error - Database or other failure", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } }, "delete": { "security": [ { "BearerAuth": [] } ], "description": "Deletes the user with the given ID if authorized", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Accounts" ], "summary": "Delete a user", "parameters": [ { "type": "integer", "description": "ID of the user to delete", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "User deleted successfully", "schema": { "$ref": "#/definitions/api.ResponseAPI" } }, "401": { "description": "Unauthorized - User not authorized to delete", "schema": { "$ref": "#/definitions/documentModel.ErrorUnauthorized" } }, "500": { "description": "Internal Server Error - Database or other failure", "schema": { "$ref": "#/definitions/documentModel.ErrorServer" } } } } } }, "definitions": { "api.CreateCommentRequest": { "type": "object", "required": [ "content", "user_id" ], "properties": { "content": { "type": "string" }, "images": { "type": "array", "items": { "type": "string" } }, "user_id": { "type": "integer" } } }, "api.CreateForumRequest": { "type": "object", "required": [ "name" ], "properties": { "description": { "type": "string", "example": "This is a basketball forum" }, "name": { "type": "string", "example": "Basketball" } } }, "api.CreatePostRequest": { "type": "object", "required": [ "content", "title", "user_id" ], "properties": { "content": { "type": "string" }, "images": { "type": "array", "items": { "type": "string" } }, "title": { "type": "string" }, "user_id": { "type": "integer" } } }, "api.ResponseAPI": { "type": "object", "properties": { "data": { "type": "object", "additionalProperties": true }, "message": { "type": "string" }, "success": { "type": "boolean" } } }, "api.UpdateForumRequest": { "type": "object", "required": [ "id", "name" ], "properties": { "description": { "type": "string", "example": "changes goes here" }, "id": { "type": "integer", "example": 1 }, "name": { "type": "string", "example": "Basketball" } } }, "api.UpdateUserRequest": { "type": "object", "properties": { "date_of_birth": { "type": "string" }, "first_name": { "type": "string" }, "gender": { "type": "string" }, "goals": { "type": "array", "items": { "$ref": "#/definitions/db.UserGoal" } }, "height_cm": { "type": "number" }, "last_name": { "type": "string" }, "location": { "type": "string" }, "weight_kg": { "type": "number" } } }, "api.UserLoginRequest": { "type": "object", "required": [ "email", "password" ], "properties": { "email": { "type": "string" }, "password": { "type": "string", "minLength": 8 } } }, "db.ActiveType": { "type": "string", "enum": [ "VERY_ACTIVE", "MODERATELY ACTIVE", "LIGHTLY ACTIVE", "NOT VERY ACTIVE" ], "x-enum-varnames": [ "ActiveTypeVERYACTIVE", "ActiveTypeMODERATELYACTIVE", "ActiveTypeLIGHTLYACTIVE", "ActiveTypeNOTVERYACTIVE" ] }, "db.UserGoal": { "type": "string", "enum": [ "WEIGHT_LOSS", "MUSCLE_GAIN", "IMPROVE_ENDURANCE", "INCREASE_STRENGTH", "FLEXIBILITY", "STRESS_RELIEF", "GENERAL_FITNESS", "SPORTS_PERFORMANCE", "HEALTH_MANAGEMENT", "BALANCE_AND_STABILITY" ], "x-enum-varnames": [ "UserGoalWEIGHTLOSS", "UserGoalMUSCLEGAIN", "UserGoalIMPROVEENDURANCE", "UserGoalINCREASESTRENGTH", "UserGoalFLEXIBILITY", "UserGoalSTRESSRELIEF", "UserGoalGENERALFITNESS", "UserGoalSPORTSPERFORMANCE", "UserGoalHEALTHMANAGEMENT", "UserGoalBALANCEANDSTABILITY" ] }, "db.UserRole": { "type": "string", "enum": [ "USER", "ADMIN", "TRAINER", "NUTRITIONIST" ], "x-enum-varnames": [ "UserRoleUSER", "UserRoleADMIN", "UserRoleTRAINER", "UserRoleNUTRITIONIST" ] }, "documentModel.DeleteForumResponse": { "type": "object", "properties": { "Deleted forum successfully": { "type": "string" }, "success": { "type": "boolean" } } }, "documentModel.ErrorAuth": { "type": "object", "properties": { "error": { "description": "Error message", "type": "string", "example": "Wrong Email or Password" } } }, "documentModel.ErrorBadRequest": { "type": "object", "properties": { "error": { "type": "string", "example": "bad request" } } }, "documentModel.ErrorGoal": { "type": "object", "properties": { "error": { "type": "string", "example": "invalid goals" } } }, "documentModel.ErrorNotFound": { "type": "object", "properties": { "error": { "type": "string", "example": "object not found" } } }, "documentModel.ErrorServer": { "type": "object", "properties": { "error": { "type": "string", "example": "Server error" } } }, "documentModel.ErrorToken": { "type": "object", "properties": { "error": { "description": "Error message", "type": "string", "example": "Cannot Create Token" } } }, "documentModel.ErrorUnauthorized": { "type": "object", "properties": { "error": { "description": "Error message", "type": "string", "example": "You need to be logged in" } } }, "documentModel.ForumComment": { "type": "object", "properties": { "content": { "type": "string", "example": "Great advice!" }, "created_at": { "type": "string", "example": "2025-10-12T09:10:00Z" }, "id": { "type": "integer", "example": 100 }, "images": { "type": "array", "items": { "type": "string" }, "example": [ "[\"comment_img1.png\"]" ] }, "like_count": { "type": "integer", "example": 3 }, "post_id": { "type": "integer", "example": 1 }, "user_id": { "type": "integer", "example": 15 } } }, "documentModel.ForumCommentResponse": { "type": "object", "properties": { "data": { "type": "object", "properties": { "comment": { "$ref": "#/definitions/documentModel.ForumComment" } } }, "message": { "type": "string", "example": "comment created successfully" }, "success": { "type": "boolean", "example": true } } }, "documentModel.ForumPost": { "type": "object", "properties": { "content": { "type": "string", "example": "Here are some useful tips..." }, "created_at": { "type": "string", "example": "2025-10-12T09:00:00Z" }, "forum_id": { "type": "integer", "example": 5 }, "id": { "type": "integer", "example": 1 }, "images": { "type": "array", "items": { "type": "string" }, "example": [ "[\"img1.png\"", " \"img2.jpg\"]" ] }, "like_count": { "type": "integer", "example": 12 }, "title": { "type": "string", "example": "How to train effectively?" }, "user_id": { "type": "integer", "example": 10 } } }, "documentModel.ForumPostResponse": { "type": "object", "properties": { "data": { "type": "object", "properties": { "post": { "$ref": "#/definitions/documentModel.ForumPost" } } }, "message": { "type": "string", "example": "post created successfully" }, "success": { "type": "boolean", "example": true } } }, "documentModel.ForumResponse": { "type": "object", "properties": { "description": { "type": "string", "example": "This is a basketball" }, "id": { "type": "integer", "example": 1 }, "name": { "type": "string", "example": "Basketball" } } }, "documentModel.Image": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "image_url": { "type": "string", "example": "https://picsum.photos/seed/picsum/200/300" } } }, "documentModel.ImageInRawMessage": { "type": "object", "properties": { "RawMessage": { "$ref": "#/definitions/documentModel.Image" }, "Valid": { "type": "boolean", "example": true } } }, "documentModel.ListExerciseResponse": { "type": "object", "properties": { "category": { "type": "string", "example": "strength" }, "created_at": { "type": "string", "example": "2025-10-12T09:00:00Z" }, "equipment": { "type": "string", "example": "body only" }, "force": { "type": "string", "example": "push" }, "id": { "type": "string", "example": "1" }, "image_url": { "$ref": "#/definitions/documentModel.ImageInRawMessage" }, "level": { "type": "string", "example": "beginner" }, "mechanic": { "type": "string", "example": "compound" }, "name": { "type": "string", "example": "Push Ups" }, "updated_at": { "type": "string", "example": "2025-10-12T09:00:00Z" } } }, "documentModel.ListForumResponse": { "type": "object", "properties": { "description": { "type": "string", "example": "This is a basketball" }, "id": { "type": "integer", "example": 1 }, "name": { "type": "string", "example": "Basketball" } } }, "documentModel.ListPostForumResponse": { "type": "object", "properties": { "content": { "type": "string", "example": "This is my first post in the forum!" }, "created_at": { "type": "string", "example": "2025-10-12T05:17:48.326974Z" }, "dislike_count": { "type": "integer", "example": 0 }, "forum_id": { "type": "integer", "example": 1 }, "id": { "type": "integer", "example": 2 }, "images": { "type": "array", "items": { "$ref": "#/definitions/documentModel.ImageInRawMessage" } }, "like_count": { "type": "integer", "example": 0 }, "title": { "type": "string", "example": "First Post in Forum" }, "updated_at": { "type": "string", "example": "2025-10-12T05:17:48.326974Z" }, "user_id": { "type": "integer", "example": 1 } } }, "documentModel.LoginResponse": { "type": "object", "properties": { "data": { "description": "Data contains the TokenData structure", "allOf": [ { "$ref": "#/definitions/documentModel.TokenData" } ] }, "message": { "description": "Example response message", "type": "string", "example": "Logged in successfully" }, "success": { "description": "Example success status", "type": "boolean", "example": true } } }, "documentModel.ResponseForum": { "type": "object", "properties": { "data": { "type": "object", "properties": { "forum": { "$ref": "#/definitions/documentModel.ForumResponse" } } }, "message": { "type": "string", "example": "Forum created successfully" }, "success": { "type": "boolean", "example": true } } }, "documentModel.ResponseListForum": { "type": "object", "properties": { "data": { "type": "object", "properties": { "forum": { "type": "array", "items": { "$ref": "#/definitions/documentModel.ListForumResponse" } } } }, "success": { "type": "boolean", "example": true } } }, "documentModel.TokenData": { "type": "object", "properties": { "token": { "description": "Example Paseto", "type": "string", "example": "v2.local.YoctVMZSL02NHH1hQMD8llI91VDvz6pUIffLSc2hONQIhCcQzaxGtCYWr_HvvDXe0KfVzEW5LJ4tcQnvi5RijvwpKUQOZ9LuxFOU-LkSWMW4gvPJ6_LiiZj0HFR7rmqu3jXAKgOnfJPXK-gHdw3jO5Uo7hu34fUPccivvXoSpyqgt-uKL32wev8kI-iJcj8gg5saHj_8EiNeHejrN3rMF7eTinPLt51Y35mggvftma0YxF4FH_lzmjmvp8ghza5lamI-w2aMXct9HzZp9Ujd0nN2wBaP6RGaZ_6W9pFjnDyZ.bnVsbA" } } }, "documentModel.UpdateForumResponse": { "type": "object", "properties": { "Updated forum successfully": { "type": "string" }, "success": { "type": "boolean" } } }, "documentModel.UserPayload": { "type": "object", "properties": { "active_type": { "allOf": [ { "$ref": "#/definitions/db.ActiveType" } ], "example": "ACTIVE" }, "created_at": { "type": "string", "example": "2023-01-01T12:00:00Z" }, "date_of_birth": { "type": "string", "example": "1990-01-01T00:00:00Z" }, "email": { "type": "string", "example": "john.doe@example.com" }, "first_name": { "type": "string", "example": "John" }, "gender": { "type": "string", "example": "male" }, "goals": { "type": "array", "items": { "$ref": "#/definitions/db.UserGoal" }, "example": [ "[\"Lose weight\"", " \"Get fit\"]" ] }, "height_cm": { "type": "number", "example": 180.5 }, "id": { "type": "integer", "example": 1 }, "last_name": { "type": "string", "example": "Doe" }, "location": { "type": "string", "example": "New York" }, "role": { "allOf": [ { "$ref": "#/definitions/db.UserRole" } ], "example": "USER" }, "updated_at": { "type": "string", "example": "2023-01-15T15:00:00Z" }, "weight_kg": { "type": "number", "example": 75.5 } } } }, "securityDefinitions": { "BearerAuth": { "type": "basic" } }, "externalDocs": { "description": "OpenAPI", "url": "https://swagger.io/resources/open-api/" } }