openapi: 3.0.3 info: title: Accounts Microservice API description: | API para la gestión de cuentas bancarias y movimientos. Implementa arquitectura limpia y principios SOLID. version: 1.0.0 contact: name: DevPeru Banking Team email: support@devperu.com servers: - url: http://localhost:8081 description: Development server tags: - name: Accounts description: Operaciones sobre cuentas bancarias - name: Movements description: Operaciones sobre movimientos (débitos/créditos) - name: Reports description: Reportes y estados de cuenta paths: /api/v1/accounts: post: tags: - Accounts summary: Crear nueva cuenta description: Crea una nueva cuenta bancaria para un cliente existente operationId: createAccount requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateAccountRequest' examples: savingsAccount: summary: Cuenta de Ahorros value: accountNumber: "478758" accountType: "SAVINGS" initialBalance: 2000.00 status: true customerId: 1 responses: '201': description: Cuenta creada exitosamente content: application/json: schema: $ref: '#/components/schemas/Account' '400': description: Datos inválidos content: application/json: schema: $ref: '#/components/schemas/ApiError' '409': description: La cuenta ya existe content: application/json: schema: $ref: '#/components/schemas/ApiError' get: tags: - Accounts summary: Listar todas las cuentas description: Obtiene un listado de todas las cuentas bancarias operationId: getAllAccounts responses: '200': description: Lista de cuentas content: application/json: schema: type: array items: $ref: '#/components/schemas/Account' /api/v1/accounts/{id}: get: tags: - Accounts summary: Obtener cuenta por ID description: Retorna los detalles de una cuenta específica operationId: getAccountById parameters: - name: id in: path required: true schema: type: integer format: int64 responses: '200': description: Cuenta encontrada content: application/json: schema: $ref: '#/components/schemas/Account' '404': description: Cuenta no encontrada content: application/json: schema: $ref: '#/components/schemas/ApiError' put: tags: - Accounts summary: Actualizar cuenta description: Actualiza los datos de una cuenta existente operationId: updateAccount parameters: - name: id in: path required: true schema: type: integer format: int64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateAccountRequest' responses: '200': description: Cuenta actualizada content: application/json: schema: $ref: '#/components/schemas/Account' '404': description: Cuenta no encontrada content: application/json: schema: $ref: '#/components/schemas/ApiError' delete: tags: - Accounts summary: Eliminar cuenta description: Elimina una cuenta bancaria operationId: deleteAccount parameters: - name: id in: path required: true schema: type: integer format: int64 responses: '204': description: Cuenta eliminada exitosamente '404': description: Cuenta no encontrada content: application/json: schema: $ref: '#/components/schemas/ApiError' /api/v1/accounts/customer/{customerId}: get: tags: - Accounts summary: Obtener cuentas por cliente description: Retorna todas las cuentas de un cliente específico operationId: getAccountsByCustomerId parameters: - name: customerId in: path required: true schema: type: integer format: int64 responses: '200': description: Lista de cuentas del cliente content: application/json: schema: type: array items: $ref: '#/components/schemas/Account' /api/v1/movements: post: tags: - Movements summary: Crear movimiento description: Registra un nuevo movimiento (débito o crédito) en una cuenta operationId: createMovement requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateMovementRequest' examples: debit: summary: Movimiento de Débito value: movementType: "DEBIT" amount: 575.00 accountId: 1 credit: summary: Movimiento de Crédito value: movementType: "CREDIT" amount: 600.00 accountId: 1 responses: '201': description: Movimiento creado exitosamente content: application/json: schema: $ref: '#/components/schemas/Movement' '400': description: Saldo no disponible o datos inválidos content: application/json: schema: $ref: '#/components/schemas/ApiError' /api/v1/movements/account/{accountId}: get: tags: - Movements summary: Obtener movimientos por cuenta description: Retorna todos los movimientos de una cuenta específica operationId: getMovementsByAccountId parameters: - name: accountId in: path required: true schema: type: integer format: int64 responses: '200': description: Lista de movimientos content: application/json: schema: type: array items: $ref: '#/components/schemas/Movement' /api/v1/reports/{customerId}: get: tags: - Reports summary: Reporte de estado de cuenta description: Genera un reporte de movimientos por rango de fechas operationId: getAccountStatement parameters: - name: customerId in: path required: true schema: type: integer format: int64 - name: startDate in: query required: true schema: type: string format: date-time example: "2022-01-01T00:00:00" - name: endDate in: query required: true schema: type: string format: date-time example: "2026-12-31T23:59:59" responses: '200': description: Reporte generado exitosamente content: application/json: schema: $ref: '#/components/schemas/AccountStatement' components: schemas: CreateAccountRequest: type: object required: - accountNumber - accountType - initialBalance - status - customerId properties: accountNumber: type: string description: Número único de la cuenta example: "478758" accountType: type: string enum: [SAVINGS, CHECKING] description: Tipo de cuenta example: "SAVINGS" initialBalance: type: number format: double minimum: 0 description: Saldo inicial de la cuenta example: 2000.00 status: type: boolean description: Estado activo/inactivo example: true customerId: type: integer format: int64 description: ID del cliente propietario example: 1 UpdateAccountRequest: type: object properties: accountNumber: type: string example: "478758" accountType: type: string enum: [SAVINGS, CHECKING] example: "SAVINGS" status: type: boolean example: true Account: type: object properties: id: type: integer format: int64 example: 1 accountNumber: type: string example: "478758" accountType: type: string example: "SAVINGS" initialBalance: type: number format: double example: 2000.00 currentBalance: type: number format: double example: 1425.00 status: type: boolean example: true customerId: type: integer format: int64 example: 1 CreateMovementRequest: type: object required: - movementType - amount - accountId properties: movementType: type: string enum: [DEBIT, CREDIT] description: Tipo de movimiento example: "DEBIT" amount: type: number format: double minimum: 0.01 description: Monto del movimiento example: 575.00 accountId: type: integer format: int64 description: ID de la cuenta example: 1 Movement: type: object properties: id: type: integer format: int64 example: 1 movementDate: type: string format: date-time example: "2026-01-19T10:30:00" movementType: type: string example: "DEBIT" amount: type: number format: double example: 575.00 balance: type: number format: double description: Saldo después del movimiento example: 1425.00 accountId: type: integer format: int64 example: 1 AccountStatement: type: object properties: customer: type: object properties: id: type: integer format: int64 name: type: string identification: type: string accounts: type: array items: type: object properties: accountNumber: type: string accountType: type: string currentBalance: type: number format: double movements: type: array items: $ref: '#/components/schemas/Movement' ApiError: type: object properties: timestamp: type: string format: date-time example: "2026-01-19T10:30:00" status: type: integer example: 400 error: type: string example: "Bad Request" message: type: string example: "Saldo no disponible" path: type: string example: "/api/v1/movements"