pinakes-server: add utoipa annotations to all routes; fix tests

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I28cf5b7b7cff8e90e123d624d97cf9656a6a6964
This commit is contained in:
raf 2026-03-21 02:17:55 +03:00
commit 625077f341
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
60 changed files with 3493 additions and 242 deletions

View file

@ -5,6 +5,17 @@ use axum::{
use crate::{dto::ScheduledTaskResponse, error::ApiError, state::AppState};
#[utoipa::path(
get,
path = "/api/v1/scheduled-tasks",
tag = "scheduled_tasks",
responses(
(status = 200, description = "List of scheduled tasks", body = Vec<ScheduledTaskResponse>),
(status = 401, description = "Unauthorized"),
(status = 403, description = "Forbidden"),
),
security(("bearer_auth" = []))
)]
pub async fn list_scheduled_tasks(
State(state): State<AppState>,
) -> Result<Json<Vec<ScheduledTaskResponse>>, ApiError> {
@ -26,6 +37,19 @@ pub async fn list_scheduled_tasks(
Ok(Json(responses))
}
#[utoipa::path(
post,
path = "/api/v1/scheduled-tasks/{id}/toggle",
tag = "scheduled_tasks",
params(("id" = String, Path, description = "Task ID")),
responses(
(status = 200, description = "Task toggled"),
(status = 401, description = "Unauthorized"),
(status = 403, description = "Forbidden"),
(status = 404, description = "Not found"),
),
security(("bearer_auth" = []))
)]
pub async fn toggle_scheduled_task(
State(state): State<AppState>,
Path(id): Path<String>,
@ -45,6 +69,19 @@ pub async fn toggle_scheduled_task(
}
}
#[utoipa::path(
post,
path = "/api/v1/scheduled-tasks/{id}/run",
tag = "scheduled_tasks",
params(("id" = String, Path, description = "Task ID")),
responses(
(status = 200, description = "Task triggered"),
(status = 401, description = "Unauthorized"),
(status = 403, description = "Forbidden"),
(status = 404, description = "Not found"),
),
security(("bearer_auth" = []))
)]
pub async fn run_scheduled_task_now(
State(state): State<AppState>,
Path(id): Path<String>,