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:
parent
8bde7f8fc2
commit
625077f341
60 changed files with 3493 additions and 242 deletions
|
|
@ -2,6 +2,18 @@ use axum::{Json, extract::State};
|
|||
|
||||
use crate::{dto::DatabaseStatsResponse, error::ApiError, state::AppState};
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/admin/database/stats",
|
||||
tag = "database",
|
||||
responses(
|
||||
(status = 200, description = "Database statistics", body = DatabaseStatsResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn database_stats(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<DatabaseStatsResponse>, ApiError> {
|
||||
|
|
@ -16,6 +28,18 @@ pub async fn database_stats(
|
|||
}))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/admin/database/vacuum",
|
||||
tag = "database",
|
||||
responses(
|
||||
(status = 200, description = "Database vacuumed"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn vacuum_database(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
|
|
@ -23,6 +47,18 @@ pub async fn vacuum_database(
|
|||
Ok(Json(serde_json::json!({"status": "ok"})))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/admin/database/clear",
|
||||
tag = "database",
|
||||
responses(
|
||||
(status = 200, description = "Database cleared"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn clear_database(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue