From 3651130e5bf67dc141d81c15e995d191406a4ece Mon Sep 17 00:00:00 2001 From: Shun Kakinoki Date: Sun, 20 Oct 2024 03:49:10 +0900 Subject: [PATCH] Revert "Remove Redirect Causing Invalid URIs for Swagger UIs Server on / (#1043)" This reverts commit a985d8c1340f80ab69b2b0e5de799df98d567732. --- utoipa-swagger-ui/src/axum.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utoipa-swagger-ui/src/axum.rs b/utoipa-swagger-ui/src/axum.rs index 22a31793..5315fc3f 100644 --- a/utoipa-swagger-ui/src/axum.rs +++ b/utoipa-swagger-ui/src/axum.rs @@ -44,9 +44,13 @@ where let handler = routing::get(serve_swagger_ui).layer(Extension(Arc::new(config))); let path: &str = swagger_ui.path.as_ref(); + let slash_path = format!("{}/", path); router - .route(path, handler.clone()) + .route( + path, + routing::get(|| async move { axum::response::Redirect::to(&slash_path) }), + ) .route(&format!("{}/", path), handler.clone()) .route(&format!("{}/*rest", path), handler) }