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:
@@ -59,7 +59,7 @@ tokio-util = "0.7.16"
|
|||||||
tower = "0.5.2"
|
tower = "0.5.2"
|
||||||
tower-http = { version = "0.6.6", features = ["cors", "fs", "trace"] }
|
tower-http = { version = "0.6.6", features = ["cors", "fs", "trace"] }
|
||||||
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
||||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"], optional = true }
|
||||||
uzers = "0.12.1"
|
uzers = "0.12.1"
|
||||||
which = "8.0.0"
|
which = "8.0.0"
|
||||||
xdg = "2.5.2"
|
xdg = "2.5.2"
|
||||||
@@ -68,8 +68,8 @@ pest = "2.8.1"
|
|||||||
pest_derive = "2.8.1"
|
pest_derive = "2.8.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Default features include core compression engines
|
# Default features include core compression engines and swagger UI
|
||||||
default = ["gzip", "lz4"]
|
default = ["gzip", "lz4", "swagger"]
|
||||||
|
|
||||||
# Compression features
|
# Compression features
|
||||||
gzip = ["flate2"]
|
gzip = ["flate2"]
|
||||||
@@ -88,6 +88,9 @@ magic = ["dep:magic"]
|
|||||||
# MCP feature (Model Context Protocol support)
|
# MCP feature (Model Context Protocol support)
|
||||||
mcp = ["dep:rmcp"]
|
mcp = ["dep:rmcp"]
|
||||||
|
|
||||||
|
# Swagger UI feature
|
||||||
|
swagger = ["dep:utoipa-swagger-ui"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.3.0"
|
tempfile = "3.3.0"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#[cfg(feature = "swagger")]
|
||||||
pub mod item;
|
pub mod item;
|
||||||
pub mod status;
|
pub mod status;
|
||||||
#[cfg(feature = "mcp")]
|
#[cfg(feature = "mcp")]
|
||||||
@@ -10,6 +11,8 @@ use axum::{
|
|||||||
|
|
||||||
use crate::modes::server::common::AppState;
|
use crate::modes::server::common::AppState;
|
||||||
use utoipa::OpenApi;
|
use utoipa::OpenApi;
|
||||||
|
|
||||||
|
#[cfg(feature = "swagger")]
|
||||||
use utoipa_swagger_ui::SwaggerUi;
|
use utoipa_swagger_ui::SwaggerUi;
|
||||||
|
|
||||||
#[derive(OpenApi)]
|
#[derive(OpenApi)]
|
||||||
@@ -75,7 +78,13 @@ pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
|
|||||||
router
|
router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "swagger")]
|
||||||
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
|
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
|
||||||
router
|
router
|
||||||
.merge(SwaggerUi::new("/swagger").url("/openapi.json", ApiDoc::openapi()))
|
.merge(SwaggerUi::new("/swagger").url("/openapi.json", ApiDoc::openapi()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "swagger"))]
|
||||||
|
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
|
||||||
|
router
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user