openapi: 3.0.3 info: title: API Admin Departamentos y Movimiento de Empleados version: 1.0.0 description: Contrato para CRUD administrativo de departamentos y movimiento manual de empleados. servers: - url: http://localhost:8080 security: - bearerAuth: [] paths: /auth/login: post: summary: Iniciar sesion operationId: login 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' '401': $ref: '#/components/responses/Unauthorized' /api/departamentos: get: summary: Listar departamentos operationId: listDepartamentos parameters: - name: includeInactive in: query required: false schema: type: boolean default: false description: Si es true, incluye departamentos inactivos. responses: '200': description: Lista de departamentos content: application/json: schema: type: array items: $ref: '#/components/schemas/DepartamentoResponse' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' post: summary: Crear departamento (solo Admin) operationId: createDepartamento requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/DepartamentoUpsertRequest' responses: '201': description: Departamento creado content: application/json: schema: $ref: '#/components/schemas/DepartamentoResponse' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' /api/departamentos/{departamentoId}: parameters: - name: departamentoId in: path required: true schema: type: integer format: int64 put: summary: Editar departamento (solo Admin) operationId: updateDepartamento requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/DepartamentoUpsertRequest' responses: '200': description: Departamento actualizado content: application/json: schema: $ref: '#/components/schemas/DepartamentoResponse' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' delete: summary: Inactivar departamento (solo Admin) operationId: deleteDepartamento responses: '204': description: Departamento inactivado '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' /api/empleados/{clave}/departamento: parameters: - name: clave in: path required: true schema: type: string pattern: '^EMP-[0-9]+$' put: summary: Mover empleado a departamento activo (solo Admin) operationId: assignEmpleadoDepartamento requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AsignacionRequest' responses: '200': description: Movimiento aplicado content: application/json: schema: $ref: '#/components/schemas/AsignacionResponse' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' delete: summary: Desasignar empleado (sin departamento) (solo Admin) operationId: unassignEmpleadoDepartamento responses: '204': description: Empleado desasignado '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: token schemas: LoginRequest: type: object required: [usuario, contrasena] properties: usuario: type: string contrasena: type: string LoginResponse: type: object required: [token, tokenType, expiresInSeconds, usuario, role] properties: token: type: string tokenType: type: string example: Bearer expiresInSeconds: type: integer usuario: type: string role: type: string enum: [ADMIN, EMPLEADO] DepartamentoResponse: type: object required: [id, nombre, activo] properties: id: type: integer format: int64 nombre: type: string descripcion: type: string nullable: true activo: type: boolean DepartamentoUpsertRequest: type: object required: [nombre] properties: nombre: type: string minLength: 1 descripcion: type: string nullable: true AsignacionRequest: type: object required: [departamentoId] properties: departamentoId: type: integer format: int64 AsignacionResponse: type: object required: [empleadoClave] properties: empleadoClave: type: string departamentoId: type: integer format: int64 nullable: true departamentoNombre: type: string nullable: true ErrorResponse: type: object properties: code: type: string message: type: string details: type: array items: type: string responses: BadRequest: description: Solicitud invalida content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' Unauthorized: description: Credenciales invalidas o sesion no valida content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' Forbidden: description: Permisos insuficientes content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' NotFound: description: Recurso no encontrado content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' Conflict: description: Conflicto de negocio o concurrencia content: application/json: schema: $ref: '#/components/schemas/ErrorResponse'