{"openapi":"3.0.4","info":{"title":"API Sistema de Flota Vehicular","version":"2.0.0","description":"Especificacion OpenAPI reconstruida desde el codigo actual.\nIncluye rutas v1, flujo operativo de viajes, aprobaciones y\nvalidaciones de negocio agregadas en Form Requests.\n"},"servers":[{"url":"http://flotavehiculossitema.test","description":"Entorno local Herd"}],"security":[{"bearerAuth":[]}],"tags":[{"name":"Auth","description":"Autenticacion con Sanctum"},{"name":"VehicleTypes","description":"Catalogo de tipos de vehiculo"},{"name":"Vehicles","description":"Gestion de vehiculos"},{"name":"Trips","description":"Gestion y flujo de viajes"},{"name":"FuelLogs","description":"Registros de combustible"},{"name":"MaintenanceLogs","description":"Registros de mantenimiento"},{"name":"Incidents","description":"Registros de incidentes"}],"paths":{"/api/v1/auth/login":{"post":{"tags":["Auth"],"summary":"Iniciar sesion","operationId":"authLogin","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"},"examples":{"gerente":{"summary":"Login de gerente","value":{"email":"gerente@flota.local","password":"secret123"}},"supervisor":{"summary":"Login de supervisor","value":{"email":"supervisor@flota.local","password":"secret123"}},"motorista":{"summary":"Login de motorista","value":{"email":"motorista@flota.local","password":"secret123"}}}}}},"responses":{"200":{"description":"Login exitoso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthTokenResponse"}}}},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/auth/logout":{"post":{"tags":["Auth"],"summary":"Cerrar sesion del token actual","operationId":"authLogout","responses":{"200":{"description":"Sesion cerrada","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string","example":"Sesion cerrada correctamente."}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/v1/auth/me":{"get":{"tags":["Auth"],"summary":"Obtener usuario autenticado","operationId":"authMe","responses":{"200":{"description":"Datos de usuario","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/User"}}},"examples":{"gerente":{"summary":"Perfil autenticado gerente","value":{"data":{"id":1,"name":"Gerente General","email":"gerente@flota.local","role":"gerente","license_number":null,"phone":"55551234","is_active":true,"email_verified_at":"2026-04-01T00:00:00Z","created_at":"2026-04-01T00:00:00Z","updated_at":"2026-04-08T00:00:00Z"}}},"supervisor":{"summary":"Perfil autenticado supervisor","value":{"data":{"id":2,"name":"Supervisor Operativo","email":"supervisor@flota.local","role":"supervisor","license_number":null,"phone":"55552345","is_active":true,"email_verified_at":"2026-04-01T00:00:00Z","created_at":"2026-04-01T00:00:00Z","updated_at":"2026-04-08T00:00:00Z"}}},"motorista":{"summary":"Perfil autenticado motorista","value":{"data":{"id":3,"name":"Motorista Uno","email":"motorista@flota.local","role":"motorista","license_number":"LIC-90210","phone":"55553456","is_active":true,"email_verified_at":"2026-04-01T00:00:00Z","created_at":"2026-04-01T00:00:00Z","updated_at":"2026-04-08T00:00:00Z"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/v1/vehicle-types":{"get":{"tags":["VehicleTypes"],"summary":"Listar tipos de vehiculo","operationId":"vehicleTypeIndex","responses":{"200":{"$ref":"#/components/responses/VehicleTypeCollectionResponse"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["VehicleTypes"],"summary":"Crear tipo de vehiculo","operationId":"vehicleTypeStore","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VehicleTypeCreateRequest"},"examples":{"gerente":{"summary":"Alta de tipo de vehiculo por gerente","value":{"name":"Camion Liviano","code":"CAM-LIV","maintenance_interval_km":8000,"tank_capacity":120,"payload_capacity":3500}}}}}},"responses":{"201":{"$ref":"#/components/responses/VehicleTypeSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/vehicle-types/{vehicle_type}":{"parameters":[{"$ref":"#/components/parameters/VehicleTypeId"}],"get":{"tags":["VehicleTypes"],"summary":"Obtener tipo de vehiculo","operationId":"vehicleTypeShow","responses":{"200":{"$ref":"#/components/responses/VehicleTypeSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"tags":["VehicleTypes"],"summary":"Actualizar tipo de vehiculo","operationId":"vehicleTypeUpdate","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VehicleTypeUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/VehicleTypeSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"patch":{"tags":["VehicleTypes"],"summary":"Actualizacion parcial de tipo de vehiculo","operationId":"vehicleTypePatch","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VehicleTypeUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/VehicleTypeSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"delete":{"tags":["VehicleTypes"],"summary":"Eliminar tipo de vehiculo","operationId":"vehicleTypeDestroy","responses":{"204":{"description":"Tipo eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/vehicles":{"get":{"tags":["Vehicles"],"summary":"Listar vehiculos","operationId":"vehicleIndex","responses":{"200":{"$ref":"#/components/responses/VehicleCollectionResponse"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Vehicles"],"summary":"Crear vehiculo","operationId":"vehicleStore","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VehicleCreateRequest"},"examples":{"supervisor":{"summary":"Alta de vehiculo por supervisor","value":{"vehicle_type_id":1,"plate_number":"P123-456","brand":"Isuzu","model":"NPR","year":2024,"status":"active"}}}}}},"responses":{"201":{"$ref":"#/components/responses/VehicleSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/vehicles/{vehicle}":{"parameters":[{"$ref":"#/components/parameters/VehicleId"}],"get":{"tags":["Vehicles"],"summary":"Obtener vehiculo","operationId":"vehicleShow","responses":{"200":{"$ref":"#/components/responses/VehicleSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"tags":["Vehicles"],"summary":"Actualizar vehiculo","operationId":"vehicleUpdate","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VehicleUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/VehicleSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"patch":{"tags":["Vehicles"],"summary":"Actualizacion parcial de vehiculo","operationId":"vehiclePatch","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VehicleUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/VehicleSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"delete":{"tags":["Vehicles"],"summary":"Eliminar vehiculo","operationId":"vehicleDestroy","responses":{"204":{"description":"Vehiculo eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/trips":{"get":{"tags":["Trips"],"summary":"Listar viajes","operationId":"tripIndex","responses":{"200":{"$ref":"#/components/responses/TripCollectionResponse"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Trips"],"summary":"Crear viaje","description":"Reglas de negocio adicionales en backend:\n- Evita viaje duplicado por mismo vehiculo, conductor y hora.\n- Evita conflicto de horario por vehiculo.\n- Evita conflicto de horario por conductor.\n","operationId":"tripStore","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TripCreateRequest"},"examples":{"supervisor":{"summary":"Programacion de viaje por supervisor","value":{"vehicle_id":1,"driver_id":3,"start_odometer":152000,"start_time":"2026-04-09 07:00:00","route_description":"Centro de distribucion -> Sucursal Norte"}}}}}},"responses":{"201":{"$ref":"#/components/responses/TripSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/trips/{trip}":{"parameters":[{"$ref":"#/components/parameters/TripId"}],"get":{"tags":["Trips"],"summary":"Obtener viaje","operationId":"tripShow","responses":{"200":{"$ref":"#/components/responses/TripSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"tags":["Trips"],"summary":"Actualizar viaje","operationId":"tripUpdate","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TripUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/TripSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"patch":{"tags":["Trips"],"summary":"Actualizacion parcial de viaje","operationId":"tripPatch","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TripUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/TripSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"delete":{"tags":["Trips"],"summary":"Eliminar viaje","operationId":"tripDestroy","responses":{"204":{"description":"Viaje eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/trips/{trip}/assign":{"patch":{"tags":["Trips"],"summary":"Asignar conductor y vehiculo","operationId":"tripAssign","parameters":[{"$ref":"#/components/parameters/TripId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TripAssignRequest"},"examples":{"supervisor":{"summary":"Reasignacion de viaje por supervisor","value":{"vehicle_id":2,"driver_id":4,"start_time":"2026-04-09 09:30:00","route_description":"Bodega Central -> Planta Sur"}}}}}},"responses":{"200":{"$ref":"#/components/responses/TripMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/trips/{trip}/start":{"patch":{"tags":["Trips"],"summary":"Iniciar viaje","operationId":"tripStart","parameters":[{"$ref":"#/components/parameters/TripId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TripStartRequest"},"examples":{"motorista":{"summary":"Inicio de viaje por motorista asignado","value":{"start_odometer":152125,"start_time":"2026-04-09 07:05:00"}}}}}},"responses":{"200":{"$ref":"#/components/responses/TripMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/trips/{trip}/complete":{"patch":{"tags":["Trips"],"summary":"Completar viaje y enviarlo a validacion","operationId":"tripComplete","parameters":[{"$ref":"#/components/parameters/TripId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TripCompleteRequest"},"examples":{"motorista":{"summary":"Cierre operativo por motorista","value":{"end_odometer":152290,"end_time":"2026-04-09 10:10:00","route_description":"Entrega completada sin novedades"}}}}}},"responses":{"200":{"$ref":"#/components/responses/TripMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/trips/{trip}/validate":{"patch":{"tags":["Trips"],"summary":"Validar y completar viaje","operationId":"tripValidate","parameters":[{"$ref":"#/components/parameters/TripId"}],"responses":{"200":{"$ref":"#/components/responses/TripMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/trips/{trip}/cancel":{"patch":{"tags":["Trips"],"summary":"Cancelar viaje","operationId":"tripCancel","parameters":[{"$ref":"#/components/parameters/TripId"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TripCancelRequest"},"examples":{"supervisor":{"summary":"Cancelacion por supervisor","value":{"reason":"Vehiculo fuera de servicio por falla mecanica."}}}}}},"responses":{"200":{"$ref":"#/components/responses/TripMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/fuel-logs":{"get":{"tags":["FuelLogs"],"summary":"Listar registros de combustible","operationId":"fuelLogIndex","responses":{"200":{"$ref":"#/components/responses/FuelLogCollectionResponse"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["FuelLogs"],"summary":"Crear registro de combustible","operationId":"fuelLogStore","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FuelLogCreateRequest"},"examples":{"motorista":{"summary":"Carga de combustible por motorista","value":{"trip_id":10,"vehicle_id":2,"liters":38.5,"cost_per_liter":4.25,"station_name":"Puma Roosevelt","receipt_image":"https://example.com/recibos/fuel-10.jpg","logged_at":"2026-04-09 08:15:00"}}}}}},"responses":{"201":{"$ref":"#/components/responses/FuelLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/fuel-logs/{fuel_log}":{"parameters":[{"$ref":"#/components/parameters/FuelLogId"}],"get":{"tags":["FuelLogs"],"summary":"Obtener registro de combustible","operationId":"fuelLogShow","responses":{"200":{"$ref":"#/components/responses/FuelLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"tags":["FuelLogs"],"summary":"Actualizar registro de combustible","operationId":"fuelLogUpdate","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FuelLogUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/FuelLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"patch":{"tags":["FuelLogs"],"summary":"Actualizacion parcial de registro de combustible","operationId":"fuelLogPatch","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FuelLogUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/FuelLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"delete":{"tags":["FuelLogs"],"summary":"Eliminar registro de combustible","operationId":"fuelLogDestroy","responses":{"204":{"description":"Registro eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/fuel-logs/{fuelLog}/approve":{"patch":{"tags":["FuelLogs"],"summary":"Aprobar registro de combustible","operationId":"fuelLogApprove","parameters":[{"$ref":"#/components/parameters/FuelLogApproveId"}],"responses":{"200":{"$ref":"#/components/responses/FuelLogMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/maintenance-logs":{"get":{"tags":["MaintenanceLogs"],"summary":"Listar registros de mantenimiento","operationId":"maintenanceLogIndex","responses":{"200":{"$ref":"#/components/responses/MaintenanceLogCollectionResponse"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["MaintenanceLogs"],"summary":"Crear registro de mantenimiento","operationId":"maintenanceLogStore","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MaintenanceLogCreateRequest"},"examples":{"supervisor":{"summary":"Registro de mantenimiento por supervisor","value":{"vehicle_id":2,"type":"Preventivo","description":"Cambio de aceite, filtro y revision de frenos.","cost":1450.75,"service_date":"2026-04-10","workshop_name":"Taller El Motor"}}}}}},"responses":{"201":{"$ref":"#/components/responses/MaintenanceLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/maintenance-logs/{maintenance_log}":{"parameters":[{"$ref":"#/components/parameters/MaintenanceLogId"}],"get":{"tags":["MaintenanceLogs"],"summary":"Obtener registro de mantenimiento","operationId":"maintenanceLogShow","responses":{"200":{"$ref":"#/components/responses/MaintenanceLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"tags":["MaintenanceLogs"],"summary":"Actualizar registro de mantenimiento","operationId":"maintenanceLogUpdate","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MaintenanceLogUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/MaintenanceLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"patch":{"tags":["MaintenanceLogs"],"summary":"Actualizacion parcial de registro de mantenimiento","operationId":"maintenanceLogPatch","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MaintenanceLogUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/MaintenanceLogSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"delete":{"tags":["MaintenanceLogs"],"summary":"Eliminar registro de mantenimiento","operationId":"maintenanceLogDestroy","responses":{"204":{"description":"Registro eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/maintenance-logs/{maintenanceLog}/approve":{"patch":{"tags":["MaintenanceLogs"],"summary":"Aprobar mantenimiento","operationId":"maintenanceLogApprove","parameters":[{"$ref":"#/components/parameters/MaintenanceLogApproveId"}],"responses":{"200":{"$ref":"#/components/responses/MaintenanceLogMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/maintenance-logs/{maintenanceLog}/reject":{"patch":{"tags":["MaintenanceLogs"],"summary":"Rechazar mantenimiento","operationId":"maintenanceLogReject","parameters":[{"$ref":"#/components/parameters/MaintenanceLogApproveId"}],"responses":{"200":{"$ref":"#/components/responses/MaintenanceLogMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/incidents":{"get":{"tags":["Incidents"],"summary":"Listar incidentes","operationId":"incidentIndex","responses":{"200":{"$ref":"#/components/responses/IncidentCollectionResponse"},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"tags":["Incidents"],"summary":"Crear incidente","description":"Reglas de negocio adicionales en backend:\n- Evita duplicidad por trip_id + reported_at.\n- Evita duplicidad por vehicle_id + reported_at.\n","operationId":"incidentStore","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentCreateRequest"},"examples":{"motorista":{"summary":"Reporte de incidente por motorista","value":{"trip_id":10,"vehicle_id":2,"description":"Pinchazo en llanta delantera izquierda durante ruta.","reported_at":"2026-04-09 09:40:00"}}}}}},"responses":{"201":{"$ref":"#/components/responses/IncidentSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"}}}},"/api/v1/incidents/{incident}":{"parameters":[{"$ref":"#/components/parameters/IncidentId"}],"get":{"tags":["Incidents"],"summary":"Obtener incidente","operationId":"incidentShow","responses":{"200":{"$ref":"#/components/responses/IncidentSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"tags":["Incidents"],"summary":"Actualizar incidente","operationId":"incidentUpdate","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/IncidentSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"patch":{"tags":["Incidents"],"summary":"Actualizacion parcial de incidente","operationId":"incidentPatch","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentUpdateRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/IncidentSingleResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"}}},"delete":{"tags":["Incidents"],"summary":"Eliminar incidente","operationId":"incidentDestroy","responses":{"204":{"description":"Incidente eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/incidents/{incident}/resolve":{"patch":{"tags":["Incidents"],"summary":"Resolver incidente","operationId":"incidentResolve","parameters":[{"$ref":"#/components/parameters/IncidentId"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"resolution":{"type":"string","nullable":true,"maxLength":2000}}},"examples":{"supervisor":{"summary":"Resolucion por supervisor","value":{"resolution":"Se sustituyo la llanta y se autorizo continuar la ruta."}}}}}},"responses":{"200":{"$ref":"#/components/responses/IncidentMessageResponse"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"Token","description":"Token de acceso personal de Laravel Sanctum"}},"parameters":{"VehicleTypeId":{"name":"vehicle_type","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"VehicleId":{"name":"vehicle","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"TripId":{"name":"trip","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"FuelLogId":{"name":"fuel_log","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"FuelLogApproveId":{"name":"fuelLog","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"MaintenanceLogId":{"name":"maintenance_log","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"MaintenanceLogApproveId":{"name":"maintenanceLog","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"IncidentId":{"name":"incident","in":"path","required":true,"schema":{"type":"integer","minimum":1}}},"responses":{"Unauthorized":{"description":"No autenticado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"Unauthenticated."}}}},"Forbidden":{"description":"Sin permisos para esta accion","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"This action is unauthorized."}}}},"NotFound":{"description":"Recurso no encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"No query results for model"}}}},"ValidationError":{"description":"Error de validacion","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationErrorResponse"},"examples":{"base":{"value":{"message":"The given data was invalid.","errors":{"field":["The field is required."]}}},"trip_conflict":{"value":{"message":"The given data was invalid.","errors":{"driver_id":["Ese conductor ya tiene un viaje asignado para esa hora."]}}},"incident_conflict":{"value":{"message":"The given data was invalid.","errors":{"vehicle_id":["Ese vehiculo ya tiene un incidente registrado para esa misma hora."]}}}}}}},"VehicleTypeCollectionResponse":{"description":"Coleccion de tipos de vehiculo","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/VehicleType"}}}}}}},"VehicleTypeSingleResponse":{"description":"Recurso tipo de vehiculo","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/VehicleType"}}}}}},"VehicleCollectionResponse":{"description":"Coleccion de vehiculos","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Vehicle"}}}}}}},"VehicleSingleResponse":{"description":"Recurso vehiculo","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Vehicle"}}}}}},"TripCollectionResponse":{"description":"Coleccion de viajes","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Trip"}}}}}}},"TripSingleResponse":{"description":"Recurso viaje","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Trip"}}}}}},"TripMessageResponse":{"description":"Respuesta con mensaje y viaje","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Trip"},"message":{"type":"string"}}}}}},"FuelLogCollectionResponse":{"description":"Coleccion de registros de combustible","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/FuelLog"}}}}}}},"FuelLogSingleResponse":{"description":"Recurso registro de combustible","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FuelLog"}}}}}},"FuelLogMessageResponse":{"description":"Respuesta con mensaje y registro de combustible","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FuelLog"},"message":{"type":"string"}}}}}},"MaintenanceLogCollectionResponse":{"description":"Coleccion de mantenimientos","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MaintenanceLog"}}}}}}},"MaintenanceLogSingleResponse":{"description":"Recurso mantenimiento","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MaintenanceLog"}}}}}},"MaintenanceLogMessageResponse":{"description":"Respuesta con mensaje y mantenimiento","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MaintenanceLog"},"message":{"type":"string"}}}}}},"IncidentCollectionResponse":{"description":"Coleccion de incidentes","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Incident"}}}}}}},"IncidentSingleResponse":{"description":"Recurso incidente","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Incident"}}}}}},"IncidentMessageResponse":{"description":"Respuesta con mensaje e incidente","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Incident"},"message":{"type":"string"}}}}}}},"schemas":{"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"}}},"ValidationErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}},"LoginRequest":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string"}}},"AuthTokenResponse":{"type":"object","required":["token_type","token","user"],"properties":{"token_type":{"type":"string","example":"Bearer"},"token":{"type":"string"},"user":{"$ref":"#/components/schemas/User"}}},"User":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"role":{"type":"string"},"license_number":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"is_active":{"type":"boolean"},"email_verified_at":{"type":"string","format":"date-time","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"VehicleType":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"code":{"type":"string"},"maintenance_interval_km":{"type":"integer","minimum":1000},"tank_capacity":{"type":"number","minimum":10},"payload_capacity":{"type":"number","minimum":100},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"VehicleTypeCreateRequest":{"type":"object","required":["name","code","maintenance_interval_km","tank_capacity","payload_capacity"],"properties":{"name":{"type":"string","maxLength":255},"code":{"type":"string"},"maintenance_interval_km":{"type":"integer","minimum":1000},"tank_capacity":{"type":"number","minimum":10},"payload_capacity":{"type":"number","minimum":100}}},"VehicleTypeUpdateRequest":{"type":"object","properties":{"name":{"type":"string","maxLength":255},"code":{"type":"string"},"maintenance_interval_km":{"type":"integer","minimum":1000},"tank_capacity":{"type":"number","minimum":10},"payload_capacity":{"type":"number","minimum":100}}},"Vehicle":{"type":"object","properties":{"id":{"type":"integer"},"vehicle_type_id":{"type":"integer"},"plate_number":{"type":"string"},"brand":{"type":"string"},"model":{"type":"string"},"year":{"type":"integer","minimum":1900},"current_odometer":{"type":"integer","minimum":0,"nullable":true},"next_maintenance_km":{"type":"integer","minimum":0,"nullable":true},"status":{"type":"string","enum":["active","inactive","maintenance"]},"assigned_driver_id":{"type":"integer","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"vehicle_type":{"$ref":"#/components/schemas/VehicleType"},"assigned_driver":{"$ref":"#/components/schemas/User"}}},"VehicleCreateRequest":{"type":"object","required":["vehicle_type_id","plate_number","brand","model","year","status"],"properties":{"vehicle_type_id":{"type":"integer","minimum":1},"plate_number":{"type":"string"},"brand":{"type":"string","maxLength":255},"model":{"type":"string","maxLength":255},"year":{"type":"integer","minimum":1900},"status":{"type":"string","enum":["active","inactive","maintenance"]}}},"VehicleUpdateRequest":{"type":"object","properties":{"vehicle_type_id":{"type":"integer","minimum":1},"plate_number":{"type":"string"},"brand":{"type":"string","maxLength":255},"model":{"type":"string","maxLength":255},"year":{"type":"integer","minimum":1900},"status":{"type":"string","enum":["active","inactive","maintenance"]},"current_odometer":{"type":"integer","minimum":0},"assigned_driver_id":{"type":"integer","minimum":1,"nullable":true}}},"Trip":{"type":"object","properties":{"id":{"type":"integer"},"vehicle_id":{"type":"integer"},"driver_id":{"type":"integer"},"start_odometer":{"type":"integer","minimum":0},"end_odometer":{"type":"integer","minimum":0,"nullable":true},"start_time":{"type":"string","format":"date-time"},"end_time":{"type":"string","format":"date-time","nullable":true},"status":{"type":"string","enum":["scheduled","assigned","in_progress","pending_validation","completed","cancelled"]},"route_description":{"type":"string","maxLength":1000,"nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"vehicle":{"$ref":"#/components/schemas/Vehicle"},"driver":{"$ref":"#/components/schemas/User"}}},"TripCreateRequest":{"type":"object","required":["vehicle_id","driver_id","start_odometer","start_time"],"properties":{"vehicle_id":{"type":"integer","minimum":1},"driver_id":{"type":"integer","minimum":1},"start_odometer":{"type":"integer","minimum":0},"start_time":{"type":"string","format":"date-time","description":"Formato esperado Y-m-d H:i:s"},"route_description":{"type":"string","maxLength":1000}}},"TripUpdateRequest":{"type":"object","properties":{"end_odometer":{"type":"integer","minimum":0},"end_time":{"type":"string","format":"date-time","description":"Formato esperado Y-m-d H:i:s"},"status":{"type":"string","enum":["scheduled","in_progress","completed","cancelled"]},"route_description":{"type":"string","maxLength":1000}}},"TripAssignRequest":{"type":"object","required":["vehicle_id","driver_id"],"properties":{"vehicle_id":{"type":"integer","minimum":1},"driver_id":{"type":"integer","minimum":1},"start_time":{"type":"string","format":"date-time","description":"Formato esperado Y-m-d H:i:s"},"route_description":{"type":"string","maxLength":1000}}},"TripStartRequest":{"type":"object","required":["start_odometer"],"properties":{"start_odometer":{"type":"integer","minimum":0},"start_time":{"type":"string","format":"date-time","description":"Formato esperado Y-m-d H:i:s"}}},"TripCompleteRequest":{"type":"object","required":["end_odometer"],"properties":{"end_odometer":{"type":"integer","minimum":0},"end_time":{"type":"string","format":"date-time","description":"Formato esperado Y-m-d H:i:s"},"route_description":{"type":"string","maxLength":1000}}},"TripCancelRequest":{"type":"object","properties":{"reason":{"type":"string","maxLength":500}}},"FuelLog":{"type":"object","properties":{"id":{"type":"integer"},"trip_id":{"type":"integer"},"vehicle_id":{"type":"integer"},"user_id":{"type":"integer"},"liters":{"type":"number","minimum":0.01},"cost_per_liter":{"type":"number","minimum":0},"total_cost":{"type":"number","minimum":0},"station_name":{"type":"string"},"receipt_image":{"type":"string","nullable":true},"logged_at":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"trip":{"$ref":"#/components/schemas/Trip"},"vehicle":{"$ref":"#/components/schemas/Vehicle"},"user":{"$ref":"#/components/schemas/User"}}},"FuelLogCreateRequest":{"type":"object","required":["trip_id","vehicle_id","liters","cost_per_liter","station_name","logged_at"],"properties":{"trip_id":{"type":"integer","minimum":1},"vehicle_id":{"type":"integer","minimum":1},"liters":{"type":"number","minimum":0.01},"cost_per_liter":{"type":"number","minimum":0},"station_name":{"type":"string","maxLength":255},"receipt_image":{"type":"string"},"logged_at":{"type":"string","format":"date-time","description":"Formato esperado Y-m-d H:i:s"}}},"FuelLogUpdateRequest":{"type":"object","properties":{"liters":{"type":"number","minimum":0.01},"cost_per_liter":{"type":"number","minimum":0},"station_name":{"type":"string","maxLength":255},"receipt_image":{"type":"string","nullable":true}}},"MaintenanceLog":{"type":"object","properties":{"id":{"type":"integer"},"vehicle_id":{"type":"integer"},"user_id":{"type":"integer"},"type":{"type":"string"},"description":{"type":"string"},"cost":{"type":"number","minimum":0},"service_date":{"type":"string","format":"date"},"next_due_km":{"type":"integer","minimum":0,"nullable":true},"workshop_name":{"type":"string"},"status":{"type":"string","enum":["pending","approved","rejected"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"vehicle":{"$ref":"#/components/schemas/Vehicle"},"user":{"$ref":"#/components/schemas/User"}}},"MaintenanceLogCreateRequest":{"type":"object","required":["vehicle_id","type","description","cost","service_date","workshop_name"],"properties":{"vehicle_id":{"type":"integer","minimum":1},"type":{"type":"string","maxLength":255},"description":{"type":"string","maxLength":2000},"cost":{"type":"number","minimum":0},"service_date":{"type":"string","format":"date","description":"Formato esperado Y-m-d"},"workshop_name":{"type":"string","maxLength":255}}},"MaintenanceLogUpdateRequest":{"type":"object","properties":{"type":{"type":"string","maxLength":255},"description":{"type":"string","maxLength":2000},"cost":{"type":"number","minimum":0},"service_date":{"type":"string","format":"date","description":"Formato esperado Y-m-d"},"workshop_name":{"type":"string","maxLength":255},"status":{"type":"string","enum":["pending","approved","rejected"]}}},"Incident":{"type":"object","properties":{"id":{"type":"integer"},"trip_id":{"type":"integer"},"vehicle_id":{"type":"integer"},"user_id":{"type":"integer"},"description":{"type":"string"},"reported_at":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["reported","investigating","resolved","closed"]},"resolution":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"trip":{"$ref":"#/components/schemas/Trip"},"vehicle":{"$ref":"#/components/schemas/Vehicle"},"user":{"$ref":"#/components/schemas/User"}}},"IncidentCreateRequest":{"type":"object","required":["trip_id","vehicle_id","description","reported_at"],"properties":{"trip_id":{"type":"integer","minimum":1},"vehicle_id":{"type":"integer","minimum":1},"description":{"type":"string","maxLength":2000},"reported_at":{"type":"string","format":"date-time","description":"Formato esperado Y-m-d H:i:s"}}},"IncidentUpdateRequest":{"type":"object","properties":{"status":{"type":"string","enum":["reported","investigating","resolved","closed"]},"resolution":{"type":"string","maxLength":2000,"nullable":true}}}}}}