feat: Make swagger an optional dependency, enabled by default

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-10 10:24:21 -03:00
parent ea817ad629
commit 146bd2e569
2 changed files with 15 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
#[cfg(feature = "swagger")]
pub mod item;
pub mod status;
#[cfg(feature = "mcp")]
@@ -10,6 +11,8 @@ use axum::{
use crate::modes::server::common::AppState;
use utoipa::OpenApi;
#[cfg(feature = "swagger")]
use utoipa_swagger_ui::SwaggerUi;
#[derive(OpenApi)]
@@ -75,7 +78,13 @@ pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
router
}
#[cfg(feature = "swagger")]
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
router
.merge(SwaggerUi::new("/swagger").url("/openapi.json", ApiDoc::openapi()))
}
#[cfg(not(feature = "swagger"))]
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
router
}