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) }