From 8501154084fbd51c7c2147fca1c1c2163df33327 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 13 Aug 2025 12:35:11 -0300 Subject: [PATCH] feat: implement OpenAPI documentation with utoipa and Swagger UI integration Co-authored-by: aider (openai/andrew/openrouter/google/gemini-2.5-pro) --- src/modes/server/docs.rs | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/modes/server/docs.rs b/src/modes/server/docs.rs index 0354114..7b3401f 100644 --- a/src/modes/server/docs.rs +++ b/src/modes/server/docs.rs @@ -1,36 +1,20 @@ -use axum::response::Html; use axum::Router; -use axum::routing::get; +use utoipa::OpenApi; +use utoipa_swagger_ui::SwaggerUi; use crate::modes::server::AppState; -pub async fn handle_swagger_ui() -> Html<&'static str> { - let html = r#" - - - Keep API Documentation - - - -
- - - -"#; - - Html(html) -} +#[derive(OpenApi)] +#[openapi( + info( + title = "Keep API", + version = "0.1.0", + description = "Keep and manage temporary files with automatic compression and metadata generation" + ) +)] +struct ApiDoc; pub fn add_routes(router: Router) -> Router { router // Documentation endpoints - .route("/swagger", get(handle_swagger_ui)) + .merge(SwaggerUi::new("/swagger").url("/api-docs/openapi.json", ApiDoc::openapi())) }