use actix_web::{HttpResponse, web}; use serde::Deserialize; use utoipa::IntoParams; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::models::issues::IssueLabelRelation; 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, } #[derive(Debug, Deserialize, IntoParams)] pub struct QueryParams { /// Maximum number of label relations to return (default: 50, max: 100) pub limit: Option, /// Number of label relations to skip for pagination (default: 0) pub offset: Option, } /// List labels assigned to an issue /// /// Returns a paginated list of all label relations for the given issue. /// Shows which labels are attached to the issue, with assignment metadata. /// Requires read access to the issue. #[utoipa::path( get, path = "/api/v1/workspaces/{workspace_name}/issues/{number}/labels", tag = "Issues", operation_id = "issueListLabelRelations", params(PathParams, QueryParams), responses( (status = 200, description = "Label relations listed successfully. Returns array of label relation objects with metadata.", body = ApiResponse>), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Insufficient permissions to view this issue", body = ApiErrorResponse), (status = 404, description = "Issue not found", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn list_issue_labels( service: web::Data, session: Session, path: web::Path, query: web::Query, ) -> Result { let rels = service .issue .issue_label_relations( &session, &path.workspace_name, path.number, query.limit.unwrap_or(50), query.offset.unwrap_or(0), ) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new(rels))) }