openapi: 3.0.3 info: title: API Autenticacion de Empleados version: 1.0.0 description: Contrato de autenticacion y autorizacion para empleados/admin en API versionada. servers: - url: http://localhost:8080 security: - basicAuth: [] paths: /api/v1/auth/login: post: summary: Validar credenciales de empleado operationId: loginEmpleado security: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AuthLoginRequest' responses: '200': description: Credenciales validas content: application/json: schema: $ref: '#/components/schemas/AuthLoginResponse' '401': description: Credenciales invalidas o empleado no autenticable '400': description: Error de validacion de entrada /api/v1/empleados: get: summary: Listar empleados operationId: listarEmpleados security: - basicAuth: [] parameters: - name: page in: query required: false schema: type: integer minimum: 0 default: 0 - name: limit in: query required: false schema: type: integer minimum: 1 maximum: 100 default: 20 responses: '200': description: Lista de empleados adaptada por rol content: application/json: schema: oneOf: - type: array items: $ref: '#/components/schemas/EmpleadoResumenResponse' - type: array items: $ref: '#/components/schemas/EmpleadoAdminResponse' '401': description: No autenticado /api/v1/empleados/{clave}: parameters: - name: clave in: path required: true schema: type: string pattern: '^EMP-[0-9]+$' put: summary: Actualizar empleado y/o asignar credenciales iniciales (solo ADMIN) operationId: actualizarEmpleadoAdmin security: - basicAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/EmpleadoAdminUpdateRequest' responses: '200': description: Empleado actualizado content: application/json: schema: $ref: '#/components/schemas/EmpleadoAdminResponse' '400': description: Error de validacion (incluye politica de contrasena) '401': description: No autenticado '403': description: Sin permisos '404': description: Empleado no encontrado components: securitySchemes: basicAuth: type: http scheme: basic schemas: AuthLoginRequest: type: object required: [email, password] properties: email: type: string format: email maxLength: 255 password: type: string minLength: 8 description: Debe contener al menos 1 letra y 1 numero. pattern: '^(?=.*[A-Za-z])(?=.*\\d).{8,}$' AuthLoginResponse: type: object required: [authenticated, role] properties: authenticated: type: boolean role: type: string enum: [ADMIN, USER] clave: type: string nullable: true pattern: '^EMP-[0-9]+$' email: type: string format: email nullable: true EmpleadoResumenResponse: type: object required: [clave, nombre] properties: clave: type: string pattern: '^EMP-[0-9]+$' nombre: type: string maxLength: 100 departamentoNombre: type: string nullable: true EmpleadoAdminResponse: type: object required: [clave, nombre, direccion, telefono, activo] properties: clave: type: string pattern: '^EMP-[0-9]+$' nombre: type: string maxLength: 100 direccion: type: string maxLength: 100 telefono: type: string maxLength: 100 email: type: string format: email nullable: true activo: type: boolean EmpleadoAdminUpdateRequest: type: object required: [nombre, direccion, telefono] properties: nombre: type: string minLength: 1 maxLength: 100 direccion: type: string minLength: 1 maxLength: 100 telefono: type: string minLength: 1 maxLength: 100 email: type: string format: email maxLength: 255 initialPassword: type: string nullable: true pattern: '^(?=.*[A-Za-z])(?=.*\\d).{8,}$' description: Solo para asignacion explicita por ADMIN.