openapi: 3.0.3 info: title: "API Gestión de Mantenimientos de Laptops" description: | API CRUD para gestión de mantenimientos de laptops integrada con el EPN Event Manager. ## Seguridad Todos los endpoints requieren la cabecera **`X-FIS-EPN-KEY`** con un token válido. Sin esta cabecera la petición será rechazada con HTTP 401. ## Fuente de eventos La fuente de integración es `crud-mantenimiento-laptops` sobre la entidad `laptop_maintenance`. version: "1.0.0" contact: name: "FIS-EPN — Equipo CRUD Mantenimiento" servers: - url: http://localhost:3000 description: Servidor de desarrollo local security: - ApiKeyAuth: [] # ───────────────────────────────────────────────────────── # SECURITY SCHEMES # ───────────────────────────────────────────────────────── components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: X-FIS-EPN-KEY description: "Clave institucional FIS-EPN requerida en todas las peticiones." schemas: # ── Entidad principal ────────────────────────────────── LaptopMaintenance: type: object required: [id, brand, model, ownerName, issueDescription, cost, status, createdAt, updatedAt] properties: id: type: string format: uuid example: "3fa85f64-5717-4562-b3fc-2c963f66afa6" readOnly: true brand: type: string minLength: 1 maxLength: 60 example: "Dell" model: type: string minLength: 1 maxLength: 80 example: "XPS 13" ownerName: type: string minLength: 2 maxLength: 100 example: "Juan Pérez" issueDescription: type: string minLength: 5 maxLength: 500 example: "Batería no carga correctamente" cost: type: number format: float minimum: 0 maximum: 99999.99 example: 150.00 status: type: string enum: [PENDIENTE, EN_PROCESO, COMPLETADO] example: "PENDIENTE" createdAt: type: string format: date-time readOnly: true example: "2024-06-01T10:30:00.000Z" updatedAt: type: string format: date-time readOnly: true example: "2024-06-02T08:15:00.000Z" # ── Payload de creación ─────────────────────────────── CreateMaintenanceRequest: type: object required: [brand, model, ownerName, issueDescription, cost] properties: brand: type: string minLength: 1 maxLength: 60 example: "Lenovo" model: type: string minLength: 1 maxLength: 80 example: "ThinkPad X1 Carbon" ownerName: type: string minLength: 2 maxLength: 100 example: "María García" issueDescription: type: string minLength: 5 maxLength: 500 example: "Cambio de pasta térmica y limpieza de ventiladores" cost: type: number format: float minimum: 0 maximum: 99999.99 example: 45.00 # ── Payload de actualización ────────────────────────── UpdateMaintenanceRequest: type: object minProperties: 1 properties: status: type: string enum: [PENDIENTE, EN_PROCESO, COMPLETADO] example: "EN_PROCESO" cost: type: number format: float minimum: 0 maximum: 99999.99 example: 75.00 issueDescription: type: string minLength: 5 maxLength: 500 example: "Cambio de pasta térmica completado. Se detectó falla adicional en placa." # ── Respuestas de error ─────────────────────────────── ErrorResponse: type: object properties: error: type: string example: "Validación fallida: 'brand' es obligatorio." timestamp: type: string format: date-time example: "2024-06-01T10:30:00.000Z" ValidationErrorResponse: type: object properties: error: type: string example: "Validación fallida" details: type: array items: type: string example: - "'brand' es obligatorio." - "'cost' fuera de rango (0–99999.99)." # ───────────────────────────────────────────────────────── # PATHS # ───────────────────────────────────────────────────────── paths: /health: get: summary: "Verificar estado del Event Manager" operationId: healthCheck tags: [Sistema] security: - ApiKeyAuth: [] responses: "200": description: "Servidor activo" content: application/json: schema: type: object properties: status: type: string example: "ok" "401": description: "API Key inválida o ausente" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /maintenances: get: summary: "Listar todos los mantenimientos" operationId: listMaintenances tags: [Mantenimientos] parameters: - name: status in: query required: false description: "Filtrar por estado" schema: type: string enum: [PENDIENTE, EN_PROCESO, COMPLETADO] - name: search in: query required: false description: "Búsqueda por marca, modelo o cliente" schema: type: string maxLength: 100 responses: "200": description: "Lista de mantenimientos" content: application/json: schema: type: array items: $ref: '#/components/schemas/LaptopMaintenance' "401": description: "No autorizado — falta X-FIS-EPN-KEY" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' post: summary: "Registrar nuevo mantenimiento" operationId: createMaintenance tags: [Mantenimientos] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateMaintenanceRequest' example: brand: "Asus" model: "ZenBook 14" ownerName: "Roberto Salinas" issueDescription: "Pantalla con líneas verticales y retroiluminación fallida" cost: 220.50 responses: "201": description: "Mantenimiento creado exitosamente" content: application/json: schema: $ref: '#/components/schemas/LaptopMaintenance' "400": description: "Datos de entrada inválidos" content: application/json: schema: $ref: '#/components/schemas/ValidationErrorResponse' "401": description: "No autorizado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /maintenances/{id}: parameters: - name: id in: path required: true description: "UUID del registro de mantenimiento" schema: type: string format: uuid get: summary: "Obtener mantenimiento por ID" operationId: getMaintenanceById tags: [Mantenimientos] responses: "200": description: "Registro encontrado" content: application/json: schema: $ref: '#/components/schemas/LaptopMaintenance' "404": description: "Registro no encontrado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' example: error: "No existe un mantenimiento con ID: 3fa85f64-..." timestamp: "2024-06-01T10:30:00.000Z" "401": description: "No autorizado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' patch: summary: "Actualizar estado, costo o descripción de un mantenimiento" operationId: updateMaintenance tags: [Mantenimientos] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateMaintenanceRequest' examples: cambiarEstado: summary: "Solo cambiar estado" value: status: "EN_PROCESO" actualizarCosto: summary: "Actualizar costo y descripción" value: cost: 350.00 issueDescription: "Se encontró falla adicional en RAM — reemplazo incluido" responses: "200": description: "Registro actualizado" content: application/json: schema: $ref: '#/components/schemas/LaptopMaintenance' "400": description: "Estado o campos inválidos" content: application/json: schema: $ref: '#/components/schemas/ValidationErrorResponse' "404": description: "Registro no encontrado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' "401": description: "No autorizado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' delete: summary: "Eliminar un mantenimiento" operationId: deleteMaintenance tags: [Mantenimientos] responses: "200": description: "Registro eliminado" content: application/json: schema: $ref: '#/components/schemas/LaptopMaintenance' "404": description: "Registro no encontrado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' "401": description: "No autorizado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /events: post: summary: "Publicar evento en el Event Manager (uso interno)" operationId: publishEvent tags: [Eventos] requestBody: required: true content: application/json: schema: type: object required: [source, entity, action, title, description, payload] properties: source: type: string example: "crud-mantenimiento-laptops" entity: type: string example: "laptop_maintenance" action: type: string enum: [CREATE, READ, UPDATE, DELETE, QUERY] example: "CREATE" title: type: string maxLength: 120 example: "Nuevo mantenimiento registrado" description: type: string maxLength: 500 example: "Laptop Dell XPS 13 de Juan Pérez — falla: batería" payload: type: object additionalProperties: true responses: "201": description: "Evento registrado en el hub" content: application/json: schema: type: object properties: id: type: string format: uuid receivedAt: type: string format: date-time "401": description: "No autorizado" content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' tags: - name: Sistema description: "Operaciones de salud e infraestructura" - name: Mantenimientos description: "CRUD de registros de mantenimiento de laptops" - name: Eventos description: "Integración con el EPN Event Manager"