{ "openapi": "3.0.0", "info": { "version": "1.0.0", "title": "API de Tradução Assíncrona", "description": "API para tradução assíncrona de textos com suporte a múltiplos idiomas e gerenciamento de status." }, "servers": [ { "url": "http://localhost:4040" } ], "paths": { "/api/translate/": { "get": { "tags": [ "Translate" ], "summary": "Listar todas as traduções", "description": "Listar todas as traduções com filtros opcionais", "parameters": [ { "name": "_page", "in": "query", "schema": { "type": "string" } }, { "name": "_order", "in": "query", "schema": { "type": "string" } }, { "name": "_sort", "in": "query", "schema": { "type": "string" } }, { "name": "status", "in": "query", "description": "Filtrar por status", "required": false, "enum": [ "QUEUED", "PROCESSING", "COMPLETED", "FAILED", "CANCELLED" ], "schema": { "type": "string" } }, { "name": "sourceLang", "in": "query", "description": "Filtrar por idioma de origem", "required": false, "schema": { "type": "string" } }, { "name": "targetLang", "in": "query", "description": "Filtrar por idioma de destino", "required": false, "schema": { "type": "string" } }, { "name": "page", "in": "query", "description": "Número da página", "required": false, "default": 1, "schema": { "type": "number" } }, { "name": "limit", "in": "query", "description": "Itens por página", "required": false, "default": 10, "schema": { "type": "number" } }, { "name": "description", "in": "query", "schema": { "type": "string" } }, { "name": "schema", "in": "query", "schema": { "type": "string" } }, { "name": "createdAt", "in": "query", "schema": { "type": "string" } }, { "name": "updatedAt", "in": "query", "schema": { "type": "string" } }, { "name": "total", "in": "query", "schema": { "type": "string" } }, { "name": "totalPages", "in": "query", "schema": { "type": "string" } } ], "responses": { "200": { "description": "Lista de traduções", "content": { "application/json": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "data": { "type": "object", "properties": { "type": { "type": "string", "example": "array" }, "items": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "requestId": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "status": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "sourceLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "targetLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "createdAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "updatedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } } } } } } } }, "pagination": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "page": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } }, "limit": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } }, "total": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } }, "totalPages": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } } } } } } } } }, "xml": { "name": "main" } } }, "application/xml": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "data": { "type": "object", "properties": { "type": { "type": "string", "example": "array" }, "items": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "requestId": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "status": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "sourceLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "targetLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "createdAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "updatedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } } } } } } } }, "pagination": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "page": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } }, "limit": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } }, "total": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } }, "totalPages": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } } } } } } } } }, "xml": { "name": "main" } } } } }, "500": { "description": "Internal Server Error" } } }, "post": { "tags": [ "Translate" ], "summary": "Criar nova tradução", "description": "Endpoint para criar uma nova requisição de tradução", "parameters": [ { "name": "_page", "in": "query", "schema": { "type": "string" } }, { "name": "_order", "in": "query", "schema": { "type": "string" } }, { "name": "_sort", "in": "query", "schema": { "type": "string" } }, { "name": "body", "text": { "type": "string", "description": "Texto a ser traduzido", "example": "Hello world!" }, "sourceLang": { "type": "string", "description": "Idioma de origem (ISO code)", "example": "en" }, "targetLang": { "type": "string", "description": "Idioma de destino (ISO code)", "example": "pt" }, "in": "query", "schema": { "type": "string" } } ], "responses": { "202": { "description": "Requisição aceita e enfileirada", "content": { "application/json": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "requestId": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "description": { "type": "string", "example": "ID único da requisição" }, "example": { "type": "string", "example": "64e257-e88b-13d4-a456-123653245000" } } } } } }, "xml": { "name": "main" } } }, "application/xml": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "requestId": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "description": { "type": "string", "example": "ID único da requisição" }, "example": { "type": "string", "example": "123e4567-e89b-12d3-a456-426614174000" } } } } } }, "xml": { "name": "main" } } } } }, "400": { "description": "Dados inválidos" }, "500": { "description": "Erro interno do servidor" } }, "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "text": { "example": "any" }, "sourceLang": { "example": "any" }, "targetLang": { "example": "any" } } } } } } } }, "/api/translate/{requestId}": { "get": { "tags": [ "Translate" ], "summary": "Buscar status da tradução", "description": "Verificar o status de uma tradução específica", "parameters": [ { "name": "requestId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "ID único da requisição de tradução", "example": "123e4567-e89b-12d3-a456-426614174000" }, { "name": "_page", "in": "query", "schema": { "type": "string" } }, { "name": "_order", "in": "query", "schema": { "type": "string" } }, { "name": "_sort", "in": "query", "schema": { "type": "string" } } ], "responses": { "200": { "description": "Status da tradução encontrado", "content": { "application/json": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "requestId": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "status": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "enum": { "type": "array", "example": [ "QUEUED", "PROCESSING", "COMPLETED", "FAILED", "CANCELLED" ], "items": { "type": "string" } } } }, "originalText": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "translatedText": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "sourceLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "targetLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "createdAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "updatedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "queuedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "errorMessage": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "errorCode": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "retryCount": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } } } } }, "xml": { "name": "main" } } }, "application/xml": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "requestId": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "status": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "enum": { "type": "array", "example": [ "QUEUED", "PROCESSING", "COMPLETED", "FAILED", "CANCELLED" ], "items": { "type": "string" } } } }, "originalText": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "translatedText": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "sourceLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "targetLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "createdAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "updatedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "queuedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "errorMessage": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "errorCode": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "retryCount": { "type": "object", "properties": { "type": { "type": "string", "example": "number" } } } } } }, "xml": { "name": "main" } } } } }, "404": { "description": "Tradução não encontrada", "content": { "application/json": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "error": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "message": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } } } } }, "xml": { "name": "main" } } }, "application/xml": { "schema": { "type": "object", "properties": { "type": { "type": "string", "example": "object" }, "properties": { "type": "object", "properties": { "error": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "message": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } } } } }, "xml": { "name": "main" } } } } }, "500": { "description": "Erro interno do servidor" } } } }, "/api/translate/{requestId}/status": { "put": { "tags": [ "Translate" ], "summary": "Atualizar status da tradução", "description": "Atualizar o status de uma tradução (usado pelo worker)", "parameters": [ { "name": "requestId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "ID único da requisição de tradução" }, { "name": "_page", "in": "query", "schema": { "type": "string" } }, { "name": "_order", "in": "query", "schema": { "type": "string" } }, { "name": "_sort", "in": "query", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK" }, "400": { "description": "Bad Request" }, "404": { "description": "Not Found" }, "500": { "description": "Internal Server Error" } }, "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "in": { "example": "any" }, "description": { "example": "any" }, "required": { "example": "any" }, "schema": { "example": "any" }, "translatedText": { "example": "any" }, "errorMessage": { "example": "any" }, "errorCode": { "example": "any" } } } } } } } } }, "components": { "schemas": { "InternalServerError": { "type": "object", "properties": { "code": { "type": "string", "example": "" }, "message": { "type": "string", "example": "" } }, "xml": { "name": "InternalServerError" } }, "Translate": { "type": "object", "properties": { "requestId": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "uuid" } } }, "text": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "translatedText": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "sourceLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "targetLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "status": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "enum": { "type": "array", "example": [ "QUEUED", "PROCESSING", "COMPLETED", "FAILED", "CANCELLED" ], "items": { "type": "string" } } } }, "errorMessage": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "errorCode": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "retryCount": { "type": "object", "properties": { "type": { "type": "string", "example": "integer" } } }, "createdAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "updatedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } }, "queuedAt": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "format": { "type": "string", "example": "date-time" } } } }, "xml": { "name": "Translate" } }, "TranslateRequest": { "type": "object", "properties": { "text": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "sourceLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "targetLang": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } } }, "xml": { "name": "TranslateRequest" } }, "TranslateStatusUpdate": { "type": "object", "properties": { "status": { "type": "object", "properties": { "type": { "type": "string", "example": "string" }, "enum": { "type": "array", "example": [ "QUEUED", "PROCESSING", "COMPLETED", "FAILED", "CANCELLED" ], "items": { "type": "string" } } } }, "translatedText": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "errorMessage": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } }, "errorCode": { "type": "object", "properties": { "type": { "type": "string", "example": "string" } } } }, "xml": { "name": "TranslateStatusUpdate" } } } } }