From 1baf0ffcae9d11a2ded9d41817f29778098ae5cf 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/src/router.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utoipa-axum/src/router.rs b/utoipa-axum/src/router.rs index ad3a5069..b30342dd 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.clone() { + 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