feat(api): implement pull request assignees and check runs endpoints
- Add PR assignees API with list, assign, and unassign operations - Add PR check runs API with create, update, list, and delete operations - Implement workspace finding by ID method in core service - Update .gitignore to include .env* files while preserving .env.example - Reorder imports in multiple API files for consistency - Format function calls with proper line breaks across PR-related APIs - Add wiki revision comparison endpoint with proper schema definitions - Integrate new API modules into main application setup - Add health check, readiness probe, and OpenAPI endpoints to main server - Configure session management and dependency injection in main application
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
use actix_web::{HttpResponse, web};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use utoipa::{IntoParams, ToSchema};
|
||||
|
||||
use crate::api::response::{ApiErrorResponse, ApiResponse};
|
||||
use crate::error::AppError;
|
||||
use crate::models::wiki::WikiPageRevision;
|
||||
use crate::service::AppService;
|
||||
use crate::session::Session;
|
||||
|
||||
#[derive(Debug, Deserialize, IntoParams)]
|
||||
pub struct PathParams {
|
||||
/// Workspace name (unique identifier)
|
||||
pub workspace_name: String,
|
||||
/// Repository name (unique within the workspace)
|
||||
pub repo_name: String,
|
||||
/// Wiki page slug (URL-friendly identifier)
|
||||
pub slug: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, IntoParams)]
|
||||
pub struct QueryParams {
|
||||
/// Older version number to compare from
|
||||
pub old_version: i32,
|
||||
/// Newer version number to compare to
|
||||
pub new_version: i32,
|
||||
}
|
||||
|
||||
/// Result of comparing two wiki page revisions
|
||||
#[derive(Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct WikiCompareResult {
|
||||
/// The older revision being compared
|
||||
pub old: WikiPageRevision,
|
||||
/// The newer revision being compared
|
||||
pub new: WikiPageRevision,
|
||||
}
|
||||
|
||||
/// Compare two wiki page revisions
|
||||
///
|
||||
/// Compares two versions of a wiki page and returns both revisions.
|
||||
/// Requires read access to the repository.
|
||||
///
|
||||
/// Returns the old and new revisions for client-side diff computation.
|
||||
/// The client can compute the diff between the two content snapshots.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}/compare",
|
||||
tag = "Wiki",
|
||||
operation_id = "wikiCompareRevisions",
|
||||
params(PathParams, QueryParams),
|
||||
responses(
|
||||
(status = 200, description = "Revisions compared successfully. Returns old and new revision objects.", body = ApiResponse<WikiCompareResult>),
|
||||
(status = 400, description = "Invalid version numbers", body = ApiErrorResponse),
|
||||
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
|
||||
(status = 403, description = "Insufficient permissions to access this repository", body = ApiErrorResponse),
|
||||
(status = 404, description = "Wiki page, revisions, repository, or workspace not found", body = ApiErrorResponse),
|
||||
(status = 500, description = "Internal server error", body = ApiErrorResponse),
|
||||
),
|
||||
security(("session_cookie" = []))
|
||||
)]
|
||||
pub async fn compare_revisions(
|
||||
service: web::Data<AppService>,
|
||||
session: Session,
|
||||
path: web::Path<PathParams>,
|
||||
query: web::Query<QueryParams>,
|
||||
) -> Result<HttpResponse, AppError> {
|
||||
let (old, new) = service
|
||||
.repo
|
||||
.wiki_compare_revisions(
|
||||
&session,
|
||||
&path.workspace_name,
|
||||
&path.repo_name,
|
||||
&path.slug,
|
||||
query.old_version,
|
||||
query.new_version,
|
||||
)
|
||||
.await?;
|
||||
Ok(HttpResponse::Ok().json(ApiResponse::new(WikiCompareResult { old, new })))
|
||||
}
|
||||
Reference in New Issue
Block a user