From 21026f0ca83bc783ba6ad14db9df953827203ec7 Mon Sep 17 00:00:00 2001 From: Tamo Date: Mon, 6 Jan 2025 12:09:07 +0100 Subject: [PATCH] move the swagger behind a feature flag --- crates/meilisearch/Cargo.toml | 3 ++- crates/meilisearch/src/routes/mod.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/meilisearch/Cargo.toml b/crates/meilisearch/Cargo.toml index 86a83b741..fb058c4cb 100644 --- a/crates/meilisearch/Cargo.toml +++ b/crates/meilisearch/Cargo.toml @@ -106,7 +106,7 @@ build-info = { version = "1.7.0", path = "../build-info" } roaring = "0.10.7" mopa-maintained = "0.2.3" utoipa = { version = "5.2.0", features = ["actix_extras", "macros", "non_strict_integers", "preserve_order", "uuid", "time", "openapi_extensions"] } -utoipa-scalar = { version = "0.2.0", features = ["actix-web"] } +utoipa-scalar = { version = "0.2.0", optional = true, features = ["actix-web"] } [dev-dependencies] actix-rt = "2.10.0" @@ -135,6 +135,7 @@ zip = { version = "2.1.3", optional = true } [features] default = ["meilisearch-types/all-tokenizations", "mini-dashboard"] +swagger = ["utoipa-scalar"] mini-dashboard = [ "static-files", "anyhow", diff --git a/crates/meilisearch/src/routes/mod.rs b/crates/meilisearch/src/routes/mod.rs index b0d6ac17f..131986712 100644 --- a/crates/meilisearch/src/routes/mod.rs +++ b/crates/meilisearch/src/routes/mod.rs @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use tracing::debug; use utoipa::{OpenApi, ToSchema}; -use utoipa_scalar::{Scalar, Servable as ScalarServable}; use self::api_key::KeyView; use self::indexes::documents::BrowseQuery; @@ -102,11 +101,12 @@ pub fn configure(cfg: &mut web::ServiceConfig) { .service(web::scope("/metrics").configure(metrics::configure)) .service(web::scope("/experimental-features").configure(features::configure)); - let now = std::time::Instant::now(); - let openapi = MeilisearchApi::openapi(); - println!("Took {:?} to generate the openapi file", now.elapsed()); - // #[cfg(feature = "webp")] - cfg.service(Scalar::with_url("/scalar", openapi.clone())); + #[cfg(feature = "swagger")] + { + use utoipa_scalar::{Scalar, Servable as ScalarServable}; + let openapi = MeilisearchApi::openapi(); + cfg.service(Scalar::with_url("/scalar", openapi.clone())); + } } pub fn get_task_id(req: &HttpRequest, opt: &Opt) -> Result, ResponseError> {