From 2ec457860b036c4c508344d0f9a99fc5d30d7e68 Mon Sep 17 00:00:00 2001 From: Hoang Luu Date: Fri, 9 Oct 2026 02:14:32 +0900 Subject: [PATCH 1/3] Rust Axum: update codegen template so wasm crate can build without server feature --- .../main/resources/rust-axum/Cargo.mustache | 30 ++++++++++++------- .../main/resources/rust-axum/README.mustache | 1 + .../src/main/resources/rust-axum/lib.mustache | 2 ++ .../main/resources/rust-axum/models.mustache | 2 ++ .../output/apikey-authorization/Cargo.toml | 30 ++++++++++++------- .../output/apikey-authorization/README.md | 1 + .../output/apikey-authorization/src/lib.rs | 2 ++ .../output/apikey-authorization/src/models.rs | 2 ++ .../rust-axum/output/apikey-auths/Cargo.toml | 30 ++++++++++++------- .../rust-axum/output/apikey-auths/README.md | 1 + .../rust-axum/output/apikey-auths/src/lib.rs | 2 ++ .../output/apikey-auths/src/models.rs | 2 ++ .../rust-axum/output/multipart-v3/Cargo.toml | 30 ++++++++++++------- .../rust-axum/output/multipart-v3/README.md | 1 + .../rust-axum/output/multipart-v3/src/lib.rs | 2 ++ .../output/multipart-v3/src/models.rs | 2 ++ .../rust-axum/output/openapi-v3/Cargo.toml | 30 ++++++++++++------- .../rust-axum/output/openapi-v3/README.md | 1 + .../rust-axum/output/openapi-v3/src/lib.rs | 2 ++ .../rust-axum/output/openapi-v3/src/models.rs | 2 ++ .../rust-axum/output/ops-v3/Cargo.toml | 30 ++++++++++++------- .../rust-axum/output/ops-v3/README.md | 1 + .../rust-axum/output/ops-v3/src/lib.rs | 2 ++ .../rust-axum/output/ops-v3/src/models.rs | 2 ++ .../Cargo.toml | 30 ++++++++++++------- .../README.md | 1 + .../src/lib.rs | 2 ++ .../src/models.rs | 2 ++ .../rust-axum/output/petstore/Cargo.toml | 30 ++++++++++++------- .../rust-axum/output/petstore/README.md | 1 + .../rust-axum/output/petstore/src/lib.rs | 2 ++ .../rust-axum/output/petstore/src/models.rs | 2 ++ .../output/ping-bearer-auth/Cargo.toml | 30 ++++++++++++------- .../output/ping-bearer-auth/README.md | 1 + .../output/ping-bearer-auth/src/lib.rs | 2 ++ .../output/ping-bearer-auth/src/models.rs | 2 ++ .../rust-axum-array-params-test/Cargo.toml | 30 ++++++++++++------- .../rust-axum-array-params-test/README.md | 1 + .../rust-axum-array-params-test/src/lib.rs | 2 ++ .../rust-axum-array-params-test/src/models.rs | 2 ++ .../Cargo.toml | 30 ++++++++++++------- .../README.md | 1 + .../src/lib.rs | 2 ++ .../src/models.rs | 2 ++ .../output/rust-axum-header-uuid/Cargo.toml | 30 ++++++++++++------- .../output/rust-axum-header-uuid/README.md | 1 + .../output/rust-axum-header-uuid/src/lib.rs | 2 ++ .../rust-axum-header-uuid/src/models.rs | 2 ++ .../rust-axum-integer-types-test/Cargo.toml | 30 ++++++++++++------- .../rust-axum-integer-types-test/README.md | 1 + .../rust-axum-integer-types-test/src/lib.rs | 2 ++ .../src/models.rs | 2 ++ .../output/rust-axum-oneof/Cargo.toml | 30 ++++++++++++------- .../output/rust-axum-oneof/README.md | 1 + .../output/rust-axum-oneof/src/lib.rs | 2 ++ .../output/rust-axum-oneof/src/models.rs | 2 ++ .../rust-axum/output/rust-axum-sse/Cargo.toml | 30 ++++++++++++------- .../rust-axum/output/rust-axum-sse/README.md | 1 + .../rust-axum/output/rust-axum-sse/src/lib.rs | 2 ++ .../output/rust-axum-sse/src/models.rs | 2 ++ .../output/rust-axum-test/Cargo.toml | 30 ++++++++++++------- .../rust-axum/output/rust-axum-test/README.md | 1 + .../output/rust-axum-test/src/lib.rs | 2 ++ .../output/rust-axum-test/src/models.rs | 2 ++ .../rust-axum-validation-test/Cargo.toml | 30 ++++++++++++------- .../rust-axum-validation-test/README.md | 1 + .../rust-axum-validation-test/src/lib.rs | 2 ++ .../rust-axum-validation-test/src/models.rs | 2 ++ 68 files changed, 425 insertions(+), 170 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache index 1400f29b749c..284738b54894 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache @@ -29,7 +29,17 @@ homepage = "{{.}}" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -40,13 +50,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -55,19 +65,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/modules/openapi-generator/src/main/resources/rust-axum/README.mustache b/modules/openapi-generator/src/main/resources/rust-axum/README.mustache index babe066ad057..cc981d125cd4 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/README.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/README.mustache @@ -34,6 +34,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/modules/openapi-generator/src/main/resources/rust-axum/lib.mustache b/modules/openapi-generator/src/main/resources/rust-axum/lib.mustache index 153ffa6d00bd..7629501755b9 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/lib.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/lib.mustache @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = "{{{basePathWithoutHost}}}"; @@ -26,6 +27,7 @@ pub mod server; pub mod models; pub mod types; +#[cfg(feature = "server")] pub mod apis; #[cfg(feature = "server")] diff --git a/modules/openapi-generator/src/main/resources/rust-axum/models.mustache b/modules/openapi-generator/src/main/resources/rust-axum/models.mustache index 747d2bf0ddff..9c2a9fa5562a 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/models.mustache @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin> + std::marker::Send + std::marker::Sync>>; diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml b/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml index 06de4219f131..4df4d839f0a1 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/README.md b/samples/server/petstore/rust-axum/output/apikey-authorization/README.md index b3c63a54bd1d..3ce0be1ae87d 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/README.md +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/src/lib.rs b/samples/server/petstore/rust-axum/output/apikey-authorization/src/lib.rs index 619411029944..4ac0a487f840 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = "/v71"; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.0"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs b/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs index 4f7fc1328084..0e515591d992 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml index a9b49a596740..1803dea6f7c7 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/README.md b/samples/server/petstore/rust-axum/output/apikey-auths/README.md index a5242d094dac..e4ce1b3569eb 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/README.md +++ b/samples/server/petstore/rust-axum/output/apikey-auths/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/lib.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/lib.rs index 619411029944..4ac0a487f840 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = "/v71"; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.0"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs index 4f7fc1328084..0e515591d992 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml index 98afe1093576..445fbc2ddb43 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/README.md b/samples/server/petstore/rust-axum/output/multipart-v3/README.md index ba0b0cdcb64d..f1804eec3c7d 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/README.md +++ b/samples/server/petstore/rust-axum/output/multipart-v3/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs index ea9c8de34b6f..219e64ae4ed4 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.7"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs index beff8f06c7b5..922ed9c6d935 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml index bcf71bc5d5f2..5752a56e142d 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/README.md b/samples/server/petstore/rust-axum/output/openapi-v3/README.md index cad7451715e4..b91b967f738c 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-axum/output/openapi-v3/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs index ea9c8de34b6f..219e64ae4ed4 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.7"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs index 10b761437a04..0592089eaa68 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml index 7eeac251f8be..26d8c9cb80b6 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/ops-v3/README.md b/samples/server/petstore/rust-axum/output/ops-v3/README.md index 03b8d9454aa1..cbbffee4a607 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/README.md +++ b/samples/server/petstore/rust-axum/output/ops-v3/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/lib.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/lib.rs index b9efa68d49c1..77ee12b8f793 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "0.0.1"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs index 0fd4ca1e0612..669853e7d935 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml index 4502ad161539..887da2a21681 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml @@ -10,7 +10,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -21,13 +31,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -36,19 +46,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md index dc01ac1ff644..3de63c90fa5e 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index 071b66d420a4..af15e1c4d442 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = "/v2"; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.0"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index be3abfc7bd7d..0c840fe53b55 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml index f4e921bb11e5..0969ae40bf24 100644 --- a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml @@ -9,7 +9,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -20,13 +30,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -35,19 +45,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/petstore/README.md b/samples/server/petstore/rust-axum/output/petstore/README.md index f088360c25ac..0e0a47ea934e 100644 --- a/samples/server/petstore/rust-axum/output/petstore/README.md +++ b/samples/server/petstore/rust-axum/output/petstore/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/petstore/src/lib.rs b/samples/server/petstore/rust-axum/output/petstore/src/lib.rs index 071b66d420a4..af15e1c4d442 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = "/v2"; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.0"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/models.rs b/samples/server/petstore/rust-axum/output/petstore/src/models.rs index 9804cb7270bb..ce66884a4a66 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml b/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml index c5fc44b6e217..516d7032e8b5 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md b/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md index 92b4aa46ffb7..c3ea67c3c37b 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs index 16bdc1559d6e..9ed8be2e6f79 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs index 0fd4ca1e0612..669853e7d935 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml index d16c08a479fe..8edceb6487d7 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md index aee20d98a36c..1c081a598234 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/lib.rs index b9efa68d49c1..77ee12b8f793 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "0.0.1"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs index d5fea6b3c719..e0b6aeadd9ba 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml index ff4d6766037e..79d65a98fb84 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md index 658c0ae2b259..4c5daeecfbe1 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/lib.rs index b9efa68d49c1..77ee12b8f793 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "0.0.1"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs index 9ba29eead2ca..fadde68d1154 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml index 44dce408865b..09557285ff82 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md index ea8899974b83..55df2212854a 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/lib.rs index 0b593a896728..ffaf5be531a2 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "0.1.9"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs index a143a801c26d..3c964f6e6fe4 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml index 4347523f3050..2ab9b02755eb 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md index 78cb070169f2..6ef9d72e39a1 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/lib.rs index a63c5aa7e55e..09763630f1ac 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.0"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs index 04105a0ed769..16a92f4f9514 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml index accdeba829d0..a9a33771a03d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md b/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md index 3775d240ac0b..1f935cf03d3c 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/lib.rs index b9efa68d49c1..77ee12b8f793 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "0.0.1"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs index 9cbc8f2571db..149fdd59106b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml index 026bfe987aa5..fecce052413a 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md b/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md index 16582bc3360e..6ed6ff12bc8c 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-sse/src/lib.rs index a63c5aa7e55e..09763630f1ac 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "1.0.0"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs index c7b330b26096..81c4dcad2964 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml index cae6e0b81cd6..95c0f3c2d63b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-test/README.md index 4ec0f4f12d60..f231311a474f 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs index 91fd90013733..bd6ca7e4afeb 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "2.3.4"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs index 345b453af32e..6a5a18b0bbf6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml index 80ba4c330ed2..c7c502757cd2 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml @@ -8,7 +8,17 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] -server = [] +server = [ + "async-trait", + "axum", + "axum-extra", + "futures-util", + "headers", + "http", + "serde_html_form", + "tokio", + "tracing", +] conversion = [ "frunk", "frunk_derives", @@ -19,13 +29,13 @@ conversion = [ [dependencies] ammonia = "4" -async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } +async-trait = { version = "0.1", optional = true } +axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ "cookie", "query", "typed-header", -] } +], optional = true } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -34,19 +44,19 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures-util = "0.3" -headers = "0.4" -http = "1" +futures-util = { version = "0.3", optional = true } +headers = { version = "0.4", optional = true } +http = { version = "1", optional = true } lazy_static = "1" regex = "1" serde = { version = "1", features = ["derive"] } -serde_html_form = "0.2" +serde_html_form = { version = "0.2", optional = true } serde_json = { version = "1", features = ["raw_value"] } tokio = { version = "1", default-features = false, features = [ "signal", "rt-multi-thread", -] } -tracing = { version = "0.1", features = ["attributes"] } +], optional = true } +tracing = { version = "0.1", features = ["attributes"], optional = true } uuid = { version = "1", features = ["serde"] } validator = { version = "0.20", features = ["derive"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md index dd020338d534..77c68420d2ed 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md @@ -29,6 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/lib.rs index b9efa68d49c1..77ee12b8f793 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/lib.rs @@ -14,6 +14,7 @@ clippy::too_many_arguments )] +#[cfg(feature = "server")] extern crate futures_util; pub const BASE_PATH: &str = ""; @@ -22,6 +23,7 @@ pub const API_VERSION: &str = "0.0.1"; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "server")] pub mod apis; pub mod models; pub mod types; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs index bd8269f6cb10..2b7ccf789dc1 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs @@ -1,5 +1,6 @@ #![allow(unused_qualifications)] +#[cfg(feature = "server")] use http::HeaderValue; use validator::Validate; @@ -7,6 +8,7 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; +#[cfg(feature = "server")] #[allow(dead_code)] pub type SSE = std::pin::Pin< std::boxed::Box< From 474fd29a878a1bc5367cdb3af8436d8dc42f65f6 Mon Sep 17 00:00:00 2001 From: Hoang Luu Date: Fri, 9 Oct 2026 02:18:36 +0900 Subject: [PATCH 2/3] also split amonia behind server feature --- .../main/resources/rust-axum/Cargo.mustache | 3 ++- .../main/resources/rust-axum/README.mustache | 2 +- .../main/resources/rust-axum/models.mustache | 22 ++++++++++++++----- .../output/apikey-authorization/Cargo.toml | 3 ++- .../output/apikey-authorization/README.md | 2 +- .../output/apikey-authorization/src/models.rs | 22 ++++++++++++++----- .../rust-axum/output/apikey-auths/Cargo.toml | 3 ++- .../rust-axum/output/apikey-auths/README.md | 2 +- .../output/apikey-auths/src/models.rs | 22 ++++++++++++++----- .../rust-axum/output/multipart-v3/Cargo.toml | 3 ++- .../rust-axum/output/multipart-v3/README.md | 2 +- .../output/multipart-v3/src/models.rs | 22 ++++++++++++++----- .../rust-axum/output/openapi-v3/Cargo.toml | 3 ++- .../rust-axum/output/openapi-v3/README.md | 2 +- .../rust-axum/output/openapi-v3/src/models.rs | 22 ++++++++++++++----- .../rust-axum/output/ops-v3/Cargo.toml | 3 ++- .../rust-axum/output/ops-v3/README.md | 2 +- .../rust-axum/output/ops-v3/src/models.rs | 22 ++++++++++++++----- .../Cargo.toml | 3 ++- .../README.md | 2 +- .../src/models.rs | 22 ++++++++++++++----- .../rust-axum/output/petstore/Cargo.toml | 3 ++- .../rust-axum/output/petstore/README.md | 2 +- .../rust-axum/output/petstore/src/models.rs | 22 ++++++++++++++----- .../output/ping-bearer-auth/Cargo.toml | 3 ++- .../output/ping-bearer-auth/README.md | 2 +- .../output/ping-bearer-auth/src/models.rs | 22 ++++++++++++++----- .../rust-axum-array-params-test/Cargo.toml | 3 ++- .../rust-axum-array-params-test/README.md | 2 +- .../rust-axum-array-params-test/src/models.rs | 22 ++++++++++++++----- .../Cargo.toml | 3 ++- .../README.md | 2 +- .../src/models.rs | 22 ++++++++++++++----- .../output/rust-axum-header-uuid/Cargo.toml | 3 ++- .../output/rust-axum-header-uuid/README.md | 2 +- .../rust-axum-header-uuid/src/models.rs | 22 ++++++++++++++----- .../rust-axum-integer-types-test/Cargo.toml | 3 ++- .../rust-axum-integer-types-test/README.md | 2 +- .../src/models.rs | 22 ++++++++++++++----- .../output/rust-axum-oneof/Cargo.toml | 3 ++- .../output/rust-axum-oneof/README.md | 2 +- .../output/rust-axum-oneof/src/models.rs | 22 ++++++++++++++----- .../rust-axum/output/rust-axum-sse/Cargo.toml | 3 ++- .../rust-axum/output/rust-axum-sse/README.md | 2 +- .../output/rust-axum-sse/src/models.rs | 22 ++++++++++++++----- .../output/rust-axum-test/Cargo.toml | 3 ++- .../rust-axum/output/rust-axum-test/README.md | 2 +- .../output/rust-axum-test/src/models.rs | 22 ++++++++++++++----- .../rust-axum-validation-test/Cargo.toml | 3 ++- .../rust-axum-validation-test/README.md | 2 +- .../rust-axum-validation-test/src/models.rs | 22 ++++++++++++++----- 51 files changed, 340 insertions(+), 119 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache index 284738b54894..0bfe723c853e 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache @@ -30,6 +30,7 @@ homepage = "{{.}}" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -49,7 +50,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/modules/openapi-generator/src/main/resources/rust-axum/README.mustache b/modules/openapi-generator/src/main/resources/rust-axum/README.mustache index cc981d125cd4..62dcbe69fa83 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/README.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/README.mustache @@ -34,7 +34,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/modules/openapi-generator/src/main/resources/rust-axum/models.mustache b/modules/openapi-generator/src/main/resources/rust-axum/models.mustache index 9c2a9fa5562a..0c29edad984d 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/models.mustache @@ -19,9 +19,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -30,7 +42,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -41,7 +53,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -55,7 +67,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -64,7 +76,7 @@ where #[allow(dead_code)] pub fn check_xss_map(v: &std::collections::HashMap) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml b/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml index 4df4d839f0a1..71e1501ecf49 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/README.md b/samples/server/petstore/rust-axum/output/apikey-authorization/README.md index 3ce0be1ae87d..8ef1da98df6b 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/README.md +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs b/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs index 0e515591d992..ee3c64e1872c 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml index 1803dea6f7c7..99a7f644a6f1 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/README.md b/samples/server/petstore/rust-axum/output/apikey-auths/README.md index e4ce1b3569eb..19fb3f2902fc 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/README.md +++ b/samples/server/petstore/rust-axum/output/apikey-auths/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs index 0e515591d992..ee3c64e1872c 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml index 445fbc2ddb43..621111b1d0b9 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/README.md b/samples/server/petstore/rust-axum/output/multipart-v3/README.md index f1804eec3c7d..0df27ba63b68 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/README.md +++ b/samples/server/petstore/rust-axum/output/multipart-v3/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs index 922ed9c6d935..e3bd9335ff33 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml index 5752a56e142d..c8fe242e8eee 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/README.md b/samples/server/petstore/rust-axum/output/openapi-v3/README.md index b91b967f738c..a3cc135006b4 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-axum/output/openapi-v3/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs index 0592089eaa68..4e02ca858715 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml index 26d8c9cb80b6..0f32367c6651 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/ops-v3/README.md b/samples/server/petstore/rust-axum/output/ops-v3/README.md index cbbffee4a607..1d882e84f8cd 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/README.md +++ b/samples/server/petstore/rust-axum/output/ops-v3/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs index 669853e7d935..fc39aa77bc22 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml index 887da2a21681..89e3d565c207 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml @@ -11,6 +11,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -30,7 +31,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md index 3de63c90fa5e..6868bd59eef2 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index 0c840fe53b55..02605f5a7b46 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml index 0969ae40bf24..6b54b158af9e 100644 --- a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml @@ -10,6 +10,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -29,7 +30,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/petstore/README.md b/samples/server/petstore/rust-axum/output/petstore/README.md index 0e0a47ea934e..4cd7730f47c8 100644 --- a/samples/server/petstore/rust-axum/output/petstore/README.md +++ b/samples/server/petstore/rust-axum/output/petstore/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/petstore/src/models.rs b/samples/server/petstore/rust-axum/output/petstore/src/models.rs index ce66884a4a66..e4e1b81c3041 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml b/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml index 516d7032e8b5..8b324cd1a256 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md b/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md index c3ea67c3c37b..068507111016 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs index 669853e7d935..fc39aa77bc22 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml index 8edceb6487d7..c01d880bf8d7 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md index 1c081a598234..0870b4a5295b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs index e0b6aeadd9ba..ffb4271d7c82 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml index 79d65a98fb84..48c8a9d05a89 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md index 4c5daeecfbe1..9620471486f7 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs index fadde68d1154..f4587159ef50 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml index 09557285ff82..baa1515a03de 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md index 55df2212854a..09574e94bd94 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs index 3c964f6e6fe4..3ebf8eca8775 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml index 2ab9b02755eb..d2a50253cf56 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md index 6ef9d72e39a1..b735eacdb7a5 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs index 16a92f4f9514..9492d8cdda31 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml index a9a33771a03d..6296cb1c2971 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md b/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md index 1f935cf03d3c..d474af9b51a1 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs index 149fdd59106b..a68d2df9f7b1 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml index fecce052413a..2aba031ad5d4 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md b/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md index 6ed6ff12bc8c..18f95c7ede15 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs index 81c4dcad2964..3f496bd294cb 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml index 95c0f3c2d63b..a7a4a595681d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-test/README.md index f231311a474f..dc143092845e 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs index 6a5a18b0bbf6..0ff009cecc60 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml index c7c502757cd2..11c391b1a388 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/openapitools/openapi-generator" [features] default = ["server"] server = [ + "ammonia", "async-trait", "axum", "axum-extra", @@ -28,7 +29,7 @@ conversion = [ ] [dependencies] -ammonia = "4" +ammonia = { version = "4", optional = true } async-trait = { version = "0.1", optional = true } axum = { version = "0.8", features = ["multipart"], optional = true } axum-extra = { version = "0.12", features = [ diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md index 77c68420d2ed..829ab47b1815 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md @@ -29,7 +29,7 @@ The generated library has a few optional features that can be activated through * `server` * This defaults to enabled and creates the basic skeleton of a server implementation based on Axum. * To create the server stack you'll need to provide an implementation of the API trait to provide the server function. - * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies, e.g. for sharing the models with a WASM frontend. + * Disabling it (`default-features = false`) leaves only `models` and `types`, without Axum, Tokio or other server dependencies (including `ammonia`, so the XSS check in model validation is skipped), e.g. for sharing the models with a WASM frontend. * `conversions` * This defaults to disabled and creates extra derives on models to allow "transmogrification" between objects of structurally similar types. diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs index 2b7ccf789dc1..7ee6d7257ce5 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/models.rs @@ -26,9 +26,21 @@ fn from_validation_error(e: validator::ValidationError) -> validator::Validation errs } +/// XSS detection relies on `ammonia`, which is only pulled in by the `server` feature. +/// Without it (e.g. models-only WASM builds), values are never flagged as HTML. +#[cfg(feature = "server")] +fn contains_html(v: &str) -> bool { + ammonia::is_html(v) +} + +#[cfg(not(feature = "server"))] +fn contains_html(_v: &str) -> bool { + false +} + #[allow(dead_code)] pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::ValidationError> { - if ammonia::is_html(v) { + if contains_html(v) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -37,7 +49,7 @@ pub fn check_xss_string(v: &str) -> std::result::Result<(), validator::Validatio #[allow(dead_code)] pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator::ValidationError> { - if v.iter().any(|i| ammonia::is_html(i)) { + if v.iter().any(|i| contains_html(i)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -48,7 +60,7 @@ pub fn check_xss_vec_string(v: &[String]) -> std::result::Result<(), validator:: pub fn check_xss_map_string( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| ammonia::is_html(v)) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| contains_html(v)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -62,7 +74,7 @@ pub fn check_xss_map_nested( where T: validator::Validate, { - if v.keys().any(|k| ammonia::is_html(k)) || v.values().any(|v| v.validate().is_err()) { + if v.keys().any(|k| contains_html(k)) || v.values().any(|v| v.validate().is_err()) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) @@ -73,7 +85,7 @@ where pub fn check_xss_map( v: &std::collections::HashMap, ) -> std::result::Result<(), validator::ValidationError> { - if v.keys().any(|k| ammonia::is_html(k)) { + if v.keys().any(|k| contains_html(k)) { std::result::Result::Err(validator::ValidationError::new("xss detected")) } else { std::result::Result::Ok(()) From b619fe9229a68be56cf8072fdbb27c26aae45837 Mon Sep 17 00:00:00 2001 From: Hoang Luu Date: Fri, 9 Oct 2026 02:33:18 +0900 Subject: [PATCH 3/3] make bytes crates optional --- .../src/main/resources/rust-axum/Cargo.mustache | 3 ++- .../petstore/rust-axum/output/apikey-authorization/Cargo.toml | 3 ++- .../server/petstore/rust-axum/output/apikey-auths/Cargo.toml | 3 ++- .../server/petstore/rust-axum/output/multipart-v3/Cargo.toml | 3 ++- samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml | 3 ++- samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml | 3 ++- .../petstore-with-fake-endpoints-models-for-testing/Cargo.toml | 3 ++- samples/server/petstore/rust-axum/output/petstore/Cargo.toml | 3 ++- .../petstore/rust-axum/output/ping-bearer-auth/Cargo.toml | 3 ++- .../rust-axum/output/rust-axum-array-params-test/Cargo.toml | 3 ++- .../output/rust-axum-discriminator-enum-ref/Cargo.toml | 3 ++- .../petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml | 3 ++- .../rust-axum/output/rust-axum-integer-types-test/Cargo.toml | 3 ++- .../petstore/rust-axum/output/rust-axum-oneof/Cargo.toml | 3 ++- .../server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml | 3 ++- .../server/petstore/rust-axum/output/rust-axum-test/Cargo.toml | 3 ++- .../rust-axum/output/rust-axum-validation-test/Cargo.toml | 3 ++- 17 files changed, 34 insertions(+), 17 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache index 0bfe723c853e..6d94377f0908 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache @@ -34,6 +34,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -59,7 +60,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml b/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml index 71e1501ecf49..5d3abfec5ae9 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml index 99a7f644a6f1..92958ec0c8a3 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml index 621111b1d0b9..767581c00ce1 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml index c8fe242e8eee..60e73dbef6ee 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml index 0f32367c6651..7cea7ca61ceb 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml index 89e3d565c207..f00e8da47781 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/Cargo.toml @@ -15,6 +15,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -40,7 +41,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml index 6b54b158af9e..6af7829a0775 100644 --- a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml @@ -14,6 +14,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -39,7 +40,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml b/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml index 8b324cd1a256..4ee2f9997e88 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml index c01d880bf8d7..cea013d0c1c0 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml index 48c8a9d05a89..4de24592de54 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-discriminator-enum-ref/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml index baa1515a03de..dd70058b437b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml index d2a50253cf56..dc9f35ff17c6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-integer-types-test/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml index 6296cb1c2971..b96e7ae6ae3f 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml index 2aba031ad5d4..17b44756ed6e 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-sse/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml index a7a4a595681d..9ec28d912970 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml index 11c391b1a388..80419f5a7d41 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/Cargo.toml @@ -13,6 +13,7 @@ server = [ "async-trait", "axum", "axum-extra", + "bytes", "futures-util", "headers", "http", @@ -38,7 +39,7 @@ axum-extra = { version = "0.12", features = [ "typed-header", ], optional = true } base64 = "0.22" -bytes = "1" +bytes = { version = "1", optional = true } chrono = { version = "0.4", features = ["serde"] } frunk = { version = "0.4", optional = true } frunk-enum-core = { version = "0.3", optional = true }