{"openapi":"3.0.3","info":{"title":"API Gestión Vehicular","version":"2.0","description":"API REST para la gestión de vehículos, documentos, personas, conductores, rutas, trayectos y cargues masivos.\n"},"servers":[{"url":"http://localhost:8080","description":"Servidor local de desarrollo"}],"security":[{"BearerAuth":[],"ApiKeyAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-KEY"}},"schemas":{"LoginRequest":{"type":"object","required":["login","password"],"properties":{"login":{"type":"string","example":"jp12345678"},"password":{"type":"string","example":"miClave123"}}},"LoginResponse":{"type":"object","properties":{"token":{"type":"string"},"apikey":{"type":"string"},"login":{"type":"string"}}},"Documento":{"type":"object","properties":{"id":{"type":"integer"},"nombre":{"type":"string"},"tipo":{"type":"string"},"estado":{"type":"string"},"fechaVencimiento":{"type":"string","format":"date"}}},"Vehiculo":{"type":"object","properties":{"id":{"type":"integer"},"placa":{"type":"string"},"tipo":{"type":"string"},"documentos":{"type":"array","items":{"$ref":"#/components/schemas/Documento"}}}},"Persona":{"type":"object","properties":{"id":{"type":"integer"},"nombre":{"type":"string"},"tipo":{"type":"string","enum":["C","A"]},"login":{"type":"string"}}},"TrayectoRequest":{"type":"object","required":["codigoRuta","orden","nombre","idVehiculo","idConductor"],"properties":{"codigoRuta":{"type":"string","example":"RUTA-001"},"orden":{"type":"integer","example":1},"nombre":{"type":"string","example":"Terminal Norte — Ibagué"},"descripcion":{"type":"string","example":"Punto de inicio"},"idVehiculo":{"type":"integer","example":1},"idConductor":{"type":"integer","example":2}}},"CargueResponse":{"type":"object","properties":{"idCargue":{"type":"integer","format":"int64","example":1718000000000},"filasLeidas":{"type":"integer"},"filasValidadas":{"type":"integer"},"filasRechazadas":{"type":"integer"},"filasProcesadas":{"type":"integer"},"mensaje":{"type":"string"},"detalle":{"type":"array","items":{"type":"object","properties":{"codigoRuta":{"type":"string"},"estado":{"type":"string","enum":["PROCESADO","RECHAZADO","VALIDADO"]},"observacion":{"type":"string"}}}}}},"Error":{"type":"object","properties":{"codigo":{"type":"integer"},"mensaje":{"type":"string"}}}},"responses":{"Unauthorized":{"description":"Token ausente o inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"APIKey inválida o ausente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"BadRequest":{"description":"Petición inválida (datos faltantes)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InternalError":{"description":"Error de validación de negocio","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/auth/login":{"post":{"tags":["Autenticación"],"summary":"Login de usuario","description":"Devuelve token JWT, apikey y login. Endpoint público.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}}},"responses":{"200":{"description":"Login exitoso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"}}}},"/api/documentos":{"post":{"tags":["Documentos"],"summary":"Crear documento paramétrico","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"responses":{"201":{"description":"Documento creado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"get":{"tags":["Documentos"],"summary":"Listar documentos","responses":{"200":{"description":"Lista de documentos","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Documento"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/documentos/{id}":{"put":{"tags":["Documentos"],"summary":"Actualizar documento","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"responses":{"200":{"description":"Documento actualizado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"delete":{"tags":["Documentos"],"summary":"Eliminar documento","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"204":{"description":"Documento eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos":{"post":{"tags":["Vehículos"],"summary":"Crear vehículo (documento obligatorio)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Vehiculo"}}}},"responses":{"201":{"description":"Vehículo creado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Vehiculo"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"get":{"tags":["Vehículos"],"summary":"Listar vehículos","responses":{"200":{"description":"Lista de vehículos","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Vehiculo"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/{id}":{"get":{"tags":["Vehículos"],"summary":"Obtener vehículo por ID","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Vehículo encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Vehiculo"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"put":{"tags":["Vehículos"],"summary":"Actualizar vehículo","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Vehiculo"}}}},"responses":{"200":{"description":"Vehículo actualizado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Vehiculo"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"delete":{"tags":["Vehículos"],"summary":"Eliminar vehículo","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"204":{"description":"Vehículo eliminado"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/placa/{placa}":{"get":{"tags":["Vehículos"],"summary":"Buscar vehículo por placa","security":[],"parameters":[{"name":"placa","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Vehículo encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Vehiculo"}}}}}}},"/api/vehiculos/tipo/{tipo}":{"get":{"tags":["Vehículos"],"summary":"Buscar vehículos por tipo","parameters":[{"name":"tipo","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Lista de vehículos","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Vehiculo"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/documento/{documentoId}":{"get":{"tags":["Vehículos"],"summary":"Vehículos con un tipo de documento","parameters":[{"name":"documentoId","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Lista de vehículos","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Vehiculo"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/estado-documento/{estado}":{"get":{"tags":["Vehículos"],"summary":"Vehículos por estado de documento","parameters":[{"name":"estado","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Lista de vehículos","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Vehiculo"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/{id}/documentos":{"post":{"tags":["Vehículos"],"summary":"Agregar documento a vehículo","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"responses":{"201":{"description":"Documento agregado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Vehiculo"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/conductores-activos":{"get":{"tags":["Vehículos"],"summary":"Conductores que pueden operar (estado PO)","security":[],"responses":{"200":{"description":"Lista de conductores activos","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Persona"}}}}}}}},"/api/vehiculos/documentos/carga":{"post":{"tags":["Vehículos"],"summary":"Cargar PDFs en Base64","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"idVehiculo":{"type":"integer"},"archivos":{"type":"array","items":{"type":"string","format":"byte"}}}}}}},"responses":{"200":{"description":"PDFs cargados"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/documentos-vencidos":{"get":{"tags":["Vehículos"],"summary":"Documentos vencidos","security":[],"responses":{"200":{"description":"Lista de documentos vencidos","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Documento"}}}}}}}},"/api/vehiculos/documentos-por-vencer":{"get":{"tags":["Vehículos"],"summary":"Documentos por vencer en N días","security":[],"parameters":[{"name":"dias","in":"query","required":true,"schema":{"type":"integer"},"example":30}],"responses":{"200":{"description":"Lista de documentos por vencer","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Documento"}}}}}}}},"/api/personas":{"post":{"tags":["Personas"],"summary":"Crear persona (genera usuario si es tipo A)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Persona"}}}},"responses":{"201":{"description":"Persona creada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Persona"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"get":{"tags":["Personas"],"summary":"Listar personas","responses":{"200":{"description":"Lista de personas","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Persona"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/personas/{id}":{"get":{"tags":["Personas"],"summary":"Obtener persona por ID","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Persona encontrada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Persona"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"put":{"tags":["Personas"],"summary":"Actualizar persona","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Persona"}}}},"responses":{"200":{"description":"Persona actualizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Persona"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/personas/tipo/{tipo}":{"get":{"tags":["Personas"],"summary":"Listar personas por tipo (C/A)","parameters":[{"name":"tipo","in":"path","required":true,"schema":{"type":"string","enum":["C","A"]}}],"responses":{"200":{"description":"Lista de personas por tipo","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Persona"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/personas/conteo-por-tipo":{"get":{"tags":["Personas"],"summary":"Total de personas agrupadas por tipo","security":[],"responses":{"200":{"description":"Conteo por tipo","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"type":"integer"}}}}}}}},"/api/usuarios/{login}/password":{"put":{"tags":["Usuarios"],"summary":"Cambiar contraseña","parameters":[{"name":"login","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"passwordActual":{"type":"string"},"passwordNueva":{"type":"string"}}}}}},"responses":{"200":{"description":"Contraseña actualizada"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/usuarios/{login}/apikey":{"get":{"tags":["Usuarios"],"summary":"Regenerar APIKey","parameters":[{"name":"login","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Nueva APIKey","content":{"application/json":{"schema":{"type":"object","properties":{"apikey":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/vehiculos/{idVehiculo}/conductores/{idPersona}":{"post":{"tags":["Conductores"],"summary":"Asociar conductor a vehículo (estado inicial EA)","parameters":[{"name":"idVehiculo","in":"path","required":true,"schema":{"type":"integer"}},{"name":"idPersona","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"201":{"description":"Conductor asociado"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/vehiculos/{idVehiculo}/conductores/{idPersona}/estado":{"put":{"tags":["Conductores"],"summary":"Cambiar estado conductor (PO / EA / RO)","parameters":[{"name":"idVehiculo","in":"path","required":true,"schema":{"type":"integer"}},{"name":"idPersona","in":"path","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"estado":{"type":"string","enum":["PO","EA","RO"]}}}}}},"responses":{"200":{"description":"Estado actualizado"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/vehiculos/{idVehiculo}/conductores":{"get":{"tags":["Conductores"],"summary":"Conductores de un vehículo","parameters":[{"name":"idVehiculo","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Lista de conductores","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Persona"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/rutas/trayectos":{"post":{"tags":["Rutas"],"summary":"Crear trayecto (valida doc HABILITADO + conductor PO)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrayectoRequest"}}}},"responses":{"201":{"description":"Trayecto creado"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/rutas/{codigo}":{"get":{"tags":["Rutas"],"summary":"Consulta 1: trayectos de una ruta en orden","parameters":[{"name":"codigo","in":"path","required":true,"schema":{"type":"string"},"example":"RUTA-001"}],"responses":{"200":{"description":"Trayectos de la ruta ordenados","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TrayectoRequest"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/rutas/conductor/{idConductor}":{"get":{"tags":["Rutas"],"summary":"Consulta 2: rutas agrupadas de un conductor","parameters":[{"name":"idConductor","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Rutas del conductor","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/rutas/vehiculo/{placa}":{"get":{"tags":["Rutas"],"summary":"Consulta 3: rutas agrupadas por placa","parameters":[{"name":"placa","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Rutas del vehículo","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/rutas/no-habilitados":{"get":{"tags":["Rutas"],"summary":"Consulta 4: trayectos con vehículo no habilitado o conductor RO","responses":{"200":{"description":"Trayectos con irregularidades","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/cargues/trayectos":{"post":{"tags":["Cargues"],"summary":"Carga masiva de trayectos vía Excel","description":"Sube una plantilla .xlsx y ejecuta el proceso CARGUE → VALIDACION → PROCESADO.\n","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"archivo":{"type":"string","format":"binary"}}}}}},"responses":{"200":{"description":"Resultado del cargue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CargueResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/api/cargues/{idCargue}":{"get":{"tags":["Cargues"],"summary":"Consultar resultado de un cargue","parameters":[{"name":"idCargue","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Resultado del cargue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CargueResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}}}}}