From c9f4c1af31d32add57ad932ff35e9463211e09c6 Mon Sep 17 00:00:00 2001 From: drbh Date: Tue, 20 Feb 2024 10:38:35 -0500 Subject: [PATCH] fix: refactor syntax to correctly include structs (#1580) This PR fixes a compilation bug related to conditionally adding docs behind a feature flag --- router/src/server.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/router/src/server.rs b/router/src/server.rs index 140fb014..054ba5a2 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -1037,20 +1037,21 @@ pub async fn run( }; // Define VertextApiDoc conditionally only if the "google" feature is enabled - #[cfg(feature = "google")] - #[derive(OpenApi)] - #[openapi( - paths(vertex_compatibility), - components(schemas(VertexInstance, VertexRequest, VertexResponse)) - )] - struct VertextApiDoc; - let doc = { // avoid `mut` if possible #[cfg(feature = "google")] { + use crate::VertexInstance; + + #[derive(OpenApi)] + #[openapi( + paths(vertex_compatibility), + components(schemas(VertexInstance, VertexRequest, VertexResponse)) + )] + struct VertextApiDoc; + // limiting mutability to the smallest scope necessary - let mut doc = doc; + let mut doc = ApiDoc::openapi(); doc.merge(VertextApiDoc::openapi()); doc }