We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cecda05 commit c2e9f45Copy full SHA for c2e9f45
3 files changed
utoipa-swagger-ui/CHANGELOG.md
@@ -2,6 +2,10 @@
2
3
## Unreleased
4
5
+### Fixed
6
+
7
+* Avoid cloning ApiDoc on every request for axum (https://github.com/juhaku/utoipa/pull/1393)
8
9
### Changed
10
11
* Update build dependency `zip` to v3.0 (https://github.com/juhaku/utoipa/pull/1391)
utoipa-swagger-ui/Cargo.toml
@@ -32,7 +32,7 @@ axum = { version = "0.8.0", default-features = false, features = [
32
utoipa = { version = "5.0.0", path = "../utoipa", default-features = false, features = [
33
"macros",
34
] }
35
-serde = { version = "1.0", features = ["derive"] }
+serde = { version = "1.0", features = ["derive", "rc"] }
36
serde_json = { version = "1.0" }
37
base64 = { version = "0.22.1" }
38
utoipa-swagger-ui/src/axum.rs
@@ -28,13 +28,13 @@ where
28
Vec::<Url>::with_capacity(urls_capacity + external_urls_capacity),
29
),
30
|router_and_urls, (url, openapi)| {
31
- add_api_doc_to_urls(router_and_urls, (url, ApiDoc::Utoipa(openapi)))
+ add_api_doc_to_urls(router_and_urls, (url, Arc::new(ApiDoc::Utoipa(openapi))))
},
);
let (router, urls) = swagger_ui.external_urls.into_iter().fold(
(router, urls),
- add_api_doc_to_urls(router_and_urls, (url, ApiDoc::Value(openapi)))
+ add_api_doc_to_urls(router_and_urls, (url, Arc::new(ApiDoc::Value(openapi))))
39
40
@@ -108,7 +108,7 @@ where
108
109
fn add_api_doc_to_urls<S>(
110
router_and_urls: (Router<S>, Vec<Url<'static>>),
111
- url: (Url<'static>, ApiDoc),
+ url: (Url<'static>, Arc<ApiDoc>),
112
) -> (Router<S>, Vec<Url<'static>>)
113
where
114
S: Clone + Send + Sync + 'static,
0 commit comments