{ "openapi": "3.0.0", "info": { "title": "API de Tarefas", "version": "1.0.0", "description": "API para gerenciamento de tarefas" }, "servers": [ { "url": "/", "description": "Servidor local" } ], "tags": [ { "name": "Tarefas", "description": "Endpoints relacionados às tarefas do usuário" }, { "name": "Auth", "description": "Endpoints de autenticação (registro, login, refresh token)" } ], "paths": { "/task/list": { "get": { "tags": [ "Tarefas" ], "summary": "Listar todas as tarefas do usuário autenticado", "responses": { "200": { "description": "Lista de tarefas retornada com sucesso", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Task" } } } } } }, "security": [ { "bearerAuth": [] } ] } }, "/task/ver/{id}": { "get": { "tags": [ "Tarefas" ], "summary": "Exibir detalhes de uma tarefa específica", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" }, "description": "ID da tarefa" } ], "responses": { "200": { "description": "Tarefa encontrada", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } }, "404": { "description": "Tarefa não encontrada", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "500": { "description": "Erro interno", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } }, "security": [ { "bearerAuth": [] } ] } }, "/task/criar": { "post": { "tags": [ "Tarefas" ], "summary": "Criar uma nova tarefa", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NewTask" }, "examples": { "novo": { "value": { "title": "Nova tarefa", "description": "Detalhes da tarefa" } } } } } }, "responses": { "201": { "description": "Tarefa criada com sucesso", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } }, "500": { "description": "Erro interno", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } }, "security": [ { "bearerAuth": [] } ] } }, "/task/atualizar/{id}": { "put": { "tags": [ "Tarefas" ], "summary": "Atualizar uma tarefa existente", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" }, "description": "ID da tarefa" } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UpdateTask" } } } }, "responses": { "200": { "description": "Tarefa atualizada com sucesso", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Task" } } } }, "404": { "description": "Tarefa não encontrada", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "500": { "description": "Erro interno", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } }, "security": [ { "bearerAuth": [] } ] } }, "/task/remover/{id}": { "delete": { "tags": [ "Tarefas" ], "summary": "Excluir uma tarefa", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" }, "description": "ID da tarefa a ser excluída" } ], "responses": { "200": { "description": "Tarefa excluída com sucesso", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SuccessResponse" } } } }, "404": { "description": "Tarefa não encontrada", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "500": { "description": "Erro interno", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } }, "security": [ { "bearerAuth": [] } ] } }, "/auth/register": { "post": { "tags": [ "Auth" ], "summary": "Registrar novo usuário", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RegisterRequest" } } } }, "responses": { "201": { "description": "Usuário registrado com sucesso", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "integer", "example": 201 }, "message": { "type": "string", "example": "Usuário registrado com sucesso!" } } } } } }, "400": { "description": "Requisição inválida", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "401": { "description": "Campo ausente ou email já cadastrado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }, "/auth/login": { "post": { "tags": [ "Auth" ], "summary": "Autenticar usuário e retornar tokens", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginRequest" } } } }, "responses": { "200": { "description": "Login bem-sucedido", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "integer", "example": 200 }, "message": { "type": "string", "example": "Login efetuado com sucesso" }, "data": { "$ref": "#/components/schemas/TokenResponse" }, "user": { "$ref": "#/components/schemas/UserShort" } } } } } }, "401": { "description": "Credenciais inválidas", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }, "/auth/refresh": { "post": { "tags": [ "Auth" ], "summary": "Renovar access token usando refresh token", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "refresh_token" ], "properties": { "refresh_token": { "type": "string", "example": "refresh_token_aqui" } } } } } }, "responses": { "200": { "description": "Token renovado", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "integer", "example": 200 }, "message": { "type": "string", "example": "Token renovado" }, "access_token": { "type": "string" } } } } } }, "401": { "description": "Refresh token inválido ou ausente", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } } }, "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } }, "schemas": { "Task": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "title": { "type": "string", "example": "Comprar leite" }, "description": { "type": "string", "example": "Leite integral 1L" }, "usr_id": { "type": "integer", "example": 10 }, "created_at": { "type": "string", "format": "date-time", "example": "2025-10-19T12:34:56Z" } } }, "NewTask": { "type": "object", "required": [ "title" ], "properties": { "title": { "type": "string", "example": "Nova tarefa" }, "description": { "type": "string", "example": "Detalhes da tarefa" } } }, "UpdateTask": { "type": "object", "properties": { "title": { "type": "string", "example": "Tarefa atualizada" }, "description": { "type": "string", "example": "Nova descrição" } } }, "ErrorResponse": { "type": "object", "properties": { "message": { "type": "string", "example": "Recurso não encontrado" } } }, "SuccessResponse": { "type": "object", "properties": { "message": { "type": "string", "example": "Operação realizada com sucesso" } } }, "RegisterRequest": { "type": "object", "required": [ "name", "email", "password" ], "properties": { "name": { "type": "string", "example": "Fulano" }, "email": { "type": "string", "format": "email", "example": "fulano@example.com" }, "password": { "type": "string", "format": "password", "example": "senha123" } } }, "LoginRequest": { "type": "object", "required": [ "email", "password" ], "properties": { "email": { "type": "string", "format": "email", "example": "fulano@example.com" }, "password": { "type": "string", "format": "password", "example": "senha123" } } }, "UserShort": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "name": { "type": "string", "example": "Fulano" }, "email": { "type": "string", "format": "email", "example": "fulano@example.com" } } }, "TokenResponse": { "type": "object", "properties": { "access_token": { "type": "string" }, "refresh_token": { "type": "string" } } } } } }