diff --git a/utoipa-rapidoc/Cargo.toml b/utoipa-rapidoc/Cargo.toml index cf359703..b119e34c 100644 --- a/utoipa-rapidoc/Cargo.toml +++ b/utoipa-rapidoc/Cargo.toml @@ -12,7 +12,7 @@ authors = ["Juha Kukkonen "] rust-version.workspace = true [package.metadata.docs.rs] -features = ["actix-web", "axum", "rocket"] +features = ["actix-web", "axum", "rocket", "hyperlane"] rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] @@ -28,7 +28,10 @@ axum = { version = "0.8.0", default-features = false, features = [ ], optional = true } [dev-dependencies] -utoipa-rapidoc = { path = ".", features = ["actix-web", "axum", "rocket"] } +utoipa-rapidoc = { path = ".", features = ["actix-web", "axum", "rocket", "hyperlane"] } [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] } + +[features] +hyperlane = [] diff --git a/utoipa-rapidoc/src/lib.rs b/utoipa-rapidoc/src/lib.rs index 2459e2ca..e29d7bdd 100644 --- a/utoipa-rapidoc/src/lib.rs +++ b/utoipa-rapidoc/src/lib.rs @@ -156,7 +156,12 @@ pub struct RapiDoc { path: Cow<'static, str>, spec_url: Cow<'static, str>, html: Cow<'static, str>, - #[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] + #[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))] openapi: Option, } @@ -177,7 +182,12 @@ impl RapiDoc { path: Cow::Borrowed(""), spec_url: spec_url.into(), html: Cow::Borrowed(DEFAULT_HTML), - #[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] + #[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))] openapi: None, } } @@ -203,10 +213,20 @@ impl RapiDoc { /// ApiDoc::openapi() /// ); /// ``` - #[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] + #[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))] #[cfg_attr( doc_cfg, - doc(cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))) + doc(cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))) )] pub fn with_openapi>>( spec_url: U, @@ -243,10 +263,20 @@ impl RapiDoc { /// ApiDoc::openapi() /// ); /// ``` - #[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] + #[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))] #[cfg_attr( doc_cfg, - doc(cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))) + doc(cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))) )] pub fn with_url>, S: Into>>( url: U, @@ -283,7 +313,12 @@ impl RapiDoc { /// RapiDoc::new("https://petstore3.swagger.io/api/v3/openapi.json") /// .path("/rapidoc"); /// ``` - #[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] + #[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))] pub fn path>>(mut self, path: U) -> Self { self.path = path.into(); diff --git a/utoipa-redoc/Cargo.toml b/utoipa-redoc/Cargo.toml index 5c9a9b57..7eee5d20 100644 --- a/utoipa-redoc/Cargo.toml +++ b/utoipa-redoc/Cargo.toml @@ -12,7 +12,7 @@ authors = ["Juha Kukkonen "] rust-version.workspace = true [package.metadata.docs.rs] -features = ["actix-web", "axum", "rocket"] +features = ["actix-web", "axum", "rocket", "hyperlane"] rustdoc-args = ["--cfg", "doc_cfg"] [dependencies] @@ -26,7 +26,10 @@ rocket = { version = "0.5", features = ["json"], optional = true } axum = { version = "0.8.0", default-features = false, optional = true } [dev-dependencies] -utoipa-redoc = { path = ".", features = ["actix-web", "axum", "rocket"] } +utoipa-redoc = { path = ".", features = ["actix-web", "axum", "rocket", "hyperlane"] } [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] } + +[features] +hyperlane = [] diff --git a/utoipa-swagger-ui/Cargo.toml b/utoipa-swagger-ui/Cargo.toml index 3fbc24eb..07a81feb 100644 --- a/utoipa-swagger-ui/Cargo.toml +++ b/utoipa-swagger-ui/Cargo.toml @@ -20,6 +20,7 @@ url = ["dep:url"] vendored = ["dep:utoipa-swagger-ui-vendored"] # cache swagger ui zip cache = ["dep:dirs", "dep:sha2"] +hyperlane = [] [dependencies] rust-embed = { version = "8" } @@ -41,10 +42,10 @@ http = "1.2" similar = "2.5" tokio = { version = "1", features = ["macros"] } tower = "0.5" -utoipa-swagger-ui = { path = ".", features = ["actix-web", "axum", "rocket"] } +utoipa-swagger-ui = { path = ".", features = ["actix-web", "axum", "rocket", "hyperlane"] } [package.metadata.docs.rs] -features = ["actix-web", "axum", "rocket", "vendored", "cache"] +features = ["actix-web", "axum", "rocket", "vendored", "cache", "hyperlane"] no-default-features = true rustdoc-args = ["--cfg", "doc_cfg"] diff --git a/utoipa-swagger-ui/src/lib.rs b/utoipa-swagger-ui/src/lib.rs index 35e5bebe..3fc0a2fb 100644 --- a/utoipa-swagger-ui/src/lib.rs +++ b/utoipa-swagger-ui/src/lib.rs @@ -150,7 +150,12 @@ mod rocket; use rust_embed::RustEmbed; use serde::Serialize; -#[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] +#[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" +))] use utoipa::openapi::OpenApi; include!(concat!(env!("OUT_DIR"), "/embed.rs")); @@ -187,10 +192,20 @@ include!(concat!(env!("OUT_DIR"), "/embed.rs")); #[non_exhaustive] #[derive(Clone)] #[cfg_attr(feature = "debug", derive(Debug))] -#[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] +#[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" +))] #[cfg_attr( doc_cfg, - doc(cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))) + doc(cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))) )] pub struct SwaggerUi { path: Cow<'static, str>, @@ -199,10 +214,20 @@ pub struct SwaggerUi { external_urls: Vec<(Url<'static>, serde_json::Value)>, } -#[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] +#[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" +))] #[cfg_attr( doc_cfg, - doc(cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))) + doc(cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))) )] impl SwaggerUi { /// Create a new [`SwaggerUi`] for given path. @@ -782,10 +807,20 @@ impl<'a> Config<'a> { /// is called on. /// /// Current config will be returned with configured default values. - #[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] + #[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))] #[cfg_attr( doc_cfg, - doc(cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))) + doc(cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" + ))) )] fn configure_defaults, U: Into>>(mut self, urls: I) -> Self { let Config { @@ -1509,7 +1544,12 @@ fn format_config(config: &Config, file: String) -> Result } /// Is used to provide general way to deliver multiple types of OpenAPI docs via `utoipa-swagger-ui`. -#[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] +#[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" +))] #[derive(Clone)] enum ApiDoc { Utoipa(utoipa::openapi::OpenApi), @@ -1517,7 +1557,12 @@ enum ApiDoc { } // Delegate serde's `Serialize` to the variant itself. -#[cfg(any(feature = "actix-web", feature = "rocket", feature = "axum"))] +#[cfg(any( + feature = "actix-web", + feature = "rocket", + feature = "axum", + feature = "hyperlane" +))] impl Serialize for ApiDoc { fn serialize(&self, serializer: S) -> Result where