{ "swagger": "2.0", "info": { "description": "API server for AI-powered task planner application", "title": "AI Planner Backend API", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "email": "support@example.com" }, "license": { "name": "MIT", "url": "https://opensource.org/licenses/MIT" }, "version": "1.0" }, "host": "localhost:8080", "basePath": "/api/v1", "paths": { "/api/v1/ai/analyze": { "post": { "security": [ { "Bearer": [] } ], "description": "Analyze user's tasks to provide insights and recommendations", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "AI" ], "summary": "Analyze multiple tasks", "responses": { "200": { "description": "Analysis successful", "schema": { "$ref": "#/definitions/services.TaskAnalysisResponse" } }, "401": { "description": "User not authenticated", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "Database or AI service error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } } }, "/api/v1/ai/health": { "get": { "description": "Check if the external AI service is available and responding", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "AI" ], "summary": "Check AI service health", "responses": { "200": { "description": "AI service is healthy", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "503": { "description": "AI service unavailable", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } }, "/api/v1/ai/predict": { "post": { "security": [ { "Bearer": [] } ], "description": "Use AI to predict task completion time and difficulty", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "AI" ], "summary": "Predict task completion time", "parameters": [ { "description": "Task prediction data", "name": "task", "in": "body", "required": true, "schema": { "$ref": "#/definitions/services.TaskPredictionRequest" } } ], "responses": { "200": { "description": "Prediction successful", "schema": { "$ref": "#/definitions/services.TaskPredictionResponse" } }, "400": { "description": "Invalid request body", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "401": { "description": "User not authenticated", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "AI service error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } } }, "/api/v1/auth/login": { "post": { "description": "Login with email and password to receive JWT token", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Authentication" ], "summary": "Authenticate user login", "parameters": [ { "description": "User login credentials", "name": "credentials", "in": "body", "required": true, "schema": { "$ref": "#/definitions/controllers.LoginRequest" } } ], "responses": { "200": { "description": "Login successful", "schema": { "$ref": "#/definitions/controllers.AuthResponseSwagger" } }, "400": { "description": "Invalid request body or validation error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "401": { "description": "Invalid credentials", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } } }, "/api/v1/auth/register": { "post": { "description": "Register a new user with email, password, and name", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Authentication" ], "summary": "Create a new user account", "parameters": [ { "description": "User registration data", "name": "user", "in": "body", "required": true, "schema": { "$ref": "#/definitions/controllers.RegisterRequest" } } ], "responses": { "201": { "description": "User created successfully", "schema": { "$ref": "#/definitions/controllers.AuthResponseSwagger" } }, "400": { "description": "Invalid request body or validation error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "409": { "description": "User already exists", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } } }, "/api/v1/tasks": { "get": { "security": [ { "Bearer": [] } ], "description": "Retrieve all tasks belonging to the authenticated user with pagination", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Tasks" ], "summary": "Get all tasks for user", "parameters": [ { "type": "integer", "default": 1, "description": "Page number", "name": "page", "in": "query" }, { "type": "integer", "default": 10, "description": "Items per page", "name": "limit", "in": "query" } ], "responses": { "200": { "description": "Tasks retrieved successfully", "schema": { "$ref": "#/definitions/controllers.TasksListResponse" } }, "401": { "description": "User not authenticated", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } }, "post": { "security": [ { "Bearer": [] } ], "description": "Create a new task for the authenticated user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Tasks" ], "summary": "Create a new task", "parameters": [ { "description": "Task creation data", "name": "task", "in": "body", "required": true, "schema": { "$ref": "#/definitions/controllers.CreateTaskRequest" } } ], "responses": { "201": { "description": "Task created successfully", "schema": { "$ref": "#/definitions/controllers.TaskResponse" } }, "400": { "description": "Invalid request body or validation error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "401": { "description": "User not authenticated", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } } }, "/api/v1/tasks/{id}": { "get": { "security": [ { "Bearer": [] } ], "description": "Retrieve a specific task by its ID for the authenticated user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Tasks" ], "summary": "Get a task by ID", "parameters": [ { "type": "integer", "description": "Task ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "Task retrieved successfully", "schema": { "$ref": "#/definitions/controllers.TaskResponse" } }, "400": { "description": "Invalid task ID", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "401": { "description": "User not authenticated", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "404": { "description": "Task not found", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } } }, "/api/v1/user/me": { "get": { "security": [ { "Bearer": [] } ], "description": "Get the authenticated user's profile information", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Authentication" ], "summary": "Get current user information", "responses": { "200": { "description": "Current user information", "schema": { "$ref": "#/definitions/controllers.UserResponse" } }, "401": { "description": "User not authenticated", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "404": { "description": "User not found", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/controllers.ErrorResponse" } } } } } }, "definitions": { "controllers.AuthResponseSwagger": { "type": "object", "properties": { "token": { "type": "string" }, "user": { "$ref": "#/definitions/controllers.UserResponse" } } }, "controllers.CreateTaskRequest": { "type": "object", "required": [ "task_name" ], "properties": { "ai_labels": { "type": "string" }, "predicted_duration": { "type": "integer" }, "priority": { "type": "number" }, "status": { "type": "string" }, "task_name": { "type": "string" } } }, "controllers.ErrorResponse": { "type": "object", "properties": { "error": { "type": "string" } } }, "controllers.LoginRequest": { "type": "object", "required": [ "email", "password" ], "properties": { "email": { "type": "string" }, "password": { "type": "string" } } }, "controllers.RegisterRequest": { "type": "object", "required": [ "email", "name", "password" ], "properties": { "email": { "type": "string" }, "name": { "type": "string" }, "password": { "type": "string", "minLength": 6 } } }, "controllers.TaskResponse": { "type": "object", "properties": { "ai_labels": { "type": "string" }, "created_at": { "type": "string" }, "id": { "type": "integer" }, "predicted_duration": { "type": "integer" }, "priority": { "type": "number" }, "status": { "type": "string" }, "task_name": { "type": "string" }, "user_id": { "type": "integer" } } }, "controllers.TasksListResponse": { "type": "object", "properties": { "meta": { "type": "object", "properties": { "limit": { "type": "integer" }, "page": { "type": "integer" }, "total": { "type": "integer" } } }, "tasks": { "type": "array", "items": { "$ref": "#/definitions/controllers.TaskResponse" } } } }, "controllers.UserResponse": { "type": "object", "properties": { "created_at": { "type": "string" }, "email": { "type": "string" }, "id": { "type": "integer" }, "name": { "type": "string" }, "updated_at": { "type": "string" } } }, "services.TaskAnalysisResponse": { "type": "object", "properties": { "average_difficulty": { "type": "number" }, "insights": { "type": "array", "items": { "type": "string" } }, "recommended_order": { "description": "task IDs in recommended order", "type": "array", "items": { "type": "integer" } }, "suggestions": { "type": "object", "additionalProperties": true }, "total_estimated_time": { "type": "integer" }, "workload": { "description": "\"light\", \"moderate\", \"heavy\"", "type": "string" } } }, "services.TaskPredictionRequest": { "type": "object", "properties": { "context": { "type": "object", "additionalProperties": true }, "description": { "type": "string" }, "priority": { "description": "1=low, 2=medium, 3=high, 4=urgent", "type": "integer" }, "title": { "type": "string" }, "user_id": { "type": "integer" } } }, "services.TaskPredictionResponse": { "type": "object", "properties": { "confidence": { "description": "0.0 to 1.0", "type": "number" }, "difficulty": { "description": "0.0 to 1.0", "type": "number" }, "predicted_duration": { "description": "in minutes", "type": "integer" }, "suggestions": { "type": "array", "items": { "type": "string" } }, "tags": { "type": "array", "items": { "type": "string" } } } } }, "securityDefinitions": { "Bearer": { "description": "Type \"Bearer\" followed by a space and JWT token.", "type": "apiKey", "name": "Authorization", "in": "header" } } }