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::service::repo::core::UpdateRepoParams; use crate::session::Session; #[derive(Debug, Deserialize, IntoParams)] pub struct PathParams { pub workspace_name: String, pub repo_name: String, } #[derive(Debug, Deserialize, utoipa::ToSchema)] pub struct TopicsBody { pub topics: Vec, } #[utoipa::path( put, path = "/api/v1/workspaces/{workspace_name}/repos/{repo_name}/topics", tag = "Repos", operation_id = "repoUpdateTopics", params(PathParams), request_body(content = TopicsBody), responses( (status = 200, description = "Topics updated", body = ApiResponse>), (status = 401, description = "Unauthorized", body = ApiErrorResponse), (status = 404, description = "Repo not found", body = ApiErrorResponse), ), security(("session_cookie" = [])) )] pub async fn update_topics( service: web::Data, session: Session, path: web::Path, body: web::Json, ) -> Result { let result = service .repo .repo_update( &session, &path.workspace_name, &path.repo_name, UpdateRepoParams { name: None, description: None, visibility: None, default_branch: None, topics: Some(body.topics.clone()), homepage: None, has_issues: None, has_wiki: None, has_pull_requests: None, allow_forking: None, allow_merge_commit: None, allow_squash_merge: None, allow_rebase_merge: None, delete_branch_on_merge: None, }, ) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new(result.topics))) }