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 9d58927cb4
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
60 changed files with 3493 additions and 242 deletions

View file

@ -3,12 +3,23 @@ use serde::Serialize;
use crate::{error::ApiError, state::AppState};
#[derive(Debug, Serialize)]
#[derive(Debug, Serialize, utoipa::ToSchema)]
pub struct WebhookInfo {
pub url: String,
pub events: Vec<String>,
}
#[utoipa::path(
get,
path = "/api/v1/webhooks",
tag = "webhooks",
responses(
(status = 200, description = "List of configured webhooks", body = Vec<WebhookInfo>),
(status = 401, description = "Unauthorized"),
(status = 403, description = "Forbidden"),
),
security(("bearer_auth" = []))
)]
pub async fn list_webhooks(
State(state): State<AppState>,
) -> Result<Json<Vec<WebhookInfo>>, ApiError> {
@ -26,6 +37,17 @@ pub async fn list_webhooks(
Ok(Json(hooks))
}
#[utoipa::path(
post,
path = "/api/v1/webhooks/test",
tag = "webhooks",
responses(
(status = 200, description = "Test webhook sent"),
(status = 401, description = "Unauthorized"),
(status = 403, description = "Forbidden"),
),
security(("bearer_auth" = []))
)]
pub async fn test_webhook(
State(state): State<AppState>,
) -> Result<Json<serde_json::Value>, ApiError> {