From 63f4c8c60bacc890cd8d0af666141ba3c1b1ab62 Mon Sep 17 00:00:00 2001 From: Henk Oordt Date: Mon, 28 Oct 2024 10:29:41 +0100 Subject: [PATCH] Merge paths if they already are added to the paths map --- utoipa-axum/CHANGELOG.md | 4 ++++ utoipa-axum/src/router.rs | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/utoipa-axum/CHANGELOG.md b/utoipa-axum/CHANGELOG.md index 6f28c305..609c096b 100644 --- a/utoipa-axum/CHANGELOG.md +++ b/utoipa-axum/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog - utoipa-axum +## Unreleased + +* Merge paths if they already are added to the paths map in utoipa-axum (https://github.com/juhaku/utoipa/pull/1171) + ## 0.1.1 - Oct 16 2024 ### Changed diff --git a/utoipa-axum/src/router.rs b/utoipa-axum/src/router.rs index ad3a5069..31533e0a 100644 --- a/utoipa-axum/src/router.rs +++ b/utoipa-axum/src/router.rs @@ -253,8 +253,15 @@ where }) }; - // add current paths to the OpenApi - self.1.paths.paths.extend(paths.paths.clone()); + // add or merge current paths to the OpenApi + for (path, item) in paths.paths { + if let Some(it) = self.1.paths.paths.get_mut(&path) { + it.merge_operations(item); + } else { + self.1.paths.paths.insert(path, item); + } + } + let components = self .1 .components