use actix_web::{HttpResponse, web}; use serde::Deserialize; use utoipa::IntoParams; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::service::AppService; use crate::session::Session; #[derive(Debug, Deserialize, IntoParams)] pub struct PathParams { /// Workspace name (unique identifier) pub workspace_name: String, /// Issue number (unique within the workspace) pub number: i64, /// Label ID (UUID) to unassign pub label_id: uuid::Uuid, } /// Unassign a label from an issue /// /// Removes a label from the given issue. /// Requires write access to the issue (author or workspace member). /// /// Effects: /// - Label relation is removed from the issue /// - Issue label count is decremented /// /// Returns success message on completion. #[utoipa::path( delete, path = "/api/v1/workspaces/{workspace_name}/issues/{number}/labels/{label_id}", tag = "Issues", operation_id = "issueUnassignLabel", params(PathParams), responses( (status = 200, description = "Label unassigned successfully.", body = ApiResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Insufficient permissions to edit this issue", body = ApiErrorResponse), (status = 404, description = "Label is not assigned to this issue or not found", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn unassign_label( service: web::Data, session: Session, path: web::Path, ) -> Result { service .issue .issue_unassign_label(&session, &path.workspace_name, path.number, path.label_id) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new("Label unassigned".to_string()))) }