fix: refactor syntax to correctly include structs (#1580)

This PR fixes a compilation bug related to conditionally adding docs
behind a feature flag
This commit is contained in:
drbh 2024-02-20 10:38:35 -05:00 committed by GitHub
parent df23062574
commit c9f4c1af31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 9 deletions

View File

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