From 9841fa4dc2c61a5a0c8bdb92e05e4dffec664592 Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Tue, 14 Jan 2025 13:18:19 +0100 Subject: [PATCH 1/9] Implement a custom error handler for unhandled or generic endpoint errors --- .../main/resources/rust-axum/README.mustache | 6 +- .../resources/rust-axum/apis-mod.mustache | 15 +- .../main/resources/rust-axum/apis.mustache | 6 +- .../rust-axum/server-operation.mustache | 11 +- .../resources/rust-axum/server-route.mustache | 7 +- .../rust-axum/output/apikey-auths/README.md | 6 +- .../output/apikey-auths/src/apis/mod.rs | 13 + .../output/apikey-auths/src/apis/payments.rs | 10 +- .../output/apikey-auths/src/server/mod.rs | 46 +- .../rust-axum/output/multipart-v3/README.md | 6 +- .../output/multipart-v3/src/apis/default.rs | 8 +- .../output/multipart-v3/src/apis/mod.rs | 13 + .../output/multipart-v3/src/server/mod.rs | 41 +- .../rust-axum/output/openapi-v3/README.md | 6 +- .../output/openapi-v3/src/apis/default.rs | 58 +-- .../output/openapi-v3/src/apis/info_repo.rs | 6 +- .../output/openapi-v3/src/apis/mod.rs | 13 + .../output/openapi-v3/src/apis/repo.rs | 4 +- .../output/openapi-v3/src/server/mod.rs | 335 +++++++------- .../rust-axum/output/ops-v3/README.md | 6 +- .../output/ops-v3/src/apis/default.rs | 76 ++-- .../rust-axum/output/ops-v3/src/apis/mod.rs | 13 + .../rust-axum/output/ops-v3/src/server/mod.rs | 412 ++++++++++-------- .../README.md | 6 +- .../src/apis/another_fake.rs | 6 +- .../src/apis/fake.rs | 28 +- .../src/apis/fake_classname_tags123.rs | 6 +- .../src/apis/mod.rs | 13 + .../src/apis/pet.rs | 18 +- .../src/apis/store.rs | 10 +- .../src/apis/user.rs | 18 +- .../src/server/mod.rs | 407 +++++++++-------- .../rust-axum/output/petstore/README.md | 4 +- .../rust-axum/output/petstore/src/apis/mod.rs | 13 + .../rust-axum/output/petstore/src/apis/pet.rs | 18 +- .../output/petstore/src/apis/store.rs | 10 +- .../output/petstore/src/apis/user.rs | 18 +- .../output/petstore/src/server/mod.rs | 233 +++++----- .../output/ping-bearer-auth/README.md | 6 +- .../ping-bearer-auth/src/apis/default.rs | 4 +- .../output/ping-bearer-auth/src/apis/mod.rs | 13 + .../output/ping-bearer-auth/src/server/mod.rs | 16 +- .../output/rust-axum-header-uuid/README.md | 6 +- .../rust-axum-header-uuid/src/apis/default.rs | 4 +- .../rust-axum-header-uuid/src/apis/mod.rs | 13 + .../rust-axum-header-uuid/src/server/mod.rs | 16 +- .../output/rust-axum-oneof/README.md | 6 +- .../rust-axum-oneof/src/apis/default.rs | 4 +- .../output/rust-axum-oneof/src/apis/mod.rs | 13 + .../output/rust-axum-oneof/src/server/mod.rs | 16 +- .../rust-axum/output/rust-axum-test/README.md | 6 +- .../output/rust-axum-test/src/apis/default.rs | 20 +- .../output/rust-axum-test/src/apis/mod.rs | 13 + .../output/rust-axum-test/src/server/mod.rs | 105 +++-- .../rust-axum-validation-test/README.md | 6 +- .../src/apis/default.rs | 4 +- .../rust-axum-validation-test/src/apis/mod.rs | 13 + .../src/server/mod.rs | 16 +- 58 files changed, 1303 insertions(+), 922 deletions(-) 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 6a2ab5ce080f..592c97af2db5 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/README.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/README.mustache @@ -48,16 +48,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl {{{packageName}}}::Api for ServerImpl { +impl {{{externCrateName}}}::apis::default::Api for ServerImpl { // API implementation goes here } +impl {{{externCrateName}}}::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = {{{packageName}}}::server::new(Arc::new(ServerImpl)); + let app = {{{externCrateName}}}::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache index 3aa19dbb7868..c3de36e2eff3 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache @@ -27,4 +27,17 @@ pub trait ApiKeyAuthHeader { } {{/isKeyInHeader}} {{/isApiKey}} -{{/authMethods}} \ No newline at end of file +{{/authMethods}} + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache index aa25d52be55c..15870dba8ceb 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache @@ -17,9 +17,9 @@ use crate::{models, types::*}; /// {{classnamePascalCase}} #[async_trait] #[allow(clippy::ptr_arg)] -pub trait {{classnamePascalCase}} { +pub trait {{classnamePascalCase}}: super::ErrorHandler { {{#havingAuthMethod}} - type Claims; + type Claims; {{/havingAuthMethod}} {{#operation}} @@ -73,7 +73,7 @@ pub trait {{classnamePascalCase}} { {{#x-consumes-multipart-related}} body: axum::body::Body, {{/x-consumes-multipart-related}} - ) -> Result<{{{operationId}}}Response, ()>; + ) -> Result<{{{operationId}}}Response, E>; {{/vendorExtensions}} {{^-last}} diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache index ceb477b11443..dd12f325b5cc 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache @@ -1,6 +1,6 @@ /// {{{operationId}}} - {{{httpMethod}}} {{{basePathWithoutHost}}}{{{path}}} #[tracing::instrument(skip_all)] -async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( +async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( method: Method, host: Host, cookies: CookieJar, @@ -54,8 +54,9 @@ async fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}} Result where I: AsRef + Send + Sync, - A: apis::{{classFilename}}::{{classnamePascalCase}}{{#havingAuthMethod}}{{/havingAuthMethod}}{{#vendorExtensions}}{{#x-has-cookie-auth-methods}}+ apis::CookieAuthentication{{/x-has-cookie-auth-methods}}{{#x-has-header-auth-methods}}+ apis::ApiKeyAuthHeader{{/x-has-header-auth-methods}}{{/vendorExtensions}}, -{ + A: apis::{{classFilename}}::{{classnamePascalCase}}{{#vendorExtensions}}{{#x-has-cookie-auth-methods}}+ apis::CookieAuthentication{{/x-has-cookie-auth-methods}}{{#x-has-header-auth-methods}}+ apis::ApiKeyAuthHeader{{/x-has-header-auth-methods}}{{/vendorExtensions}} + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, + { {{#vendorExtensions}} {{#x-has-auth-methods}} // Authentication @@ -342,10 +343,10 @@ where }, {{/responses}} }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; }, }; diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-route.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-route.mustache index 3f8fe8edbb3a..f75a627787a1 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-route.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-route.mustache @@ -1,15 +1,16 @@ /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: {{#apiInfo}}{{#apis}}{{#operations}}apis::{{classFilename}}::{{classnamePascalCase}}{{#havingAuthMethod}}{{/havingAuthMethod}} + {{/operations}}{{/apis}}{{/apiInfo}}{{#authMethods}}{{#isApiKey}}{{#isKeyInCookie}}apis::CookieAuthentication + {{/isKeyInCookie}}{{#isKeyInHeader}}apis::ApiKeyAuthHeader + {{/isKeyInHeader}}{{/isApiKey}}{{/authMethods}}'static, + A: {{#apiInfo}}{{#apis}}{{#operations}}apis::{{classFilename}}::{{classnamePascalCase}} + {{/operations}}{{/apis}}{{/apiInfo}}{{#authMethods}}{{#isApiKey}}{{#isKeyInCookie}}apis::CookieAuthentication + {{/isKeyInCookie}}{{#isKeyInHeader}}apis::ApiKeyAuthHeader + {{/isKeyInHeader}}{{/isApiKey}}{{/authMethods}}Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, {{#havingAuthMethods}}C: Send + Sync + 'static,{{/havingAuthMethods}} { // build our application with a route Router::new() {{#pathMethodOps}} .route("{{{basePathWithoutHost}}}{{{path}}}", - {{#methodOperations}}{{{method}}}({{{operationID}}}::){{^-last}}.{{/-last}}{{/methodOperations}} + {{#methodOperations}}{{{method}}}({{{operationID}}}::){{^-last}}.{{/-last}}{{/methodOperations}} ) {{/pathMethodOps}} .with_state(api_impl) 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 143e1c1b27bb..a298e7c00f23 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/README.md +++ b/samples/server/petstore/rust-axum/output/apikey-auths/README.md @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl apikey-auths::Api for ServerImpl { +impl apikey_auths::apis::default::Api for ServerImpl { // API implementation goes here } +impl apikey_auths::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = apikey-auths::server::new(Arc::new(ServerImpl)); + let app = apikey_auths::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs index 23e9675928fc..9fee0e68012b 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs @@ -24,3 +24,16 @@ pub trait CookieAuthentication { key: &str, ) -> Option; } + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs index 3dada59a82dd..5053c2341499 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs @@ -38,7 +38,9 @@ pub enum PostMakePaymentResponse { /// Payments #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Payments { +pub trait Payments: + super::ErrorHandler +{ type Claims; /// Get payment method by id. @@ -50,7 +52,7 @@ pub trait Payments { host: Host, cookies: CookieJar, path_params: models::GetPaymentMethodByIdPathParams, - ) -> Result; + ) -> Result; /// Get payment methods. /// @@ -60,7 +62,7 @@ pub trait Payments { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Make a payment. /// @@ -72,5 +74,5 @@ pub trait Payments { cookies: CookieJar, claims: Self::Claims, body: Option, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index 7db56e8b151d..36a2d69f77c3 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -13,23 +13,29 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::payments::Payments + A: apis::payments::Payments + apis::ApiKeyAuthHeader + apis::CookieAuthentication + + Send + + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, C: Send + Sync + 'static, { // build our application with a route Router::new() - .route("/v71/paymentMethods", get(get_payment_methods::)) + .route( + "/v71/paymentMethods", + get(get_payment_methods::), + ) .route( "/v71/paymentMethods/:id", - get(get_payment_method_by_id::), + get(get_payment_method_by_id::), ) - .route("/v71/payments", post(post_make_payment::)) + .route("/v71/payments", post(post_make_payment::)) .with_state(api_impl) } @@ -43,7 +49,7 @@ fn get_payment_method_by_id_validation( } /// GetPaymentMethodById - GET /v71/paymentMethods/{id} #[tracing::instrument(skip_all)] -async fn get_payment_method_by_id( +async fn get_payment_method_by_id( method: Method, host: Host, cookies: CookieJar, @@ -52,7 +58,8 @@ async fn get_payment_method_by_id( ) -> Result where I: AsRef + Send + Sync, - A: apis::payments::Payments, + A: apis::payments::Payments + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -123,10 +130,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -142,7 +149,7 @@ fn get_payment_methods_validation() -> std::result::Result<(), ValidationErrors> } /// GetPaymentMethods - GET /v71/paymentMethods #[tracing::instrument(skip_all)] -async fn get_payment_methods( +async fn get_payment_methods( method: Method, host: Host, cookies: CookieJar, @@ -150,7 +157,8 @@ async fn get_payment_methods( ) -> Result where I: AsRef + Send + Sync, - A: apis::payments::Payments, + A: apis::payments::Payments + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || get_payment_methods_validation()) @@ -197,10 +205,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -230,7 +238,7 @@ fn post_make_payment_validation( } /// PostMakePayment - POST /v71/payments #[tracing::instrument(skip_all)] -async fn post_make_payment( +async fn post_make_payment( method: Method, host: Host, cookies: CookieJar, @@ -239,7 +247,11 @@ async fn post_make_payment( ) -> Result where I: AsRef + Send + Sync, - A: apis::payments::Payments + apis::CookieAuthentication, + A: apis::payments::Payments + + apis::CookieAuthentication + + Send + + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_cookie = api_impl @@ -322,10 +334,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 4944ebb95cdf..ed697a9b04d3 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/README.md +++ b/samples/server/petstore/rust-axum/output/multipart-v3/README.md @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl multipart-v3::Api for ServerImpl { +impl multipart_v3::apis::default::Api for ServerImpl { // API implementation goes here } +impl multipart_v3::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = multipart-v3::server::new(Arc::new(ServerImpl)); + let app = multipart_v3::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs index ad21c532ae7e..6bf76a5edf9f 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs @@ -34,7 +34,7 @@ pub enum MultipleIdenticalMimeTypesPostResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// MultipartRelatedRequestPost - POST /multipart_related_request async fn multipart_related_request_post( &self, @@ -42,7 +42,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: axum::body::Body, - ) -> Result; + ) -> Result; /// MultipartRequestPost - POST /multipart_request async fn multipart_request_post( @@ -51,7 +51,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: Multipart, - ) -> Result; + ) -> Result; /// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types async fn multiple_identical_mime_types_post( @@ -60,5 +60,5 @@ pub trait Default { host: Host, cookies: CookieJar, body: axum::body::Body, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs index 1be8d340b8e0..dce6c9a8e2de 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs @@ -1 +1,14 @@ pub mod default; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index 89fd45ae4611..ccca87143d83 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -13,21 +13,25 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + 'static, + A: apis::default::Default + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() .route( "/multipart_related_request", - post(multipart_related_request_post::), + post(multipart_related_request_post::), + ) + .route( + "/multipart_request", + post(multipart_request_post::), ) - .route("/multipart_request", post(multipart_request_post::)) .route( "/multiple-identical-mime-types", - post(multiple_identical_mime_types_post::), + post(multiple_identical_mime_types_post::), ) .with_state(api_impl) } @@ -38,7 +42,7 @@ fn multipart_related_request_post_validation() -> std::result::Result<(), Valida } /// MultipartRelatedRequestPost - POST /multipart_related_request #[tracing::instrument(skip_all)] -async fn multipart_related_request_post( +async fn multipart_related_request_post( method: Method, host: Host, cookies: CookieJar, @@ -47,7 +51,8 @@ async fn multipart_related_request_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -76,10 +81,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -95,7 +100,7 @@ fn multipart_request_post_validation() -> std::result::Result<(), ValidationErro } /// MultipartRequestPost - POST /multipart_request #[tracing::instrument(skip_all)] -async fn multipart_request_post( +async fn multipart_request_post( method: Method, host: Host, cookies: CookieJar, @@ -104,7 +109,8 @@ async fn multipart_request_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || multipart_request_post_validation()) @@ -132,10 +138,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -151,7 +157,7 @@ fn multiple_identical_mime_types_post_validation() -> std::result::Result<(), Va } /// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types #[tracing::instrument(skip_all)] -async fn multiple_identical_mime_types_post( +async fn multiple_identical_mime_types_post( method: Method, host: Host, cookies: CookieJar, @@ -160,7 +166,8 @@ async fn multiple_identical_mime_types_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -189,10 +196,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 3054fe00af70..e4db33ef004c 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-axum/output/openapi-v3/README.md @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl openapi-v3::Api for ServerImpl { +impl openapi_v3::apis::default::Api for ServerImpl { // API implementation goes here } +impl openapi_v3::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = openapi-v3::server::new(Arc::new(ServerImpl)); + let app = openapi_v3::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs index 0e7b62722ca2..26e15203fa7e 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs @@ -274,7 +274,7 @@ pub enum XmlPutResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// AnyOfGet - GET /any-of async fn any_of_get( &self, @@ -282,7 +282,7 @@ pub trait Default { host: Host, cookies: CookieJar, query_params: models::AnyOfGetQueryParams, - ) -> Result; + ) -> Result; /// CallbackWithHeaderPost - POST /callback-with-header async fn callback_with_header_post( @@ -291,7 +291,7 @@ pub trait Default { host: Host, cookies: CookieJar, query_params: models::CallbackWithHeaderPostQueryParams, - ) -> Result; + ) -> Result; /// ComplexQueryParamGet - GET /complex-query-param async fn complex_query_param_get( @@ -300,7 +300,7 @@ pub trait Default { host: Host, cookies: CookieJar, query_params: models::ComplexQueryParamGetQueryParams, - ) -> Result; + ) -> Result; /// EnumInPathPathParamGet - GET /enum_in_path/{path_param} async fn enum_in_path_path_param_get( @@ -309,7 +309,7 @@ pub trait Default { host: Host, cookies: CookieJar, path_params: models::EnumInPathPathParamGetPathParams, - ) -> Result; + ) -> Result; /// Test a Form Post. /// @@ -320,7 +320,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: models::FormTestRequest, - ) -> Result; + ) -> Result; /// GetWithBooleanParameter - GET /get-with-bool async fn get_with_boolean_parameter( @@ -329,7 +329,7 @@ pub trait Default { host: Host, cookies: CookieJar, query_params: models::GetWithBooleanParameterQueryParams, - ) -> Result; + ) -> Result; /// JsonComplexQueryParamGet - GET /json-complex-query-param async fn json_complex_query_param_get( @@ -338,7 +338,7 @@ pub trait Default { host: Host, cookies: CookieJar, query_params: models::JsonComplexQueryParamGetQueryParams, - ) -> Result; + ) -> Result; /// MandatoryRequestHeaderGet - GET /mandatory-request-header async fn mandatory_request_header_get( @@ -347,7 +347,7 @@ pub trait Default { host: Host, cookies: CookieJar, header_params: models::MandatoryRequestHeaderGetHeaderParams, - ) -> Result; + ) -> Result; /// MergePatchJsonGet - GET /merge-patch-json async fn merge_patch_json_get( @@ -355,7 +355,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Get some stuff.. /// @@ -365,7 +365,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// MultipleAuthSchemeGet - GET /multiple_auth_scheme async fn multiple_auth_scheme_get( @@ -373,7 +373,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet - GET /multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b} async fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get( @@ -382,7 +382,7 @@ pub trait Default { host: Host, cookies: CookieJar, path_params: models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams, - ) -> Result; + ) -> Result; /// OneOfGet - GET /one-of async fn one_of_get( @@ -390,7 +390,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// OverrideServerGet - GET /override-server async fn override_server_get( @@ -398,7 +398,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Get some stuff with parameters.. /// @@ -409,7 +409,7 @@ pub trait Default { host: Host, cookies: CookieJar, query_params: models::ParamgetGetQueryParams, - ) -> Result; + ) -> Result; /// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme async fn readonly_auth_scheme_get( @@ -417,7 +417,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// RegisterCallbackPost - POST /register-callback async fn register_callback_post( @@ -426,7 +426,7 @@ pub trait Default { host: Host, cookies: CookieJar, query_params: models::RegisterCallbackPostQueryParams, - ) -> Result; + ) -> Result; /// RequiredOctetStreamPut - PUT /required_octet_stream async fn required_octet_stream_put( @@ -435,7 +435,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: Bytes, - ) -> Result; + ) -> Result; /// ResponsesWithHeadersGet - GET /responses_with_headers async fn responses_with_headers_get( @@ -443,7 +443,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Rfc7807Get - GET /rfc7807 async fn rfc7807_get( @@ -451,7 +451,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// TwoFirstLetterHeaders - POST /operation-two-first-letter-headers async fn two_first_letter_headers( @@ -460,7 +460,7 @@ pub trait Default { host: Host, cookies: CookieJar, header_params: models::TwoFirstLetterHeadersHeaderParams, - ) -> Result; + ) -> Result; /// UntypedPropertyGet - GET /untyped_property async fn untyped_property_get( @@ -469,7 +469,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: Option, - ) -> Result; + ) -> Result; /// UuidGet - GET /uuid async fn uuid_get( @@ -477,7 +477,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// XmlExtraPost - POST /xml_extra async fn xml_extra_post( @@ -486,7 +486,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: Bytes, - ) -> Result; + ) -> Result; /// XmlOtherPost - POST /xml_other async fn xml_other_post( @@ -495,7 +495,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: Bytes, - ) -> Result; + ) -> Result; /// XmlOtherPut - PUT /xml_other async fn xml_other_put( @@ -504,7 +504,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: Bytes, - ) -> Result; + ) -> Result; /// Post an array. It's important we test apostrophes, so include one here.. /// @@ -515,7 +515,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: Bytes, - ) -> Result; + ) -> Result; /// XmlPut - PUT /xml async fn xml_put( @@ -524,5 +524,5 @@ pub trait Default { host: Host, cookies: CookieJar, body: Bytes, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs index c73db4a16d43..48ab82f2c4c6 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs @@ -18,7 +18,9 @@ pub enum GetRepoInfoResponse { /// InfoRepo #[async_trait] #[allow(clippy::ptr_arg)] -pub trait InfoRepo { +pub trait InfoRepo: + super::ErrorHandler +{ /// GetRepoInfo - GET /repos/{repoId} async fn get_repo_info( &self, @@ -26,5 +28,5 @@ pub trait InfoRepo { host: Host, cookies: CookieJar, path_params: models::GetRepoInfoPathParams, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs index 63ecd2990e89..97d4ac0121da 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs @@ -1,3 +1,16 @@ pub mod default; pub mod info_repo; pub mod repo; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs index 90d9a774f6e1..fc2a65b16bea 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs @@ -18,7 +18,7 @@ pub enum CreateRepoResponse { /// Repo #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Repo { +pub trait Repo: super::ErrorHandler { /// CreateRepo - POST /repos async fn create_repo( &self, @@ -26,5 +26,5 @@ pub trait Repo { host: Host, cookies: CookieJar, body: models::ObjectParam, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index 666120206b69..e0f210a1734c 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -13,96 +13,102 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + apis::info_repo::InfoRepo + apis::repo::Repo + 'static, + A: apis::default::Default + + apis::info_repo::InfoRepo + + apis::repo::Repo + + Send + + Sync + + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() .route("/any-of", - get(any_of_get::) + get(any_of_get::) ) .route("/callback-with-header", - post(callback_with_header_post::) + post(callback_with_header_post::) ) .route("/complex-query-param", - get(complex_query_param_get::) + get(complex_query_param_get::) ) .route("/enum_in_path/:path_param", - get(enum_in_path_path_param_get::) + get(enum_in_path_path_param_get::) ) .route("/form-test", - post(form_test::) + post(form_test::) ) .route("/get-with-bool", - get(get_with_boolean_parameter::) + get(get_with_boolean_parameter::) ) .route("/json-complex-query-param", - get(json_complex_query_param_get::) + get(json_complex_query_param_get::) ) .route("/mandatory-request-header", - get(mandatory_request_header_get::) + get(mandatory_request_header_get::) ) .route("/merge-patch-json", - get(merge_patch_json_get::) + get(merge_patch_json_get::) ) .route("/multiget", - get(multiget_get::) + get(multiget_get::) ) .route("/multiple-path-params-with-very-long-path-to-test-formatting/:path_param_a/:path_param_b", - get(multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get::) + get(multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get::) ) .route("/multiple_auth_scheme", - get(multiple_auth_scheme_get::) + get(multiple_auth_scheme_get::) ) .route("/one-of", - get(one_of_get::) + get(one_of_get::) ) .route("/operation-two-first-letter-headers", - post(two_first_letter_headers::) + post(two_first_letter_headers::) ) .route("/override-server", - get(override_server_get::) + get(override_server_get::) ) .route("/paramget", - get(paramget_get::) + get(paramget_get::) ) .route("/readonly_auth_scheme", - get(readonly_auth_scheme_get::) + get(readonly_auth_scheme_get::) ) .route("/register-callback", - post(register_callback_post::) + post(register_callback_post::) ) .route("/repos", - post(create_repo::) + post(create_repo::) ) .route("/repos/:repo_id", - get(get_repo_info::).get(get_repo_info::) + get(get_repo_info::).get(get_repo_info::) ) .route("/required_octet_stream", - put(required_octet_stream_put::) + put(required_octet_stream_put::) ) .route("/responses_with_headers", - get(responses_with_headers_get::) + get(responses_with_headers_get::) ) .route("/rfc7807", - get(rfc7807_get::) + get(rfc7807_get::) ) .route("/untyped_property", - get(untyped_property_get::) + get(untyped_property_get::) ) .route("/uuid", - get(uuid_get::) + get(uuid_get::) ) .route("/xml", - post(xml_post::).put(xml_put::) + post(xml_post::).put(xml_put::) ) .route("/xml_extra", - post(xml_extra_post::) + post(xml_extra_post::) ) .route("/xml_other", - post(xml_other_post::).put(xml_other_put::) + post(xml_other_post::).put(xml_other_put::) ) .with_state(api_impl) } @@ -117,7 +123,7 @@ fn any_of_get_validation( } /// AnyOfGet - GET /any-of #[tracing::instrument(skip_all)] -async fn any_of_get( +async fn any_of_get( method: Method, host: Host, cookies: CookieJar, @@ -126,7 +132,8 @@ async fn any_of_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = any_of_get_validation(query_params); @@ -216,10 +223,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -239,7 +246,7 @@ fn callback_with_header_post_validation( } /// CallbackWithHeaderPost - POST /callback-with-header #[tracing::instrument(skip_all)] -async fn callback_with_header_post( +async fn callback_with_header_post( method: Method, host: Host, cookies: CookieJar, @@ -248,7 +255,8 @@ async fn callback_with_header_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = callback_with_header_post_validation(query_params); @@ -273,10 +281,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -296,7 +304,7 @@ fn complex_query_param_get_validation( } /// ComplexQueryParamGet - GET /complex-query-param #[tracing::instrument(skip_all)] -async fn complex_query_param_get( +async fn complex_query_param_get( method: Method, host: Host, cookies: CookieJar, @@ -305,7 +313,8 @@ async fn complex_query_param_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = complex_query_param_get_validation(query_params); @@ -330,10 +339,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -353,7 +362,7 @@ fn enum_in_path_path_param_get_validation( } /// EnumInPathPathParamGet - GET /enum_in_path/{path_param} #[tracing::instrument(skip_all)] -async fn enum_in_path_path_param_get( +async fn enum_in_path_path_param_get( method: Method, host: Host, cookies: CookieJar, @@ -362,7 +371,8 @@ async fn enum_in_path_path_param_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = enum_in_path_path_param_get_validation(path_params); @@ -387,10 +397,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -418,7 +428,7 @@ fn form_test_validation( } /// FormTest - POST /form-test #[tracing::instrument(skip_all)] -async fn form_test( +async fn form_test( method: Method, host: Host, cookies: CookieJar, @@ -427,7 +437,8 @@ async fn form_test( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = form_test_validation(body); @@ -452,10 +463,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -475,7 +486,7 @@ fn get_with_boolean_parameter_validation( } /// GetWithBooleanParameter - GET /get-with-bool #[tracing::instrument(skip_all)] -async fn get_with_boolean_parameter( +async fn get_with_boolean_parameter( method: Method, host: Host, cookies: CookieJar, @@ -484,7 +495,8 @@ async fn get_with_boolean_parameter( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = get_with_boolean_parameter_validation(query_params); @@ -509,10 +521,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -532,7 +544,7 @@ fn json_complex_query_param_get_validation( } /// JsonComplexQueryParamGet - GET /json-complex-query-param #[tracing::instrument(skip_all)] -async fn json_complex_query_param_get( +async fn json_complex_query_param_get( method: Method, host: Host, cookies: CookieJar, @@ -541,7 +553,8 @@ async fn json_complex_query_param_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = json_complex_query_param_get_validation(query_params); @@ -566,10 +579,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -589,7 +602,7 @@ fn mandatory_request_header_get_validation( } /// MandatoryRequestHeaderGet - GET /mandatory-request-header #[tracing::instrument(skip_all)] -async fn mandatory_request_header_get( +async fn mandatory_request_header_get( method: Method, host: Host, cookies: CookieJar, @@ -598,7 +611,8 @@ async fn mandatory_request_header_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Header parameters let header_params = { @@ -656,10 +670,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -675,7 +689,7 @@ fn merge_patch_json_get_validation() -> std::result::Result<(), ValidationErrors } /// MergePatchJsonGet - GET /merge-patch-json #[tracing::instrument(skip_all)] -async fn merge_patch_json_get( +async fn merge_patch_json_get( method: Method, host: Host, cookies: CookieJar, @@ -683,7 +697,8 @@ async fn merge_patch_json_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = merge_patch_json_get_validation(); @@ -727,10 +742,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -746,7 +761,7 @@ fn multiget_get_validation() -> std::result::Result<(), ValidationErrors> { } /// MultigetGet - GET /multiget #[tracing::instrument(skip_all)] -async fn multiget_get( +async fn multiget_get( method: Method, host: Host, cookies: CookieJar, @@ -754,7 +769,8 @@ async fn multiget_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = multiget_get_validation(); @@ -912,10 +928,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -931,7 +947,7 @@ fn multiple_auth_scheme_get_validation() -> std::result::Result<(), ValidationEr } /// MultipleAuthSchemeGet - GET /multiple_auth_scheme #[tracing::instrument(skip_all)] -async fn multiple_auth_scheme_get( +async fn multiple_auth_scheme_get( method: Method, host: Host, cookies: CookieJar, @@ -939,7 +955,8 @@ async fn multiple_auth_scheme_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = multiple_auth_scheme_get_validation(); @@ -965,10 +982,10 @@ where response.body(Body::empty()) }, }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; }, }; @@ -994,6 +1011,7 @@ fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path async fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get< I, A, + E, >( method: Method, host: Host, @@ -1005,7 +1023,8 @@ async fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_ ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get_validation( @@ -1040,10 +1059,10 @@ where response.body(Body::empty()) }, }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; }, }; @@ -1059,7 +1078,7 @@ fn one_of_get_validation() -> std::result::Result<(), ValidationErrors> { } /// OneOfGet - GET /one-of #[tracing::instrument(skip_all)] -async fn one_of_get( +async fn one_of_get( method: Method, host: Host, cookies: CookieJar, @@ -1067,7 +1086,8 @@ async fn one_of_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = one_of_get_validation(); @@ -1108,10 +1128,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1127,7 +1147,7 @@ fn override_server_get_validation() -> std::result::Result<(), ValidationErrors> } /// OverrideServerGet - GET /override-server #[tracing::instrument(skip_all)] -async fn override_server_get( +async fn override_server_get( method: Method, host: Host, cookies: CookieJar, @@ -1135,7 +1155,8 @@ async fn override_server_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = override_server_get_validation(); @@ -1160,10 +1181,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1183,7 +1204,7 @@ fn paramget_get_validation( } /// ParamgetGet - GET /paramget #[tracing::instrument(skip_all)] -async fn paramget_get( +async fn paramget_get( method: Method, host: Host, cookies: CookieJar, @@ -1192,7 +1213,8 @@ async fn paramget_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = paramget_get_validation(query_params); @@ -1236,10 +1258,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1255,7 +1277,7 @@ fn readonly_auth_scheme_get_validation() -> std::result::Result<(), ValidationEr } /// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme #[tracing::instrument(skip_all)] -async fn readonly_auth_scheme_get( +async fn readonly_auth_scheme_get( method: Method, host: Host, cookies: CookieJar, @@ -1263,7 +1285,8 @@ async fn readonly_auth_scheme_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = readonly_auth_scheme_get_validation(); @@ -1289,10 +1312,10 @@ where response.body(Body::empty()) }, }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; }, }; @@ -1312,7 +1335,7 @@ fn register_callback_post_validation( } /// RegisterCallbackPost - POST /register-callback #[tracing::instrument(skip_all)] -async fn register_callback_post( +async fn register_callback_post( method: Method, host: Host, cookies: CookieJar, @@ -1321,7 +1344,8 @@ async fn register_callback_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = register_callback_post_validation(query_params); @@ -1346,10 +1370,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1373,7 +1397,7 @@ fn required_octet_stream_put_validation( } /// RequiredOctetStreamPut - PUT /required_octet_stream #[tracing::instrument(skip_all)] -async fn required_octet_stream_put( +async fn required_octet_stream_put( method: Method, host: Host, cookies: CookieJar, @@ -1382,7 +1406,8 @@ async fn required_octet_stream_put( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = required_octet_stream_put_validation(body); @@ -1407,10 +1432,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1426,7 +1451,7 @@ fn responses_with_headers_get_validation() -> std::result::Result<(), Validation } /// ResponsesWithHeadersGet - GET /responses_with_headers #[tracing::instrument(skip_all)] -async fn responses_with_headers_get( +async fn responses_with_headers_get( method: Method, host: Host, cookies: CookieJar, @@ -1434,7 +1459,8 @@ async fn responses_with_headers_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = responses_with_headers_get_validation(); @@ -1567,10 +1593,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1586,7 +1612,7 @@ fn rfc7807_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Rfc7807Get - GET /rfc7807 #[tracing::instrument(skip_all)] -async fn rfc7807_get( +async fn rfc7807_get( method: Method, host: Host, cookies: CookieJar, @@ -1594,7 +1620,8 @@ async fn rfc7807_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = rfc7807_get_validation(); @@ -1674,10 +1701,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1697,7 +1724,7 @@ fn two_first_letter_headers_validation( } /// TwoFirstLetterHeaders - POST /operation-two-first-letter-headers #[tracing::instrument(skip_all)] -async fn two_first_letter_headers( +async fn two_first_letter_headers( method: Method, host: Host, cookies: CookieJar, @@ -1706,7 +1733,8 @@ async fn two_first_letter_headers( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Header parameters let header_params = { @@ -1774,10 +1802,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1807,7 +1835,7 @@ fn untyped_property_get_validation( } /// UntypedPropertyGet - GET /untyped_property #[tracing::instrument(skip_all)] -async fn untyped_property_get( +async fn untyped_property_get( method: Method, host: Host, cookies: CookieJar, @@ -1816,7 +1844,8 @@ async fn untyped_property_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = untyped_property_get_validation(body); @@ -1842,10 +1871,10 @@ where response.body(Body::empty()) }, }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; }, }; @@ -1861,7 +1890,7 @@ fn uuid_get_validation() -> std::result::Result<(), ValidationErrors> { } /// UuidGet - GET /uuid #[tracing::instrument(skip_all)] -async fn uuid_get( +async fn uuid_get( method: Method, host: Host, cookies: CookieJar, @@ -1869,7 +1898,8 @@ async fn uuid_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = uuid_get_validation(); @@ -1910,10 +1940,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1935,7 +1965,7 @@ fn xml_extra_post_validation(body: Bytes) -> std::result::Result<(Bytes,), Valid } /// XmlExtraPost - POST /xml_extra #[tracing::instrument(skip_all)] -async fn xml_extra_post( +async fn xml_extra_post( method: Method, host: Host, cookies: CookieJar, @@ -1944,7 +1974,8 @@ async fn xml_extra_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = xml_extra_post_validation(body); @@ -1973,10 +2004,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1998,7 +2029,7 @@ fn xml_other_post_validation(body: Bytes) -> std::result::Result<(Bytes,), Valid } /// XmlOtherPost - POST /xml_other #[tracing::instrument(skip_all)] -async fn xml_other_post( +async fn xml_other_post( method: Method, host: Host, cookies: CookieJar, @@ -2007,7 +2038,8 @@ async fn xml_other_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = xml_other_post_validation(body); @@ -2048,10 +2080,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2073,7 +2105,7 @@ fn xml_other_put_validation(body: Bytes) -> std::result::Result<(Bytes,), Valida } /// XmlOtherPut - PUT /xml_other #[tracing::instrument(skip_all)] -async fn xml_other_put( +async fn xml_other_put( method: Method, host: Host, cookies: CookieJar, @@ -2082,7 +2114,8 @@ async fn xml_other_put( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = xml_other_put_validation(body); @@ -2111,10 +2144,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2136,7 +2169,7 @@ fn xml_post_validation(body: Bytes) -> std::result::Result<(Bytes,), ValidationE } /// XmlPost - POST /xml #[tracing::instrument(skip_all)] -async fn xml_post( +async fn xml_post( method: Method, host: Host, cookies: CookieJar, @@ -2145,7 +2178,8 @@ async fn xml_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = xml_post_validation(body); @@ -2174,10 +2208,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2199,7 +2233,7 @@ fn xml_put_validation(body: Bytes) -> std::result::Result<(Bytes,), ValidationEr } /// XmlPut - PUT /xml #[tracing::instrument(skip_all)] -async fn xml_put( +async fn xml_put( method: Method, host: Host, cookies: CookieJar, @@ -2208,7 +2242,8 @@ async fn xml_put( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = xml_put_validation(body); @@ -2234,10 +2269,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2257,7 +2292,7 @@ fn get_repo_info_validation( } /// GetRepoInfo - GET /repos/{repoId} #[tracing::instrument(skip_all)] -async fn get_repo_info( +async fn get_repo_info( method: Method, host: Host, cookies: CookieJar, @@ -2266,7 +2301,8 @@ async fn get_repo_info( ) -> Result where I: AsRef + Send + Sync, - A: apis::info_repo::InfoRepo, + A: apis::info_repo::InfoRepo + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = get_repo_info_validation(path_params); @@ -2310,10 +2346,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2341,7 +2377,7 @@ fn create_repo_validation( } /// CreateRepo - POST /repos #[tracing::instrument(skip_all)] -async fn create_repo( +async fn create_repo( method: Method, host: Host, cookies: CookieJar, @@ -2350,7 +2386,8 @@ async fn create_repo( ) -> Result where I: AsRef + Send + Sync, - A: apis::repo::Repo, + A: apis::repo::Repo + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let validation = create_repo_validation(body); @@ -2375,10 +2412,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 dd0e372a0747..c94615271690 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/README.md +++ b/samples/server/petstore/rust-axum/output/ops-v3/README.md @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl ops-v3::Api for ServerImpl { +impl ops_v3::apis::default::Api for ServerImpl { // API implementation goes here } +impl ops_v3::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = ops-v3::server::new(Arc::new(ServerImpl)); + let app = ops_v3::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs index 387f4b3fa792..5bf812e0f574 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs @@ -306,14 +306,14 @@ pub enum Op9GetResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// Op10Get - GET /op10 async fn op10_get( &self, method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op11Get - GET /op11 async fn op11_get( @@ -321,7 +321,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op12Get - GET /op12 async fn op12_get( @@ -329,7 +329,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op13Get - GET /op13 async fn op13_get( @@ -337,7 +337,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op14Get - GET /op14 async fn op14_get( @@ -345,7 +345,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op15Get - GET /op15 async fn op15_get( @@ -353,7 +353,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op16Get - GET /op16 async fn op16_get( @@ -361,7 +361,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op17Get - GET /op17 async fn op17_get( @@ -369,7 +369,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op18Get - GET /op18 async fn op18_get( @@ -377,7 +377,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op19Get - GET /op19 async fn op19_get( @@ -385,7 +385,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op1Get - GET /op1 async fn op1_get( @@ -393,7 +393,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op20Get - GET /op20 async fn op20_get( @@ -401,7 +401,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op21Get - GET /op21 async fn op21_get( @@ -409,7 +409,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op22Get - GET /op22 async fn op22_get( @@ -417,7 +417,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op23Get - GET /op23 async fn op23_get( @@ -425,7 +425,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op24Get - GET /op24 async fn op24_get( @@ -433,7 +433,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op25Get - GET /op25 async fn op25_get( @@ -441,7 +441,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op26Get - GET /op26 async fn op26_get( @@ -449,7 +449,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op27Get - GET /op27 async fn op27_get( @@ -457,7 +457,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op28Get - GET /op28 async fn op28_get( @@ -465,7 +465,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op29Get - GET /op29 async fn op29_get( @@ -473,7 +473,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op2Get - GET /op2 async fn op2_get( @@ -481,7 +481,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op30Get - GET /op30 async fn op30_get( @@ -489,7 +489,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op31Get - GET /op31 async fn op31_get( @@ -497,7 +497,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op32Get - GET /op32 async fn op32_get( @@ -505,7 +505,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op33Get - GET /op33 async fn op33_get( @@ -513,7 +513,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op34Get - GET /op34 async fn op34_get( @@ -521,7 +521,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op35Get - GET /op35 async fn op35_get( @@ -529,7 +529,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op36Get - GET /op36 async fn op36_get( @@ -537,7 +537,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op37Get - GET /op37 async fn op37_get( @@ -545,7 +545,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op3Get - GET /op3 async fn op3_get( @@ -553,7 +553,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op4Get - GET /op4 async fn op4_get( @@ -561,7 +561,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op5Get - GET /op5 async fn op5_get( @@ -569,7 +569,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op6Get - GET /op6 async fn op6_get( @@ -577,7 +577,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op7Get - GET /op7 async fn op7_get( @@ -585,7 +585,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op8Get - GET /op8 async fn op8_get( @@ -593,7 +593,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Op9Get - GET /op9 async fn op9_get( @@ -601,5 +601,5 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs index 1be8d340b8e0..dce6c9a8e2de 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs @@ -1 +1,14 @@ pub mod default; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs index a8b3ed89bc76..a1b40fd40049 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs @@ -13,50 +13,51 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + 'static, + A: apis::default::Default + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() - .route("/op1", get(op1_get::)) - .route("/op10", get(op10_get::)) - .route("/op11", get(op11_get::)) - .route("/op12", get(op12_get::)) - .route("/op13", get(op13_get::)) - .route("/op14", get(op14_get::)) - .route("/op15", get(op15_get::)) - .route("/op16", get(op16_get::)) - .route("/op17", get(op17_get::)) - .route("/op18", get(op18_get::)) - .route("/op19", get(op19_get::)) - .route("/op2", get(op2_get::)) - .route("/op20", get(op20_get::)) - .route("/op21", get(op21_get::)) - .route("/op22", get(op22_get::)) - .route("/op23", get(op23_get::)) - .route("/op24", get(op24_get::)) - .route("/op25", get(op25_get::)) - .route("/op26", get(op26_get::)) - .route("/op27", get(op27_get::)) - .route("/op28", get(op28_get::)) - .route("/op29", get(op29_get::)) - .route("/op3", get(op3_get::)) - .route("/op30", get(op30_get::)) - .route("/op31", get(op31_get::)) - .route("/op32", get(op32_get::)) - .route("/op33", get(op33_get::)) - .route("/op34", get(op34_get::)) - .route("/op35", get(op35_get::)) - .route("/op36", get(op36_get::)) - .route("/op37", get(op37_get::)) - .route("/op4", get(op4_get::)) - .route("/op5", get(op5_get::)) - .route("/op6", get(op6_get::)) - .route("/op7", get(op7_get::)) - .route("/op8", get(op8_get::)) - .route("/op9", get(op9_get::)) + .route("/op1", get(op1_get::)) + .route("/op10", get(op10_get::)) + .route("/op11", get(op11_get::)) + .route("/op12", get(op12_get::)) + .route("/op13", get(op13_get::)) + .route("/op14", get(op14_get::)) + .route("/op15", get(op15_get::)) + .route("/op16", get(op16_get::)) + .route("/op17", get(op17_get::)) + .route("/op18", get(op18_get::)) + .route("/op19", get(op19_get::)) + .route("/op2", get(op2_get::)) + .route("/op20", get(op20_get::)) + .route("/op21", get(op21_get::)) + .route("/op22", get(op22_get::)) + .route("/op23", get(op23_get::)) + .route("/op24", get(op24_get::)) + .route("/op25", get(op25_get::)) + .route("/op26", get(op26_get::)) + .route("/op27", get(op27_get::)) + .route("/op28", get(op28_get::)) + .route("/op29", get(op29_get::)) + .route("/op3", get(op3_get::)) + .route("/op30", get(op30_get::)) + .route("/op31", get(op31_get::)) + .route("/op32", get(op32_get::)) + .route("/op33", get(op33_get::)) + .route("/op34", get(op34_get::)) + .route("/op35", get(op35_get::)) + .route("/op36", get(op36_get::)) + .route("/op37", get(op37_get::)) + .route("/op4", get(op4_get::)) + .route("/op5", get(op5_get::)) + .route("/op6", get(op6_get::)) + .route("/op7", get(op7_get::)) + .route("/op8", get(op8_get::)) + .route("/op9", get(op9_get::)) .with_state(api_impl) } @@ -66,7 +67,7 @@ fn op10_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op10Get - GET /op10 #[tracing::instrument(skip_all)] -async fn op10_get( +async fn op10_get( method: Method, host: Host, cookies: CookieJar, @@ -74,7 +75,8 @@ async fn op10_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op10_get_validation()) @@ -99,10 +101,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -118,7 +120,7 @@ fn op11_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op11Get - GET /op11 #[tracing::instrument(skip_all)] -async fn op11_get( +async fn op11_get( method: Method, host: Host, cookies: CookieJar, @@ -126,7 +128,8 @@ async fn op11_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op11_get_validation()) @@ -151,10 +154,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -170,7 +173,7 @@ fn op12_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op12Get - GET /op12 #[tracing::instrument(skip_all)] -async fn op12_get( +async fn op12_get( method: Method, host: Host, cookies: CookieJar, @@ -178,7 +181,8 @@ async fn op12_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op12_get_validation()) @@ -203,10 +207,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -222,7 +226,7 @@ fn op13_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op13Get - GET /op13 #[tracing::instrument(skip_all)] -async fn op13_get( +async fn op13_get( method: Method, host: Host, cookies: CookieJar, @@ -230,7 +234,8 @@ async fn op13_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op13_get_validation()) @@ -255,10 +260,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -274,7 +279,7 @@ fn op14_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op14Get - GET /op14 #[tracing::instrument(skip_all)] -async fn op14_get( +async fn op14_get( method: Method, host: Host, cookies: CookieJar, @@ -282,7 +287,8 @@ async fn op14_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op14_get_validation()) @@ -307,10 +313,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -326,7 +332,7 @@ fn op15_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op15Get - GET /op15 #[tracing::instrument(skip_all)] -async fn op15_get( +async fn op15_get( method: Method, host: Host, cookies: CookieJar, @@ -334,7 +340,8 @@ async fn op15_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op15_get_validation()) @@ -359,10 +366,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -378,7 +385,7 @@ fn op16_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op16Get - GET /op16 #[tracing::instrument(skip_all)] -async fn op16_get( +async fn op16_get( method: Method, host: Host, cookies: CookieJar, @@ -386,7 +393,8 @@ async fn op16_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op16_get_validation()) @@ -411,10 +419,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -430,7 +438,7 @@ fn op17_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op17Get - GET /op17 #[tracing::instrument(skip_all)] -async fn op17_get( +async fn op17_get( method: Method, host: Host, cookies: CookieJar, @@ -438,7 +446,8 @@ async fn op17_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op17_get_validation()) @@ -463,10 +472,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -482,7 +491,7 @@ fn op18_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op18Get - GET /op18 #[tracing::instrument(skip_all)] -async fn op18_get( +async fn op18_get( method: Method, host: Host, cookies: CookieJar, @@ -490,7 +499,8 @@ async fn op18_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op18_get_validation()) @@ -515,10 +525,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -534,7 +544,7 @@ fn op19_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op19Get - GET /op19 #[tracing::instrument(skip_all)] -async fn op19_get( +async fn op19_get( method: Method, host: Host, cookies: CookieJar, @@ -542,7 +552,8 @@ async fn op19_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op19_get_validation()) @@ -567,10 +578,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -586,7 +597,7 @@ fn op1_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op1Get - GET /op1 #[tracing::instrument(skip_all)] -async fn op1_get( +async fn op1_get( method: Method, host: Host, cookies: CookieJar, @@ -594,7 +605,8 @@ async fn op1_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op1_get_validation()) @@ -619,10 +631,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -638,7 +650,7 @@ fn op20_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op20Get - GET /op20 #[tracing::instrument(skip_all)] -async fn op20_get( +async fn op20_get( method: Method, host: Host, cookies: CookieJar, @@ -646,7 +658,8 @@ async fn op20_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op20_get_validation()) @@ -671,10 +684,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -690,7 +703,7 @@ fn op21_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op21Get - GET /op21 #[tracing::instrument(skip_all)] -async fn op21_get( +async fn op21_get( method: Method, host: Host, cookies: CookieJar, @@ -698,7 +711,8 @@ async fn op21_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op21_get_validation()) @@ -723,10 +737,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -742,7 +756,7 @@ fn op22_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op22Get - GET /op22 #[tracing::instrument(skip_all)] -async fn op22_get( +async fn op22_get( method: Method, host: Host, cookies: CookieJar, @@ -750,7 +764,8 @@ async fn op22_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op22_get_validation()) @@ -775,10 +790,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -794,7 +809,7 @@ fn op23_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op23Get - GET /op23 #[tracing::instrument(skip_all)] -async fn op23_get( +async fn op23_get( method: Method, host: Host, cookies: CookieJar, @@ -802,7 +817,8 @@ async fn op23_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op23_get_validation()) @@ -827,10 +843,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -846,7 +862,7 @@ fn op24_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op24Get - GET /op24 #[tracing::instrument(skip_all)] -async fn op24_get( +async fn op24_get( method: Method, host: Host, cookies: CookieJar, @@ -854,7 +870,8 @@ async fn op24_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op24_get_validation()) @@ -879,10 +896,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -898,7 +915,7 @@ fn op25_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op25Get - GET /op25 #[tracing::instrument(skip_all)] -async fn op25_get( +async fn op25_get( method: Method, host: Host, cookies: CookieJar, @@ -906,7 +923,8 @@ async fn op25_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op25_get_validation()) @@ -931,10 +949,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -950,7 +968,7 @@ fn op26_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op26Get - GET /op26 #[tracing::instrument(skip_all)] -async fn op26_get( +async fn op26_get( method: Method, host: Host, cookies: CookieJar, @@ -958,7 +976,8 @@ async fn op26_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op26_get_validation()) @@ -983,10 +1002,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1002,7 +1021,7 @@ fn op27_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op27Get - GET /op27 #[tracing::instrument(skip_all)] -async fn op27_get( +async fn op27_get( method: Method, host: Host, cookies: CookieJar, @@ -1010,7 +1029,8 @@ async fn op27_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op27_get_validation()) @@ -1035,10 +1055,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1054,7 +1074,7 @@ fn op28_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op28Get - GET /op28 #[tracing::instrument(skip_all)] -async fn op28_get( +async fn op28_get( method: Method, host: Host, cookies: CookieJar, @@ -1062,7 +1082,8 @@ async fn op28_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op28_get_validation()) @@ -1087,10 +1108,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1106,7 +1127,7 @@ fn op29_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op29Get - GET /op29 #[tracing::instrument(skip_all)] -async fn op29_get( +async fn op29_get( method: Method, host: Host, cookies: CookieJar, @@ -1114,7 +1135,8 @@ async fn op29_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op29_get_validation()) @@ -1139,10 +1161,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1158,7 +1180,7 @@ fn op2_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op2Get - GET /op2 #[tracing::instrument(skip_all)] -async fn op2_get( +async fn op2_get( method: Method, host: Host, cookies: CookieJar, @@ -1166,7 +1188,8 @@ async fn op2_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op2_get_validation()) @@ -1191,10 +1214,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1210,7 +1233,7 @@ fn op30_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op30Get - GET /op30 #[tracing::instrument(skip_all)] -async fn op30_get( +async fn op30_get( method: Method, host: Host, cookies: CookieJar, @@ -1218,7 +1241,8 @@ async fn op30_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op30_get_validation()) @@ -1243,10 +1267,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1262,7 +1286,7 @@ fn op31_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op31Get - GET /op31 #[tracing::instrument(skip_all)] -async fn op31_get( +async fn op31_get( method: Method, host: Host, cookies: CookieJar, @@ -1270,7 +1294,8 @@ async fn op31_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op31_get_validation()) @@ -1295,10 +1320,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1314,7 +1339,7 @@ fn op32_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op32Get - GET /op32 #[tracing::instrument(skip_all)] -async fn op32_get( +async fn op32_get( method: Method, host: Host, cookies: CookieJar, @@ -1322,7 +1347,8 @@ async fn op32_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op32_get_validation()) @@ -1347,10 +1373,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1366,7 +1392,7 @@ fn op33_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op33Get - GET /op33 #[tracing::instrument(skip_all)] -async fn op33_get( +async fn op33_get( method: Method, host: Host, cookies: CookieJar, @@ -1374,7 +1400,8 @@ async fn op33_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op33_get_validation()) @@ -1399,10 +1426,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1418,7 +1445,7 @@ fn op34_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op34Get - GET /op34 #[tracing::instrument(skip_all)] -async fn op34_get( +async fn op34_get( method: Method, host: Host, cookies: CookieJar, @@ -1426,7 +1453,8 @@ async fn op34_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op34_get_validation()) @@ -1451,10 +1479,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1470,7 +1498,7 @@ fn op35_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op35Get - GET /op35 #[tracing::instrument(skip_all)] -async fn op35_get( +async fn op35_get( method: Method, host: Host, cookies: CookieJar, @@ -1478,7 +1506,8 @@ async fn op35_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op35_get_validation()) @@ -1503,10 +1532,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1522,7 +1551,7 @@ fn op36_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op36Get - GET /op36 #[tracing::instrument(skip_all)] -async fn op36_get( +async fn op36_get( method: Method, host: Host, cookies: CookieJar, @@ -1530,7 +1559,8 @@ async fn op36_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op36_get_validation()) @@ -1555,10 +1585,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1574,7 +1604,7 @@ fn op37_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op37Get - GET /op37 #[tracing::instrument(skip_all)] -async fn op37_get( +async fn op37_get( method: Method, host: Host, cookies: CookieJar, @@ -1582,7 +1612,8 @@ async fn op37_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op37_get_validation()) @@ -1607,10 +1638,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1626,7 +1657,7 @@ fn op3_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op3Get - GET /op3 #[tracing::instrument(skip_all)] -async fn op3_get( +async fn op3_get( method: Method, host: Host, cookies: CookieJar, @@ -1634,7 +1665,8 @@ async fn op3_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op3_get_validation()) @@ -1659,10 +1691,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1678,7 +1710,7 @@ fn op4_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op4Get - GET /op4 #[tracing::instrument(skip_all)] -async fn op4_get( +async fn op4_get( method: Method, host: Host, cookies: CookieJar, @@ -1686,7 +1718,8 @@ async fn op4_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op4_get_validation()) @@ -1711,10 +1744,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1730,7 +1763,7 @@ fn op5_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op5Get - GET /op5 #[tracing::instrument(skip_all)] -async fn op5_get( +async fn op5_get( method: Method, host: Host, cookies: CookieJar, @@ -1738,7 +1771,8 @@ async fn op5_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op5_get_validation()) @@ -1763,10 +1797,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1782,7 +1816,7 @@ fn op6_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op6Get - GET /op6 #[tracing::instrument(skip_all)] -async fn op6_get( +async fn op6_get( method: Method, host: Host, cookies: CookieJar, @@ -1790,7 +1824,8 @@ async fn op6_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op6_get_validation()) @@ -1815,10 +1850,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1834,7 +1869,7 @@ fn op7_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op7Get - GET /op7 #[tracing::instrument(skip_all)] -async fn op7_get( +async fn op7_get( method: Method, host: Host, cookies: CookieJar, @@ -1842,7 +1877,8 @@ async fn op7_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op7_get_validation()) @@ -1867,10 +1903,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1886,7 +1922,7 @@ fn op8_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op8Get - GET /op8 #[tracing::instrument(skip_all)] -async fn op8_get( +async fn op8_get( method: Method, host: Host, cookies: CookieJar, @@ -1894,7 +1930,8 @@ async fn op8_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op8_get_validation()) @@ -1919,10 +1956,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1938,7 +1975,7 @@ fn op9_get_validation() -> std::result::Result<(), ValidationErrors> { } /// Op9Get - GET /op9 #[tracing::instrument(skip_all)] -async fn op9_get( +async fn op9_get( method: Method, host: Host, cookies: CookieJar, @@ -1946,7 +1983,8 @@ async fn op9_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || op9_get_validation()) @@ -1971,10 +2009,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 abfcfff517be..ddad4bd4f6ae 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 @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl petstore-with-fake-endpoints-models-for-testing::Api for ServerImpl { +impl petstore_with_fake_endpoints_models_for_testing::apis::default::Api for ServerImpl { // API implementation goes here } +impl petstore_with_fake_endpoints_models_for_testing::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = petstore-with-fake-endpoints-models-for-testing::server::new(Arc::new(ServerImpl)); + let app = petstore_with_fake_endpoints_models_for_testing::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs index f64e2e451bb9..5291cd90bd14 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs @@ -18,7 +18,9 @@ pub enum TestSpecialTagsResponse { /// AnotherFake #[async_trait] #[allow(clippy::ptr_arg)] -pub trait AnotherFake { +pub trait AnotherFake: + super::ErrorHandler +{ /// To test special tags. /// /// TestSpecialTags - PATCH /v2/another-fake/dummy @@ -28,5 +30,5 @@ pub trait AnotherFake { host: Host, cookies: CookieJar, body: models::Client, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs index 22ad661101aa..ef29bf5a02cc 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs @@ -118,14 +118,14 @@ pub enum TestJsonFormDataResponse { /// Fake #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Fake { +pub trait Fake: super::ErrorHandler { /// Call123example - GET /v2/fake/operation-with-numeric-id async fn call123example( &self, method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean async fn fake_outer_boolean_serialize( @@ -134,7 +134,7 @@ pub trait Fake { host: Host, cookies: CookieJar, body: Option, - ) -> Result; + ) -> Result; /// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite async fn fake_outer_composite_serialize( @@ -143,7 +143,7 @@ pub trait Fake { host: Host, cookies: CookieJar, body: Option, - ) -> Result; + ) -> Result; /// FakeOuterNumberSerialize - POST /v2/fake/outer/number async fn fake_outer_number_serialize( @@ -152,7 +152,7 @@ pub trait Fake { host: Host, cookies: CookieJar, body: Option, - ) -> Result; + ) -> Result; /// FakeOuterStringSerialize - POST /v2/fake/outer/string async fn fake_outer_string_serialize( @@ -161,7 +161,7 @@ pub trait Fake { host: Host, cookies: CookieJar, body: Option, - ) -> Result; + ) -> Result; /// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description async fn fake_response_with_numerical_description( @@ -169,7 +169,7 @@ pub trait Fake { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param} async fn hyphen_param( @@ -178,7 +178,7 @@ pub trait Fake { host: Host, cookies: CookieJar, path_params: models::HyphenParamPathParams, - ) -> Result; + ) -> Result; /// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params async fn test_body_with_query_params( @@ -188,7 +188,7 @@ pub trait Fake { cookies: CookieJar, query_params: models::TestBodyWithQueryParamsQueryParams, body: models::User, - ) -> Result; + ) -> Result; /// To test \"client\" model. /// @@ -199,7 +199,7 @@ pub trait Fake { host: Host, cookies: CookieJar, body: models::Client, - ) -> Result; + ) -> Result; /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트. /// @@ -210,7 +210,7 @@ pub trait Fake { host: Host, cookies: CookieJar, body: models::TestEndpointParametersRequest, - ) -> Result; + ) -> Result; /// To test enum parameters. /// @@ -223,7 +223,7 @@ pub trait Fake { header_params: models::TestEnumParametersHeaderParams, query_params: models::TestEnumParametersQueryParams, body: Option, - ) -> Result; + ) -> Result; /// test inline additionalProperties. /// @@ -234,7 +234,7 @@ pub trait Fake { host: Host, cookies: CookieJar, body: std::collections::HashMap, - ) -> Result; + ) -> Result; /// test json serialization of form data. /// @@ -245,5 +245,5 @@ pub trait Fake { host: Host, cookies: CookieJar, body: models::TestJsonFormDataRequest, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs index 100f9dc7ad59..867fab8a5df4 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs @@ -18,7 +18,9 @@ pub enum TestClassnameResponse { /// FakeClassnameTags123 #[async_trait] #[allow(clippy::ptr_arg)] -pub trait FakeClassnameTags123 { +pub trait FakeClassnameTags123: + super::ErrorHandler +{ /// To test class name in snake case. /// /// TestClassname - PATCH /v2/fake_classname_test @@ -28,5 +30,5 @@ pub trait FakeClassnameTags123 { host: Host, cookies: CookieJar, body: models::Client, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs index 720eb77d2bfb..478004700c14 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs @@ -17,3 +17,16 @@ pub trait ApiKeyAuthHeader { key: &str, ) -> Option; } + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs index abac35a8571b..0048d85c1a82 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs @@ -86,7 +86,7 @@ pub enum UploadFileResponse { /// Pet #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Pet { +pub trait Pet: super::ErrorHandler { type Claims; /// Add a new pet to the store. @@ -98,7 +98,7 @@ pub trait Pet { host: Host, cookies: CookieJar, body: models::Pet, - ) -> Result; + ) -> Result; /// Deletes a pet. /// @@ -110,7 +110,7 @@ pub trait Pet { cookies: CookieJar, header_params: models::DeletePetHeaderParams, path_params: models::DeletePetPathParams, - ) -> Result; + ) -> Result; /// Finds Pets by status. /// @@ -121,7 +121,7 @@ pub trait Pet { host: Host, cookies: CookieJar, query_params: models::FindPetsByStatusQueryParams, - ) -> Result; + ) -> Result; /// Finds Pets by tags. /// @@ -132,7 +132,7 @@ pub trait Pet { host: Host, cookies: CookieJar, query_params: models::FindPetsByTagsQueryParams, - ) -> Result; + ) -> Result; /// Find pet by ID. /// @@ -144,7 +144,7 @@ pub trait Pet { cookies: CookieJar, claims: Self::Claims, path_params: models::GetPetByIdPathParams, - ) -> Result; + ) -> Result; /// Update an existing pet. /// @@ -155,7 +155,7 @@ pub trait Pet { host: Host, cookies: CookieJar, body: models::Pet, - ) -> Result; + ) -> Result; /// Updates a pet in the store with form data. /// @@ -167,7 +167,7 @@ pub trait Pet { cookies: CookieJar, path_params: models::UpdatePetWithFormPathParams, body: Option, - ) -> Result; + ) -> Result; /// uploads an image. /// @@ -179,5 +179,5 @@ pub trait Pet { cookies: CookieJar, path_params: models::UploadFilePathParams, body: Multipart, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs index 56c33f935c7f..bd296c015fe7 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs @@ -50,7 +50,7 @@ pub enum PlaceOrderResponse { /// Store #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Store { +pub trait Store: super::ErrorHandler { type Claims; /// Delete purchase order by ID. @@ -62,7 +62,7 @@ pub trait Store { host: Host, cookies: CookieJar, path_params: models::DeleteOrderPathParams, - ) -> Result; + ) -> Result; /// Returns pet inventories by status. /// @@ -73,7 +73,7 @@ pub trait Store { host: Host, cookies: CookieJar, claims: Self::Claims, - ) -> Result; + ) -> Result; /// Find purchase order by ID. /// @@ -84,7 +84,7 @@ pub trait Store { host: Host, cookies: CookieJar, path_params: models::GetOrderByIdPathParams, - ) -> Result; + ) -> Result; /// Place an order for a pet. /// @@ -95,5 +95,5 @@ pub trait Store { host: Host, cookies: CookieJar, body: models::Order, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs index 1aa623644320..e6c36ba26360 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs @@ -88,7 +88,7 @@ pub enum UpdateUserResponse { /// User #[async_trait] #[allow(clippy::ptr_arg)] -pub trait User { +pub trait User: super::ErrorHandler { /// Create user. /// /// CreateUser - POST /v2/user @@ -98,7 +98,7 @@ pub trait User { host: Host, cookies: CookieJar, body: models::User, - ) -> Result; + ) -> Result; /// Creates list of users with given input array. /// @@ -109,7 +109,7 @@ pub trait User { host: Host, cookies: CookieJar, body: Vec, - ) -> Result; + ) -> Result; /// Creates list of users with given input array. /// @@ -120,7 +120,7 @@ pub trait User { host: Host, cookies: CookieJar, body: Vec, - ) -> Result; + ) -> Result; /// Delete user. /// @@ -131,7 +131,7 @@ pub trait User { host: Host, cookies: CookieJar, path_params: models::DeleteUserPathParams, - ) -> Result; + ) -> Result; /// Get user by user name. /// @@ -142,7 +142,7 @@ pub trait User { host: Host, cookies: CookieJar, path_params: models::GetUserByNamePathParams, - ) -> Result; + ) -> Result; /// Logs user into the system. /// @@ -153,7 +153,7 @@ pub trait User { host: Host, cookies: CookieJar, query_params: models::LoginUserQueryParams, - ) -> Result; + ) -> Result; /// Logs out current logged in user session. /// @@ -163,7 +163,7 @@ pub trait User { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Updated user. /// @@ -175,5 +175,5 @@ pub trait User { cookies: CookieJar, path_params: models::UpdateUserPathParams, body: models::User, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 33a54a8cc5da..69655b140d2d 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -13,102 +13,114 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::another_fake::AnotherFake - + apis::fake::Fake - + apis::fake_classname_tags123::FakeClassnameTags123 - + apis::pet::Pet - + apis::store::Store - + apis::user::User + A: apis::another_fake::AnotherFake + + apis::fake::Fake + + apis::fake_classname_tags123::FakeClassnameTags123 + + apis::pet::Pet + + apis::store::Store + + apis::user::User + apis::ApiKeyAuthHeader + + Send + + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, C: Send + Sync + 'static, { // build our application with a route Router::new() - .route("/v2/another-fake/dummy", patch(test_special_tags::)) + .route( + "/v2/another-fake/dummy", + patch(test_special_tags::), + ) .route( "/v2/fake", - get(test_enum_parameters::) - .patch(test_client_model::) - .post(test_endpoint_parameters::), + get(test_enum_parameters::) + .patch(test_client_model::) + .post(test_endpoint_parameters::), ) .route( "/v2/fake/body-with-query-params", - put(test_body_with_query_params::), + put(test_body_with_query_params::), ) .route( "/v2/fake/hyphenParam/:hyphen_param", - get(hyphen_param::), + get(hyphen_param::), ) .route( "/v2/fake/inline-additionalProperties", - post(test_inline_additional_properties::), + post(test_inline_additional_properties::), ) - .route("/v2/fake/jsonFormData", get(test_json_form_data::)) + .route("/v2/fake/jsonFormData", get(test_json_form_data::)) .route( "/v2/fake/operation-with-numeric-id", - get(call123example::), + get(call123example::), ) .route( "/v2/fake/outer/boolean", - post(fake_outer_boolean_serialize::), + post(fake_outer_boolean_serialize::), ) .route( "/v2/fake/outer/composite", - post(fake_outer_composite_serialize::), + post(fake_outer_composite_serialize::), ) .route( "/v2/fake/outer/number", - post(fake_outer_number_serialize::), + post(fake_outer_number_serialize::), ) .route( "/v2/fake/outer/string", - post(fake_outer_string_serialize::), + post(fake_outer_string_serialize::), ) .route( "/v2/fake/response-with-numerical-description", - get(fake_response_with_numerical_description::), + get(fake_response_with_numerical_description::), ) - .route("/v2/fake_classname_test", patch(test_classname::)) + .route("/v2/fake_classname_test", patch(test_classname::)) .route( "/v2/pet", - post(add_pet::).put(update_pet::), + post(add_pet::).put(update_pet::), ) .route( "/v2/pet/:pet_id", - delete(delete_pet::) - .get(get_pet_by_id::) - .post(update_pet_with_form::), + delete(delete_pet::) + .get(get_pet_by_id::) + .post(update_pet_with_form::), + ) + .route( + "/v2/pet/:pet_id/uploadImage", + post(upload_file::), + ) + .route( + "/v2/pet/findByStatus", + get(find_pets_by_status::), ) - .route("/v2/pet/:pet_id/uploadImage", post(upload_file::)) - .route("/v2/pet/findByStatus", get(find_pets_by_status::)) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) - .route("/v2/store/inventory", get(get_inventory::)) - .route("/v2/store/order", post(place_order::)) + .route("/v2/pet/findByTags", get(find_pets_by_tags::)) + .route("/v2/store/inventory", get(get_inventory::)) + .route("/v2/store/order", post(place_order::)) .route( "/v2/store/order/:order_id", - delete(delete_order::).get(get_order_by_id::), + delete(delete_order::).get(get_order_by_id::), ) - .route("/v2/user", post(create_user::)) + .route("/v2/user", post(create_user::)) .route( "/v2/user/:username", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), + delete(delete_user::) + .get(get_user_by_name::) + .put(update_user::), ) .route( "/v2/user/createWithArray", - post(create_users_with_array_input::), + post(create_users_with_array_input::), ) .route( "/v2/user/createWithList", - post(create_users_with_list_input::), + post(create_users_with_list_input::), ) - .route("/v2/user/login", get(login_user::)) - .route("/v2/user/logout", get(logout_user::)) + .route("/v2/user/login", get(login_user::)) + .route("/v2/user/logout", get(logout_user::)) .with_state(api_impl) } @@ -130,7 +142,7 @@ fn test_special_tags_validation( } /// TestSpecialTags - PATCH /v2/another-fake/dummy #[tracing::instrument(skip_all)] -async fn test_special_tags( +async fn test_special_tags( method: Method, host: Host, cookies: CookieJar, @@ -139,7 +151,8 @@ async fn test_special_tags( ) -> Result where I: AsRef + Send + Sync, - A: apis::another_fake::AnotherFake, + A: apis::another_fake::AnotherFake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || test_special_tags_validation(body)) @@ -186,10 +199,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -205,7 +218,7 @@ fn call123example_validation() -> std::result::Result<(), ValidationErrors> { } /// Call123example - GET /v2/fake/operation-with-numeric-id #[tracing::instrument(skip_all)] -async fn call123example( +async fn call123example( method: Method, host: Host, cookies: CookieJar, @@ -213,7 +226,8 @@ async fn call123example( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || call123example_validation()) @@ -241,10 +255,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -274,7 +288,7 @@ fn fake_outer_boolean_serialize_validation( } /// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean #[tracing::instrument(skip_all)] -async fn fake_outer_boolean_serialize( +async fn fake_outer_boolean_serialize( method: Method, host: Host, cookies: CookieJar, @@ -283,7 +297,8 @@ async fn fake_outer_boolean_serialize( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -331,10 +346,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -364,7 +379,7 @@ fn fake_outer_composite_serialize_validation( } /// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite #[tracing::instrument(skip_all)] -async fn fake_outer_composite_serialize( +async fn fake_outer_composite_serialize( method: Method, host: Host, cookies: CookieJar, @@ -373,7 +388,8 @@ async fn fake_outer_composite_serialize( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -421,10 +437,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -454,7 +470,7 @@ fn fake_outer_number_serialize_validation( } /// FakeOuterNumberSerialize - POST /v2/fake/outer/number #[tracing::instrument(skip_all)] -async fn fake_outer_number_serialize( +async fn fake_outer_number_serialize( method: Method, host: Host, cookies: CookieJar, @@ -463,7 +479,8 @@ async fn fake_outer_number_serialize( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -511,10 +528,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -544,7 +561,7 @@ fn fake_outer_string_serialize_validation( } /// FakeOuterStringSerialize - POST /v2/fake/outer/string #[tracing::instrument(skip_all)] -async fn fake_outer_string_serialize( +async fn fake_outer_string_serialize( method: Method, host: Host, cookies: CookieJar, @@ -553,7 +570,8 @@ async fn fake_outer_string_serialize( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -601,10 +619,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -621,7 +639,7 @@ fn fake_response_with_numerical_description_validation() -> std::result::Result< } /// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description #[tracing::instrument(skip_all)] -async fn fake_response_with_numerical_description( +async fn fake_response_with_numerical_description( method: Method, host: Host, cookies: CookieJar, @@ -629,7 +647,8 @@ async fn fake_response_with_numerical_description( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -658,10 +677,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -681,7 +700,7 @@ fn hyphen_param_validation( } /// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param} #[tracing::instrument(skip_all)] -async fn hyphen_param( +async fn hyphen_param( method: Method, host: Host, cookies: CookieJar, @@ -690,7 +709,8 @@ async fn hyphen_param( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || hyphen_param_validation(path_params)) @@ -718,10 +738,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -752,7 +772,7 @@ fn test_body_with_query_params_validation( } /// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params #[tracing::instrument(skip_all)] -async fn test_body_with_query_params( +async fn test_body_with_query_params( method: Method, host: Host, cookies: CookieJar, @@ -762,7 +782,8 @@ async fn test_body_with_query_params( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || { @@ -792,10 +813,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -823,7 +844,7 @@ fn test_client_model_validation( } /// TestClientModel - PATCH /v2/fake #[tracing::instrument(skip_all)] -async fn test_client_model( +async fn test_client_model( method: Method, host: Host, cookies: CookieJar, @@ -832,7 +853,8 @@ async fn test_client_model( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || test_client_model_validation(body)) @@ -879,10 +901,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -910,7 +932,7 @@ fn test_endpoint_parameters_validation( } /// TestEndpointParameters - POST /v2/fake #[tracing::instrument(skip_all)] -async fn test_endpoint_parameters( +async fn test_endpoint_parameters( method: Method, host: Host, cookies: CookieJar, @@ -919,7 +941,8 @@ async fn test_endpoint_parameters( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || test_endpoint_parameters_validation(body)) @@ -951,10 +974,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -995,7 +1018,7 @@ fn test_enum_parameters_validation( } /// TestEnumParameters - GET /v2/fake #[tracing::instrument(skip_all)] -async fn test_enum_parameters( +async fn test_enum_parameters( method: Method, host: Host, cookies: CookieJar, @@ -1006,7 +1029,8 @@ async fn test_enum_parameters( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Header parameters let header_params = { @@ -1090,10 +1114,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1120,7 +1144,7 @@ fn test_inline_additional_properties_validation( } /// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties #[tracing::instrument(skip_all)] -async fn test_inline_additional_properties( +async fn test_inline_additional_properties( method: Method, host: Host, cookies: CookieJar, @@ -1129,7 +1153,8 @@ async fn test_inline_additional_properties( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -1158,10 +1183,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1189,7 +1214,7 @@ fn test_json_form_data_validation( } /// TestJsonFormData - GET /v2/fake/jsonFormData #[tracing::instrument(skip_all)] -async fn test_json_form_data( +async fn test_json_form_data( method: Method, host: Host, cookies: CookieJar, @@ -1198,7 +1223,8 @@ async fn test_json_form_data( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake::Fake, + A: apis::fake::Fake + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || test_json_form_data_validation(body)) @@ -1226,10 +1252,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1257,7 +1283,7 @@ fn test_classname_validation( } /// TestClassname - PATCH /v2/fake_classname_test #[tracing::instrument(skip_all)] -async fn test_classname( +async fn test_classname( method: Method, host: Host, cookies: CookieJar, @@ -1266,7 +1292,8 @@ async fn test_classname( ) -> Result where I: AsRef + Send + Sync, - A: apis::fake_classname_tags123::FakeClassnameTags123, + A: apis::fake_classname_tags123::FakeClassnameTags123 + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || test_classname_validation(body)) @@ -1315,10 +1342,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1344,7 +1371,7 @@ fn add_pet_validation(body: models::Pet) -> std::result::Result<(models::Pet,), } /// AddPet - POST /v2/pet #[tracing::instrument(skip_all)] -async fn add_pet( +async fn add_pet( method: Method, host: Host, cookies: CookieJar, @@ -1353,7 +1380,8 @@ async fn add_pet( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || add_pet_validation(body)) @@ -1378,10 +1406,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1406,7 +1434,7 @@ fn delete_pet_validation( } /// DeletePet - DELETE /v2/pet/{petId} #[tracing::instrument(skip_all)] -async fn delete_pet( +async fn delete_pet( method: Method, host: Host, cookies: CookieJar, @@ -1416,7 +1444,8 @@ async fn delete_pet( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Header parameters let header_params = { @@ -1470,10 +1499,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1493,7 +1522,7 @@ fn find_pets_by_status_validation( } /// FindPetsByStatus - GET /v2/pet/findByStatus #[tracing::instrument(skip_all)] -async fn find_pets_by_status( +async fn find_pets_by_status( method: Method, host: Host, cookies: CookieJar, @@ -1502,7 +1531,8 @@ async fn find_pets_by_status( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -1547,10 +1577,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1570,7 +1600,7 @@ fn find_pets_by_tags_validation( } /// FindPetsByTags - GET /v2/pet/findByTags #[tracing::instrument(skip_all)] -async fn find_pets_by_tags( +async fn find_pets_by_tags( method: Method, host: Host, cookies: CookieJar, @@ -1579,7 +1609,8 @@ async fn find_pets_by_tags( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -1624,10 +1655,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1647,7 +1678,7 @@ fn get_pet_by_id_validation( } /// GetPetById - GET /v2/pet/{petId} #[tracing::instrument(skip_all)] -async fn get_pet_by_id( +async fn get_pet_by_id( method: Method, host: Host, cookies: CookieJar, @@ -1657,7 +1688,8 @@ async fn get_pet_by_id( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet + apis::ApiKeyAuthHeader, + A: apis::pet::Pet + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -1718,10 +1750,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1749,7 +1781,7 @@ fn update_pet_validation( } /// UpdatePet - PUT /v2/pet #[tracing::instrument(skip_all)] -async fn update_pet( +async fn update_pet( method: Method, host: Host, cookies: CookieJar, @@ -1758,7 +1790,8 @@ async fn update_pet( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || update_pet_validation(body)) @@ -1794,10 +1827,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1835,7 +1868,7 @@ fn update_pet_with_form_validation( } /// UpdatePetWithForm - POST /v2/pet/{petId} #[tracing::instrument(skip_all)] -async fn update_pet_with_form( +async fn update_pet_with_form( method: Method, host: Host, cookies: CookieJar, @@ -1845,7 +1878,8 @@ async fn update_pet_with_form( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -1874,10 +1908,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1897,7 +1931,7 @@ fn upload_file_validation( } /// UploadFile - POST /v2/pet/{petId}/uploadImage #[tracing::instrument(skip_all)] -async fn upload_file( +async fn upload_file( method: Method, host: Host, cookies: CookieJar, @@ -1907,7 +1941,8 @@ async fn upload_file( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || upload_file_validation(path_params)) @@ -1954,10 +1989,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1977,7 +2012,7 @@ fn delete_order_validation( } /// DeleteOrder - DELETE /v2/store/order/{order_id} #[tracing::instrument(skip_all)] -async fn delete_order( +async fn delete_order( method: Method, host: Host, cookies: CookieJar, @@ -1986,7 +2021,8 @@ async fn delete_order( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store, + A: apis::store::Store + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || delete_order_validation(path_params)) @@ -2018,10 +2054,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2037,7 +2073,7 @@ fn get_inventory_validation() -> std::result::Result<(), ValidationErrors> { } /// GetInventory - GET /v2/store/inventory #[tracing::instrument(skip_all)] -async fn get_inventory( +async fn get_inventory( method: Method, host: Host, cookies: CookieJar, @@ -2046,7 +2082,8 @@ async fn get_inventory( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store + apis::ApiKeyAuthHeader, + A: apis::store::Store + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -2106,10 +2143,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2129,7 +2166,7 @@ fn get_order_by_id_validation( } /// GetOrderById - GET /v2/store/order/{order_id} #[tracing::instrument(skip_all)] -async fn get_order_by_id( +async fn get_order_by_id( method: Method, host: Host, cookies: CookieJar, @@ -2138,7 +2175,8 @@ async fn get_order_by_id( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store, + A: apis::store::Store + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || get_order_by_id_validation(path_params)) @@ -2186,10 +2224,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2217,7 +2255,7 @@ fn place_order_validation( } /// PlaceOrder - POST /v2/store/order #[tracing::instrument(skip_all)] -async fn place_order( +async fn place_order( method: Method, host: Host, cookies: CookieJar, @@ -2226,7 +2264,8 @@ async fn place_order( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store, + A: apis::store::Store + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || place_order_validation(body)) @@ -2270,10 +2309,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2301,7 +2340,7 @@ fn create_user_validation( } /// CreateUser - POST /v2/user #[tracing::instrument(skip_all)] -async fn create_user( +async fn create_user( method: Method, host: Host, cookies: CookieJar, @@ -2310,7 +2349,8 @@ async fn create_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || create_user_validation(body)) @@ -2338,10 +2378,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2369,7 +2409,7 @@ fn create_users_with_array_input_validation( } /// CreateUsersWithArrayInput - POST /v2/user/createWithArray #[tracing::instrument(skip_all)] -async fn create_users_with_array_input( +async fn create_users_with_array_input( method: Method, host: Host, cookies: CookieJar, @@ -2378,7 +2418,8 @@ async fn create_users_with_array_input( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -2407,10 +2448,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2438,7 +2479,7 @@ fn create_users_with_list_input_validation( } /// CreateUsersWithListInput - POST /v2/user/createWithList #[tracing::instrument(skip_all)] -async fn create_users_with_list_input( +async fn create_users_with_list_input( method: Method, host: Host, cookies: CookieJar, @@ -2447,7 +2488,8 @@ async fn create_users_with_list_input( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -2476,10 +2518,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2499,7 +2541,7 @@ fn delete_user_validation( } /// DeleteUser - DELETE /v2/user/{username} #[tracing::instrument(skip_all)] -async fn delete_user( +async fn delete_user( method: Method, host: Host, cookies: CookieJar, @@ -2508,7 +2550,8 @@ async fn delete_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || delete_user_validation(path_params)) @@ -2540,10 +2583,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2563,7 +2606,7 @@ fn get_user_by_name_validation( } /// GetUserByName - GET /v2/user/{username} #[tracing::instrument(skip_all)] -async fn get_user_by_name( +async fn get_user_by_name( method: Method, host: Host, cookies: CookieJar, @@ -2572,7 +2615,8 @@ async fn get_user_by_name( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || get_user_by_name_validation(path_params)) @@ -2620,10 +2664,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2643,7 +2687,7 @@ fn login_user_validation( } /// LoginUser - GET /v2/user/login #[tracing::instrument(skip_all)] -async fn login_user( +async fn login_user( method: Method, host: Host, cookies: CookieJar, @@ -2652,7 +2696,8 @@ async fn login_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || login_user_validation(query_params)) @@ -2733,10 +2778,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2752,7 +2797,7 @@ fn logout_user_validation() -> std::result::Result<(), ValidationErrors> { } /// LogoutUser - GET /v2/user/logout #[tracing::instrument(skip_all)] -async fn logout_user( +async fn logout_user( method: Method, host: Host, cookies: CookieJar, @@ -2760,7 +2805,8 @@ async fn logout_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || logout_user_validation()) @@ -2785,10 +2831,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -2818,7 +2864,7 @@ fn update_user_validation( } /// UpdateUser - PUT /v2/user/{username} #[tracing::instrument(skip_all)] -async fn update_user( +async fn update_user( method: Method, host: Host, cookies: CookieJar, @@ -2828,7 +2874,8 @@ async fn update_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || update_user_validation(path_params, body)) @@ -2860,10 +2907,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; diff --git a/samples/server/petstore/rust-axum/output/petstore/README.md b/samples/server/petstore/rust-axum/output/petstore/README.md index e2f49a93712b..166405b99e04 100644 --- a/samples/server/petstore/rust-axum/output/petstore/README.md +++ b/samples/server/petstore/rust-axum/output/petstore/README.md @@ -43,10 +43,12 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl petstore::Api for ServerImpl { +impl petstore::apis::default::Api for ServerImpl { // API implementation goes here } +impl petstore::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs index f6b0a17ddd57..c9aef0e1a9b2 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs @@ -14,3 +14,16 @@ pub trait ApiKeyAuthHeader { key: &str, ) -> Option; } + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs index 3cf7805ba541..1eaa525d087c 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs @@ -90,7 +90,7 @@ pub enum UploadFileResponse { /// Pet #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Pet { +pub trait Pet: super::ErrorHandler { type Claims; /// Add a new pet to the store. @@ -102,7 +102,7 @@ pub trait Pet { host: Host, cookies: CookieJar, body: models::Pet, - ) -> Result; + ) -> Result; /// Deletes a pet. /// @@ -114,7 +114,7 @@ pub trait Pet { cookies: CookieJar, header_params: models::DeletePetHeaderParams, path_params: models::DeletePetPathParams, - ) -> Result; + ) -> Result; /// Finds Pets by status. /// @@ -125,7 +125,7 @@ pub trait Pet { host: Host, cookies: CookieJar, query_params: models::FindPetsByStatusQueryParams, - ) -> Result; + ) -> Result; /// Finds Pets by tags. /// @@ -136,7 +136,7 @@ pub trait Pet { host: Host, cookies: CookieJar, query_params: models::FindPetsByTagsQueryParams, - ) -> Result; + ) -> Result; /// Find pet by ID. /// @@ -148,7 +148,7 @@ pub trait Pet { cookies: CookieJar, claims: Self::Claims, path_params: models::GetPetByIdPathParams, - ) -> Result; + ) -> Result; /// Update an existing pet. /// @@ -159,7 +159,7 @@ pub trait Pet { host: Host, cookies: CookieJar, body: models::Pet, - ) -> Result; + ) -> Result; /// Updates a pet in the store with form data. /// @@ -171,7 +171,7 @@ pub trait Pet { cookies: CookieJar, path_params: models::UpdatePetWithFormPathParams, body: Option, - ) -> Result; + ) -> Result; /// uploads an image. /// @@ -183,5 +183,5 @@ pub trait Pet { cookies: CookieJar, path_params: models::UploadFilePathParams, body: Multipart, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs index eb592d88aa83..2bda82b2d040 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs @@ -50,7 +50,7 @@ pub enum PlaceOrderResponse { /// Store #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Store { +pub trait Store: super::ErrorHandler { type Claims; /// Delete purchase order by ID. @@ -62,7 +62,7 @@ pub trait Store { host: Host, cookies: CookieJar, path_params: models::DeleteOrderPathParams, - ) -> Result; + ) -> Result; /// Returns pet inventories by status. /// @@ -73,7 +73,7 @@ pub trait Store { host: Host, cookies: CookieJar, claims: Self::Claims, - ) -> Result; + ) -> Result; /// Find purchase order by ID. /// @@ -84,7 +84,7 @@ pub trait Store { host: Host, cookies: CookieJar, path_params: models::GetOrderByIdPathParams, - ) -> Result; + ) -> Result; /// Place an order for a pet. /// @@ -95,5 +95,5 @@ pub trait Store { host: Host, cookies: CookieJar, body: models::Order, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs index cfec1d4f84e8..0348b13b1e61 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs @@ -89,7 +89,7 @@ pub enum UpdateUserResponse { /// User #[async_trait] #[allow(clippy::ptr_arg)] -pub trait User { +pub trait User: super::ErrorHandler { type Claims; /// Create user. @@ -102,7 +102,7 @@ pub trait User { cookies: CookieJar, claims: Self::Claims, body: models::User, - ) -> Result; + ) -> Result; /// Creates list of users with given input array. /// @@ -114,7 +114,7 @@ pub trait User { cookies: CookieJar, claims: Self::Claims, body: Vec, - ) -> Result; + ) -> Result; /// Creates list of users with given input array. /// @@ -126,7 +126,7 @@ pub trait User { cookies: CookieJar, claims: Self::Claims, body: Vec, - ) -> Result; + ) -> Result; /// Delete user. /// @@ -138,7 +138,7 @@ pub trait User { cookies: CookieJar, claims: Self::Claims, path_params: models::DeleteUserPathParams, - ) -> Result; + ) -> Result; /// Get user by user name. /// @@ -149,7 +149,7 @@ pub trait User { host: Host, cookies: CookieJar, path_params: models::GetUserByNamePathParams, - ) -> Result; + ) -> Result; /// Logs user into the system. /// @@ -160,7 +160,7 @@ pub trait User { host: Host, cookies: CookieJar, query_params: models::LoginUserQueryParams, - ) -> Result; + ) -> Result; /// Logs out current logged in user session. /// @@ -171,7 +171,7 @@ pub trait User { host: Host, cookies: CookieJar, claims: Self::Claims, - ) -> Result; + ) -> Result; /// Updated user. /// @@ -184,5 +184,5 @@ pub trait User { claims: Self::Claims, path_params: models::UpdateUserPathParams, body: models::User, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index edb1b82fc442..d108d680d4c9 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -13,54 +13,63 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::pet::Pet - + apis::store::Store - + apis::user::User + A: apis::pet::Pet + + apis::store::Store + + apis::user::User + apis::ApiKeyAuthHeader + + Send + + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, C: Send + Sync + 'static, { // build our application with a route Router::new() .route( "/v2/pet", - post(add_pet::).put(update_pet::), + post(add_pet::).put(update_pet::), ) .route( "/v2/pet/:pet_id", - delete(delete_pet::) - .get(get_pet_by_id::) - .post(update_pet_with_form::), + delete(delete_pet::) + .get(get_pet_by_id::) + .post(update_pet_with_form::), ) - .route("/v2/pet/:pet_id/uploadImage", post(upload_file::)) - .route("/v2/pet/findByStatus", get(find_pets_by_status::)) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) - .route("/v2/store/inventory", get(get_inventory::)) - .route("/v2/store/order", post(place_order::)) + .route( + "/v2/pet/:pet_id/uploadImage", + post(upload_file::), + ) + .route( + "/v2/pet/findByStatus", + get(find_pets_by_status::), + ) + .route("/v2/pet/findByTags", get(find_pets_by_tags::)) + .route("/v2/store/inventory", get(get_inventory::)) + .route("/v2/store/order", post(place_order::)) .route( "/v2/store/order/:order_id", - delete(delete_order::).get(get_order_by_id::), + delete(delete_order::).get(get_order_by_id::), ) - .route("/v2/user", post(create_user::)) + .route("/v2/user", post(create_user::)) .route( "/v2/user/:username", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), + delete(delete_user::) + .get(get_user_by_name::) + .put(update_user::), ) .route( "/v2/user/createWithArray", - post(create_users_with_array_input::), + post(create_users_with_array_input::), ) .route( "/v2/user/createWithList", - post(create_users_with_list_input::), + post(create_users_with_list_input::), ) - .route("/v2/user/login", get(login_user::)) - .route("/v2/user/logout", get(logout_user::)) + .route("/v2/user/login", get(login_user::)) + .route("/v2/user/logout", get(logout_user::)) .with_state(api_impl) } @@ -80,7 +89,7 @@ fn add_pet_validation(body: models::Pet) -> std::result::Result<(models::Pet,), } /// AddPet - POST /v2/pet #[tracing::instrument(skip_all)] -async fn add_pet( +async fn add_pet( method: Method, host: Host, cookies: CookieJar, @@ -89,7 +98,8 @@ async fn add_pet( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || add_pet_validation(body)) @@ -130,10 +140,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -158,7 +168,7 @@ fn delete_pet_validation( } /// DeletePet - DELETE /v2/pet/{petId} #[tracing::instrument(skip_all)] -async fn delete_pet( +async fn delete_pet( method: Method, host: Host, cookies: CookieJar, @@ -168,7 +178,8 @@ async fn delete_pet( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Header parameters let header_params = { @@ -222,10 +233,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -245,7 +256,7 @@ fn find_pets_by_status_validation( } /// FindPetsByStatus - GET /v2/pet/findByStatus #[tracing::instrument(skip_all)] -async fn find_pets_by_status( +async fn find_pets_by_status( method: Method, host: Host, cookies: CookieJar, @@ -254,7 +265,8 @@ async fn find_pets_by_status( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -299,10 +311,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -322,7 +334,7 @@ fn find_pets_by_tags_validation( } /// FindPetsByTags - GET /v2/pet/findByTags #[tracing::instrument(skip_all)] -async fn find_pets_by_tags( +async fn find_pets_by_tags( method: Method, host: Host, cookies: CookieJar, @@ -331,7 +343,8 @@ async fn find_pets_by_tags( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -376,10 +389,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -399,7 +412,7 @@ fn get_pet_by_id_validation( } /// GetPetById - GET /v2/pet/{petId} #[tracing::instrument(skip_all)] -async fn get_pet_by_id( +async fn get_pet_by_id( method: Method, host: Host, cookies: CookieJar, @@ -409,7 +422,8 @@ async fn get_pet_by_id( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet + apis::ApiKeyAuthHeader, + A: apis::pet::Pet + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -470,10 +484,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -501,7 +515,7 @@ fn update_pet_validation( } /// UpdatePet - PUT /v2/pet #[tracing::instrument(skip_all)] -async fn update_pet( +async fn update_pet( method: Method, host: Host, cookies: CookieJar, @@ -510,7 +524,8 @@ async fn update_pet( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || update_pet_validation(body)) @@ -562,10 +577,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -603,7 +618,7 @@ fn update_pet_with_form_validation( } /// UpdatePetWithForm - POST /v2/pet/{petId} #[tracing::instrument(skip_all)] -async fn update_pet_with_form( +async fn update_pet_with_form( method: Method, host: Host, cookies: CookieJar, @@ -613,7 +628,8 @@ async fn update_pet_with_form( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = @@ -642,10 +658,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -665,7 +681,7 @@ fn upload_file_validation( } /// UploadFile - POST /v2/pet/{petId}/uploadImage #[tracing::instrument(skip_all)] -async fn upload_file( +async fn upload_file( method: Method, host: Host, cookies: CookieJar, @@ -675,7 +691,8 @@ async fn upload_file( ) -> Result where I: AsRef + Send + Sync, - A: apis::pet::Pet, + A: apis::pet::Pet + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || upload_file_validation(path_params)) @@ -722,10 +739,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -745,7 +762,7 @@ fn delete_order_validation( } /// DeleteOrder - DELETE /v2/store/order/{orderId} #[tracing::instrument(skip_all)] -async fn delete_order( +async fn delete_order( method: Method, host: Host, cookies: CookieJar, @@ -754,7 +771,8 @@ async fn delete_order( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store, + A: apis::store::Store + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || delete_order_validation(path_params)) @@ -786,10 +804,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -805,7 +823,7 @@ fn get_inventory_validation() -> std::result::Result<(), ValidationErrors> { } /// GetInventory - GET /v2/store/inventory #[tracing::instrument(skip_all)] -async fn get_inventory( +async fn get_inventory( method: Method, host: Host, cookies: CookieJar, @@ -814,7 +832,8 @@ async fn get_inventory( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store + apis::ApiKeyAuthHeader, + A: apis::store::Store + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -874,10 +893,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -897,7 +916,7 @@ fn get_order_by_id_validation( } /// GetOrderById - GET /v2/store/order/{orderId} #[tracing::instrument(skip_all)] -async fn get_order_by_id( +async fn get_order_by_id( method: Method, host: Host, cookies: CookieJar, @@ -906,7 +925,8 @@ async fn get_order_by_id( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store, + A: apis::store::Store + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || get_order_by_id_validation(path_params)) @@ -954,10 +974,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -985,7 +1005,7 @@ fn place_order_validation( } /// PlaceOrder - POST /v2/store/order #[tracing::instrument(skip_all)] -async fn place_order( +async fn place_order( method: Method, host: Host, cookies: CookieJar, @@ -994,7 +1014,8 @@ async fn place_order( ) -> Result where I: AsRef + Send + Sync, - A: apis::store::Store, + A: apis::store::Store + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || place_order_validation(body)) @@ -1038,10 +1059,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1069,7 +1090,7 @@ fn create_user_validation( } /// CreateUser - POST /v2/user #[tracing::instrument(skip_all)] -async fn create_user( +async fn create_user( method: Method, host: Host, cookies: CookieJar, @@ -1079,7 +1100,8 @@ async fn create_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User + apis::ApiKeyAuthHeader, + A: apis::user::User + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -1120,10 +1142,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1151,7 +1173,7 @@ fn create_users_with_array_input_validation( } /// CreateUsersWithArrayInput - POST /v2/user/createWithArray #[tracing::instrument(skip_all)] -async fn create_users_with_array_input( +async fn create_users_with_array_input( method: Method, host: Host, cookies: CookieJar, @@ -1161,7 +1183,8 @@ async fn create_users_with_array_input( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User + apis::ApiKeyAuthHeader, + A: apis::user::User + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -1203,10 +1226,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1234,7 +1257,7 @@ fn create_users_with_list_input_validation( } /// CreateUsersWithListInput - POST /v2/user/createWithList #[tracing::instrument(skip_all)] -async fn create_users_with_list_input( +async fn create_users_with_list_input( method: Method, host: Host, cookies: CookieJar, @@ -1244,7 +1267,8 @@ async fn create_users_with_list_input( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User + apis::ApiKeyAuthHeader, + A: apis::user::User + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -1286,10 +1310,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1309,7 +1333,7 @@ fn delete_user_validation( } /// DeleteUser - DELETE /v2/user/{username} #[tracing::instrument(skip_all)] -async fn delete_user( +async fn delete_user( method: Method, host: Host, cookies: CookieJar, @@ -1319,7 +1343,8 @@ async fn delete_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User + apis::ApiKeyAuthHeader, + A: apis::user::User + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -1364,10 +1389,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1387,7 +1412,7 @@ fn get_user_by_name_validation( } /// GetUserByName - GET /v2/user/{username} #[tracing::instrument(skip_all)] -async fn get_user_by_name( +async fn get_user_by_name( method: Method, host: Host, cookies: CookieJar, @@ -1396,7 +1421,8 @@ async fn get_user_by_name( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || get_user_by_name_validation(path_params)) @@ -1444,10 +1470,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1467,7 +1493,7 @@ fn login_user_validation( } /// LoginUser - GET /v2/user/login #[tracing::instrument(skip_all)] -async fn login_user( +async fn login_user( method: Method, host: Host, cookies: CookieJar, @@ -1476,7 +1502,8 @@ async fn login_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User, + A: apis::user::User + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || login_user_validation(query_params)) @@ -1573,10 +1600,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1592,7 +1619,7 @@ fn logout_user_validation() -> std::result::Result<(), ValidationErrors> { } /// LogoutUser - GET /v2/user/logout #[tracing::instrument(skip_all)] -async fn logout_user( +async fn logout_user( method: Method, host: Host, cookies: CookieJar, @@ -1601,7 +1628,8 @@ async fn logout_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User + apis::ApiKeyAuthHeader, + A: apis::user::User + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -1642,10 +1670,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -1675,7 +1703,7 @@ fn update_user_validation( } /// UpdateUser - PUT /v2/user/{username} #[tracing::instrument(skip_all)] -async fn update_user( +async fn update_user( method: Method, host: Host, cookies: CookieJar, @@ -1686,7 +1714,8 @@ async fn update_user( ) -> Result where I: AsRef + Send + Sync, - A: apis::user::User + apis::ApiKeyAuthHeader, + A: apis::user::User + apis::ApiKeyAuthHeader + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Authentication let claims_in_header = api_impl @@ -1731,10 +1760,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 5b152c6a4fb2..36c44b9b3f06 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 @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl ping-bearer-auth::Api for ServerImpl { +impl ping_bearer_auth::apis::default::Api for ServerImpl { // API implementation goes here } +impl ping_bearer_auth::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = ping-bearer-auth::server::new(Arc::new(ServerImpl)); + let app = ping_bearer_auth::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs index cfb12ef7fd4d..0fe333a1da80 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs @@ -18,12 +18,12 @@ pub enum PingGetResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// PingGet - GET /ping async fn ping_get( &self, method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs index 1be8d340b8e0..dce6c9a8e2de 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs @@ -1 +1,14 @@ pub mod default; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index 2d1e7ca10116..d67e85fb1812 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -13,14 +13,15 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + 'static, + A: apis::default::Default + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() - .route("/ping", get(ping_get::)) + .route("/ping", get(ping_get::)) .with_state(api_impl) } @@ -30,7 +31,7 @@ fn ping_get_validation() -> std::result::Result<(), ValidationErrors> { } /// PingGet - GET /ping #[tracing::instrument(skip_all)] -async fn ping_get( +async fn ping_get( method: Method, host: Host, cookies: CookieJar, @@ -38,7 +39,8 @@ async fn ping_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || ping_get_validation()) @@ -63,10 +65,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 56220aaf10fd..a1c0125fecbd 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 @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl rust-axum-header-uui::Api for ServerImpl { +impl rust_axum_header_uui::apis::default::Api for ServerImpl { // API implementation goes here } +impl rust_axum_header_uui::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = rust-axum-header-uui::server::new(Arc::new(ServerImpl)); + let app = rust_axum_header_uui::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs index 2c6c51c0d2c3..962b5408b423 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs @@ -18,7 +18,7 @@ pub enum UsersPostResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// UsersPost - POST /users async fn users_post( &self, @@ -26,5 +26,5 @@ pub trait Default { host: Host, cookies: CookieJar, header_params: models::UsersPostHeaderParams, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs index 1be8d340b8e0..dce6c9a8e2de 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs @@ -1 +1,14 @@ pub mod default; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs index e0deda59d9c9..8462ff721d40 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs @@ -13,14 +13,15 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + 'static, + A: apis::default::Default + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() - .route("/users", post(users_post::)) + .route("/users", post(users_post::)) .with_state(api_impl) } @@ -34,7 +35,7 @@ fn users_post_validation( } /// UsersPost - POST /users #[tracing::instrument(skip_all)] -async fn users_post( +async fn users_post( method: Method, host: Host, cookies: CookieJar, @@ -43,7 +44,8 @@ async fn users_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { // Header parameters let header_params = { @@ -123,10 +125,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 6c4665e80ba0..23afeff11c18 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 @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl rust-axum-oneof::Api for ServerImpl { +impl rust_axum_oneof::apis::default::Api for ServerImpl { // API implementation goes here } +impl rust_axum_oneof::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = rust-axum-oneof::server::new(Arc::new(ServerImpl)); + let app = rust_axum_oneof::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs index 1873aebd9db8..c79516aafe22 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs @@ -18,7 +18,7 @@ pub enum FooResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// Foo - POST / async fn foo( &self, @@ -26,5 +26,5 @@ pub trait Default { host: Host, cookies: CookieJar, body: models::Message, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs index 1be8d340b8e0..dce6c9a8e2de 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs @@ -1 +1,14 @@ pub mod default; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs index 8db98b873f15..63d5890483b0 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs @@ -13,14 +13,15 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + 'static, + A: apis::default::Default + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() - .route("/", post(foo::)) + .route("/", post(foo::)) .with_state(api_impl) } @@ -42,7 +43,7 @@ fn foo_validation( } /// Foo - POST / #[tracing::instrument(skip_all)] -async fn foo( +async fn foo( method: Method, host: Host, cookies: CookieJar, @@ -51,7 +52,8 @@ async fn foo( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || foo_validation(body)) @@ -95,10 +97,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 17add5a653eb..262ca27fc921 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 @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl rust-server-test::Api for ServerImpl { +impl rust_server_test::apis::default::Api for ServerImpl { // API implementation goes here } +impl rust_server_test::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = rust-server-test::server::new(Arc::new(ServerImpl)); + let app = rust_server_test::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs index ba643a1d2f82..6b9d7202a9b2 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs @@ -82,14 +82,14 @@ pub enum SoloObjectPostResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// AllOfGet - GET /allOf async fn all_of_get( &self, method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// A dummy endpoint to make the spec valid.. /// @@ -99,7 +99,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// DummyPut - PUT /dummy async fn dummy_put( @@ -108,7 +108,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: models::FooDummyPutRequest, - ) -> Result; + ) -> Result; /// Get a file. /// @@ -118,7 +118,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// GetStructuredYaml - GET /get-structured-yaml async fn get_structured_yaml( @@ -126,7 +126,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Test HTML handling. /// @@ -137,7 +137,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: String, - ) -> Result; + ) -> Result; /// PostYaml - POST /post-yaml async fn post_yaml( @@ -146,7 +146,7 @@ pub trait Default { host: Host, cookies: CookieJar, body: String, - ) -> Result; + ) -> Result; /// Get an arbitrary JSON blob.. /// @@ -156,7 +156,7 @@ pub trait Default { method: Method, host: Host, cookies: CookieJar, - ) -> Result; + ) -> Result; /// Send an arbitrary JSON blob. /// @@ -167,5 +167,5 @@ pub trait Default { host: Host, cookies: CookieJar, body: crate::types::Object, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs index 1be8d340b8e0..dce6c9a8e2de 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs @@ -1 +1,14 @@ pub mod default; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index c8205254790a..2993fc5265a9 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -13,21 +13,25 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + 'static, + A: apis::default::Default + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() - .route("/allOf", get(all_of_get::)) - .route("/dummy", get(dummy_get::).put(dummy_put::)) - .route("/file_response", get(file_response_get::)) - .route("/get-structured-yaml", get(get_structured_yaml::)) - .route("/html", post(html_post::)) - .route("/post-yaml", post(post_yaml::)) - .route("/raw_json", get(raw_json_get::)) - .route("/solo-object", post(solo_object_post::)) + .route("/allOf", get(all_of_get::)) + .route( + "/dummy", + get(dummy_get::).put(dummy_put::), + ) + .route("/file_response", get(file_response_get::)) + .route("/get-structured-yaml", get(get_structured_yaml::)) + .route("/html", post(html_post::)) + .route("/post-yaml", post(post_yaml::)) + .route("/raw_json", get(raw_json_get::)) + .route("/solo-object", post(solo_object_post::)) .with_state(api_impl) } @@ -37,7 +41,7 @@ fn all_of_get_validation() -> std::result::Result<(), ValidationErrors> { } /// AllOfGet - GET /allOf #[tracing::instrument(skip_all)] -async fn all_of_get( +async fn all_of_get( method: Method, host: Host, cookies: CookieJar, @@ -45,7 +49,8 @@ async fn all_of_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || all_of_get_validation()) @@ -89,10 +94,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -108,7 +113,7 @@ fn dummy_get_validation() -> std::result::Result<(), ValidationErrors> { } /// DummyGet - GET /dummy #[tracing::instrument(skip_all)] -async fn dummy_get( +async fn dummy_get( method: Method, host: Host, cookies: CookieJar, @@ -116,7 +121,8 @@ async fn dummy_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || dummy_get_validation()) @@ -141,10 +147,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -172,7 +178,7 @@ fn dummy_put_validation( } /// DummyPut - PUT /dummy #[tracing::instrument(skip_all)] -async fn dummy_put( +async fn dummy_put( method: Method, host: Host, cookies: CookieJar, @@ -181,7 +187,8 @@ async fn dummy_put( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || dummy_put_validation(body)) @@ -209,10 +216,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -228,7 +235,7 @@ fn file_response_get_validation() -> std::result::Result<(), ValidationErrors> { } /// FileResponseGet - GET /file_response #[tracing::instrument(skip_all)] -async fn file_response_get( +async fn file_response_get( method: Method, host: Host, cookies: CookieJar, @@ -236,7 +243,8 @@ async fn file_response_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || file_response_get_validation()) @@ -283,10 +291,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -302,7 +310,7 @@ fn get_structured_yaml_validation() -> std::result::Result<(), ValidationErrors> } /// GetStructuredYaml - GET /get-structured-yaml #[tracing::instrument(skip_all)] -async fn get_structured_yaml( +async fn get_structured_yaml( method: Method, host: Host, cookies: CookieJar, @@ -310,7 +318,8 @@ async fn get_structured_yaml( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || get_structured_yaml_validation()) @@ -350,10 +359,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -375,7 +384,7 @@ fn html_post_validation(body: String) -> std::result::Result<(String,), Validati } /// HtmlPost - POST /html #[tracing::instrument(skip_all)] -async fn html_post( +async fn html_post( method: Method, host: Host, cookies: CookieJar, @@ -384,7 +393,8 @@ async fn html_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || html_post_validation(body)) @@ -424,10 +434,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -449,7 +459,7 @@ fn post_yaml_validation(body: String) -> std::result::Result<(String,), Validati } /// PostYaml - POST /post-yaml #[tracing::instrument(skip_all)] -async fn post_yaml( +async fn post_yaml( method: Method, host: Host, cookies: CookieJar, @@ -458,7 +468,8 @@ async fn post_yaml( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || post_yaml_validation(body)) @@ -486,10 +497,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -505,7 +516,7 @@ fn raw_json_get_validation() -> std::result::Result<(), ValidationErrors> { } /// RawJsonGet - GET /raw_json #[tracing::instrument(skip_all)] -async fn raw_json_get( +async fn raw_json_get( method: Method, host: Host, cookies: CookieJar, @@ -513,7 +524,8 @@ async fn raw_json_get( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || raw_json_get_validation()) @@ -557,10 +569,10 @@ where response.body(Body::from(body_content)) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; @@ -587,7 +599,7 @@ fn solo_object_post_validation( } /// SoloObjectPost - POST /solo-object #[tracing::instrument(skip_all)] -async fn solo_object_post( +async fn solo_object_post( method: Method, host: Host, cookies: CookieJar, @@ -596,7 +608,8 @@ async fn solo_object_post( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { #[allow(clippy::redundant_closure)] let validation = tokio::task::spawn_blocking(move || solo_object_post_validation(body)) @@ -624,10 +637,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; 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 fbff4455f06b..2dafd50e9caa 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 @@ -43,16 +43,18 @@ struct ServerImpl { #[allow(unused_variables)] #[async_trait] -impl rust-axum-validation-test::Api for ServerImpl { +impl rust_axum_validation_test::apis::default::Api for ServerImpl { // API implementation goes here } +impl rust_axum_validation_test::apis::ErrorHandler for ServerImpl {} + pub async fn start_server(addr: &str) { // initialize tracing tracing_subscriber::fmt::init(); // Init Axum router - let app = rust-axum-validation-test::server::new(Arc::new(ServerImpl)); + let app = rust_axum_validation_test::server::new(Arc::new(ServerImpl)); // Add layers to the router let app = app.layer(...); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs index d9ef3904a0ca..2157d0565695 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs @@ -18,7 +18,7 @@ pub enum MailPutResponse { /// Default #[async_trait] #[allow(clippy::ptr_arg)] -pub trait Default { +pub trait Default: super::ErrorHandler { /// MailPut - PUT /mail async fn mail_put( &self, @@ -26,5 +26,5 @@ pub trait Default { host: Host, cookies: CookieJar, body: models::Email, - ) -> Result; + ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs index 1be8d340b8e0..dce6c9a8e2de 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs @@ -1 +1,14 @@ pub mod default; + +// Error handler for unhandled errors. +#[async_trait::async_trait] +pub trait ErrorHandler { + #[tracing::instrument(skip(self))] + async fn handle_error(&self, error: E) -> Result { + tracing::error!("Unhandled error: {:?}", error); + axum::response::Response::builder() + .status(500) + .body(axum::body::Body::empty()) + .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) + } +} diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs index 822b74a61f60..138859c41044 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs @@ -13,20 +13,21 @@ use crate::{header, types::*}; use crate::{apis, models}; /// Setup API Server. -pub fn new(api_impl: I) -> Router +pub fn new(api_impl: I) -> Router where I: AsRef + Clone + Send + Sync + 'static, - A: apis::default::Default + 'static, + A: apis::default::Default + Send + Sync + 'static, + E: std::fmt::Debug + Send + Sync + 'static, { // build our application with a route Router::new() - .route("/mail", put(mail_put::)) + .route("/mail", put(mail_put::)) .with_state(api_impl) } /// MailPut - PUT /mail #[tracing::instrument(skip_all)] -async fn mail_put( +async fn mail_put( method: Method, host: Host, cookies: CookieJar, @@ -35,7 +36,8 @@ async fn mail_put( ) -> Result where I: AsRef + Send + Sync, - A: apis::default::Default, + A: apis::default::Default + Send + Sync, + E: std::fmt::Debug + Send + Sync + 'static, { let result = api_impl .as_ref() @@ -51,10 +53,10 @@ where response.body(Body::empty()) } }, - Err(_) => { + Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - response.status(500).body(Body::empty()) + return api_impl.as_ref().handle_error(why).await; } }; From 00e7ad2ac291c449af2f3c456e21fa6ebefd5735 Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Mon, 3 Feb 2025 20:12:39 +0100 Subject: [PATCH 2/9] Pass in method, host and cookies to error handler --- .../resources/rust-axum/apis-mod.mustache | 11 +- .../rust-axum/server-operation.mustache | 9 +- .../apikey-auths/.openapi-generator/VERSION | 2 +- .../rust-axum/output/apikey-auths/README.md | 2 +- .../output/apikey-auths/src/apis/mod.rs | 11 +- .../output/apikey-auths/src/server/mod.rs | 24 +- .../multipart-v3/.openapi-generator/VERSION | 2 +- .../rust-axum/output/multipart-v3/README.md | 2 +- .../output/multipart-v3/src/apis/mod.rs | 11 +- .../output/multipart-v3/src/server/mod.rs | 24 +- .../openapi-v3/.openapi-generator/VERSION | 2 +- .../rust-axum/output/openapi-v3/README.md | 2 +- .../output/openapi-v3/src/apis/mod.rs | 11 +- .../output/openapi-v3/src/server/mod.rs | 247 ++++++++--- .../output/ops-v3/.openapi-generator/VERSION | 2 +- .../rust-axum/output/ops-v3/README.md | 2 +- .../rust-axum/output/ops-v3/src/apis/mod.rs | 11 +- .../rust-axum/output/ops-v3/src/server/mod.rs | 407 ++++++++++++++---- .../.openapi-generator/VERSION | 2 +- .../README.md | 2 +- .../src/apis/mod.rs | 11 +- .../src/server/mod.rs | 329 +++++++++++--- .../petstore/.openapi-generator/VERSION | 2 +- .../rust-axum/output/petstore/README.md | 2 +- .../rust-axum/output/petstore/src/apis/mod.rs | 11 +- .../output/petstore/src/server/mod.rs | 200 +++++++-- .../.openapi-generator/VERSION | 2 +- .../output/ping-bearer-auth/README.md | 2 +- .../output/ping-bearer-auth/src/apis/mod.rs | 11 +- .../output/ping-bearer-auth/src/server/mod.rs | 11 +- .../.openapi-generator/VERSION | 2 +- .../output/rust-axum-header-uuid/README.md | 2 +- .../rust-axum-header-uuid/src/apis/mod.rs | 11 +- .../rust-axum-header-uuid/src/server/mod.rs | 8 +- .../.openapi-generator/VERSION | 2 +- .../output/rust-axum-oneof/README.md | 2 +- .../output/rust-axum-oneof/src/apis/mod.rs | 11 +- .../output/rust-axum-oneof/src/server/mod.rs | 11 +- .../rust-axum-test/.openapi-generator/VERSION | 2 +- .../rust-axum/output/rust-axum-test/README.md | 2 +- .../output/rust-axum-test/src/apis/mod.rs | 11 +- .../output/rust-axum-test/src/server/mod.rs | 81 +++- .../.openapi-generator/VERSION | 2 +- .../rust-axum-validation-test/README.md | 2 +- .../rust-axum-validation-test/src/apis/mod.rs | 11 +- .../src/server/mod.rs | 8 +- 46 files changed, 1201 insertions(+), 334 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache index c3de36e2eff3..d8832cbe17aa 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache @@ -32,8 +32,15 @@ pub trait ApiKeyAuthHeader { // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache index dd12f325b5cc..26095202be48 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache @@ -187,9 +187,9 @@ where {{/disableValidator}} let result = api_impl.as_ref().{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( - method, - host, - cookies, + method.clone(), + host.clone(), + cookies.clone(), {{#vendorExtensions}} {{#x-has-auth-methods}} claims, @@ -346,7 +346,8 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl.as_ref().handle_error(method, host, cookies, why).await; }, }; diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/apikey-auths/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/apikey-auths/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 a298e7c00f23..9cf63a6d09de 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/README.md +++ b/samples/server/petstore/rust-axum/output/apikey-auths/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.0 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs index 9fee0e68012b..e99a23ce8ce8 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs @@ -28,8 +28,15 @@ pub trait CookieAuthentication { // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index 36a2d69f77c3..cf844e731313 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -76,7 +76,7 @@ where let result = api_impl .as_ref() - .get_payment_method_by_id(method, host, cookies, path_params) + .get_payment_method_by_id(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -133,7 +133,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -174,7 +178,7 @@ where let result = api_impl .as_ref() - .get_payment_methods(method, host, cookies) + .get_payment_methods(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -208,7 +212,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -280,7 +288,7 @@ where let result = api_impl .as_ref() - .post_make_payment(method, host, cookies, claims, body) + .post_make_payment(method.clone(), host.clone(), cookies.clone(), claims, body) .await; let mut response = Response::builder(); @@ -337,7 +345,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 ed697a9b04d3..0451497fd561 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/README.md +++ b/samples/server/petstore/rust-axum/output/multipart-v3/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.7 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs index dce6c9a8e2de..29119d0a0fa6 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs @@ -3,8 +3,15 @@ pub mod default; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index ccca87143d83..f9244ef77231 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -69,7 +69,7 @@ where let result = api_impl .as_ref() - .multipart_related_request_post(method, host, cookies, body) + .multipart_related_request_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -84,7 +84,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -126,7 +130,7 @@ where let result = api_impl .as_ref() - .multipart_request_post(method, host, cookies, body) + .multipart_request_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -141,7 +145,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -184,7 +192,7 @@ where let result = api_impl .as_ref() - .multiple_identical_mime_types_post(method, host, cookies, body) + .multiple_identical_mime_types_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -199,7 +207,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/openapi-v3/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 e4db33ef004c..813a1753c314 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-axum/output/openapi-v3/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.7 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs index 97d4ac0121da..b10bc2c9bfac 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs @@ -5,8 +5,15 @@ pub mod repo; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index e0f210a1734c..a846d6e23d7c 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -146,7 +146,7 @@ where let result = api_impl .as_ref() - .any_of_get(method, host, cookies, query_params) + .any_of_get(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -226,7 +226,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -269,7 +273,7 @@ where let result = api_impl .as_ref() - .callback_with_header_post(method, host, cookies, query_params) + .callback_with_header_post(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -284,7 +288,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -327,7 +335,7 @@ where let result = api_impl .as_ref() - .complex_query_param_get(method, host, cookies, query_params) + .complex_query_param_get(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -342,7 +350,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -385,7 +397,7 @@ where let result = api_impl .as_ref() - .enum_in_path_path_param_get(method, host, cookies, path_params) + .enum_in_path_path_param_get(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -400,7 +412,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -451,7 +467,7 @@ where let result = api_impl .as_ref() - .form_test(method, host, cookies, body) + .form_test(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -466,7 +482,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -509,7 +529,7 @@ where let result = api_impl .as_ref() - .get_with_boolean_parameter(method, host, cookies, query_params) + .get_with_boolean_parameter(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -524,7 +544,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -567,7 +591,7 @@ where let result = api_impl .as_ref() - .json_complex_query_param_get(method, host, cookies, query_params) + .json_complex_query_param_get(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -582,7 +606,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -658,7 +686,7 @@ where let result = api_impl .as_ref() - .mandatory_request_header_get(method, host, cookies, header_params) + .mandatory_request_header_get(method.clone(), host.clone(), cookies.clone(), header_params) .await; let mut response = Response::builder(); @@ -673,7 +701,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -711,7 +743,7 @@ where let result = api_impl .as_ref() - .merge_patch_json_get(method, host, cookies) + .merge_patch_json_get(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -745,7 +777,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -781,7 +817,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().multiget_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .multiget_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -931,7 +970,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -969,7 +1012,7 @@ where let result = api_impl .as_ref() - .multiple_auth_scheme_get(method, host, cookies) + .multiple_auth_scheme_get(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -985,7 +1028,8 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl.as_ref().handle_error(method, host, cookies, why).await; }, }; @@ -1042,9 +1086,9 @@ where let result = api_impl .as_ref() .multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get( - method, - host, - cookies, + method.clone(), + host.clone(), + cookies.clone(), path_params, ) .await; @@ -1062,7 +1106,8 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl.as_ref().handle_error(method, host, cookies, why).await; }, }; @@ -1098,7 +1143,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().one_of_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .one_of_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1131,7 +1179,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1169,7 +1221,7 @@ where let result = api_impl .as_ref() - .override_server_get(method, host, cookies) + .override_server_get(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -1184,7 +1236,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1227,7 +1283,7 @@ where let result = api_impl .as_ref() - .paramget_get(method, host, cookies, query_params) + .paramget_get(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -1261,7 +1317,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1299,7 +1359,7 @@ where let result = api_impl .as_ref() - .readonly_auth_scheme_get(method, host, cookies) + .readonly_auth_scheme_get(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -1315,7 +1375,8 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl.as_ref().handle_error(method, host, cookies, why).await; }, }; @@ -1358,7 +1419,7 @@ where let result = api_impl .as_ref() - .register_callback_post(method, host, cookies, query_params) + .register_callback_post(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -1373,7 +1434,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1420,7 +1485,7 @@ where let result = api_impl .as_ref() - .required_octet_stream_put(method, host, cookies, body) + .required_octet_stream_put(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -1435,7 +1500,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1473,7 +1542,7 @@ where let result = api_impl .as_ref() - .responses_with_headers_get(method, host, cookies) + .responses_with_headers_get(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -1596,7 +1665,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1632,7 +1705,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().rfc7807_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .rfc7807_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1704,7 +1780,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1790,7 +1870,7 @@ where let result = api_impl .as_ref() - .two_first_letter_headers(method, host, cookies, header_params) + .two_first_letter_headers(method.clone(), host.clone(), cookies.clone(), header_params) .await; let mut response = Response::builder(); @@ -1805,7 +1885,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1858,7 +1942,7 @@ where let result = api_impl .as_ref() - .untyped_property_get(method, host, cookies, body) + .untyped_property_get(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -1874,7 +1958,8 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl.as_ref().handle_error(method, host, cookies, why).await; }, }; @@ -1910,7 +1995,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().uuid_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .uuid_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1943,7 +2031,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1988,7 +2080,7 @@ where let result = api_impl .as_ref() - .xml_extra_post(method, host, cookies, body) + .xml_extra_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2007,7 +2099,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2052,7 +2148,7 @@ where let result = api_impl .as_ref() - .xml_other_post(method, host, cookies, body) + .xml_other_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2083,7 +2179,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2128,7 +2228,7 @@ where let result = api_impl .as_ref() - .xml_other_put(method, host, cookies, body) + .xml_other_put(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2147,7 +2247,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2192,7 +2296,7 @@ where let result = api_impl .as_ref() - .xml_post(method, host, cookies, body) + .xml_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2211,7 +2315,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2254,7 +2362,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().xml_put(method, host, cookies, body).await; + let result = api_impl + .as_ref() + .xml_put(method.clone(), host.clone(), cookies.clone(), body) + .await; let mut response = Response::builder(); @@ -2272,7 +2383,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2315,7 +2430,7 @@ where let result = api_impl .as_ref() - .get_repo_info(method, host, cookies, path_params) + .get_repo_info(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -2349,7 +2464,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2400,7 +2519,7 @@ where let result = api_impl .as_ref() - .create_repo(method, host, cookies, body) + .create_repo(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2415,7 +2534,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/ops-v3/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 c94615271690..e22d2151321c 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/README.md +++ b/samples/server/petstore/rust-axum/output/ops-v3/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.0.1 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs index dce6c9a8e2de..29119d0a0fa6 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs @@ -3,8 +3,15 @@ pub mod default; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs index a1b40fd40049..2d6199d6bf93 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs @@ -90,7 +90,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op10_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op10_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -104,7 +107,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -143,7 +150,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op11_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op11_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -157,7 +167,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -196,7 +210,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op12_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op12_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -210,7 +227,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -249,7 +270,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op13_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op13_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -263,7 +287,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -302,7 +330,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op14_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op14_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -316,7 +347,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -355,7 +390,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op15_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op15_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -369,7 +407,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -408,7 +450,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op16_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op16_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -422,7 +467,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -461,7 +510,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op17_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op17_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -475,7 +527,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -514,7 +570,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op18_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op18_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -528,7 +587,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -567,7 +630,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op19_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op19_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -581,7 +647,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -620,7 +690,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op1_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op1_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -634,7 +707,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -673,7 +750,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op20_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op20_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -687,7 +767,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -726,7 +810,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op21_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op21_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -740,7 +827,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -779,7 +870,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op22_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op22_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -793,7 +887,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -832,7 +930,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op23_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op23_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -846,7 +947,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -885,7 +990,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op24_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op24_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -899,7 +1007,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -938,7 +1050,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op25_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op25_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -952,7 +1067,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -991,7 +1110,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op26_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op26_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1005,7 +1127,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1044,7 +1170,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op27_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op27_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1058,7 +1187,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1097,7 +1230,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op28_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op28_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1111,7 +1247,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1150,7 +1290,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op29_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op29_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1164,7 +1307,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1203,7 +1350,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op2_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op2_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1217,7 +1367,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1256,7 +1410,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op30_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op30_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1270,7 +1427,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1309,7 +1470,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op31_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op31_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1323,7 +1487,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1362,7 +1530,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op32_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op32_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1376,7 +1547,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1415,7 +1590,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op33_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op33_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1429,7 +1607,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1468,7 +1650,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op34_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op34_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1482,7 +1667,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1521,7 +1710,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op35_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op35_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1535,7 +1727,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1574,7 +1770,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op36_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op36_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1588,7 +1787,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1627,7 +1830,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op37_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op37_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1641,7 +1847,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1680,7 +1890,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op3_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op3_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1694,7 +1907,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1733,7 +1950,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op4_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op4_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1747,7 +1967,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1786,7 +2010,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op5_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op5_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1800,7 +2027,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1839,7 +2070,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op6_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op6_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1853,7 +2087,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1892,7 +2130,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op7_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op7_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1906,7 +2147,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1945,7 +2190,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op8_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op8_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -1959,7 +2207,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1998,7 +2250,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().op9_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .op9_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -2012,7 +2267,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 ddad4bd4f6ae..32026c65f858 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 @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.0 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs index 478004700c14..16385340d000 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs @@ -21,8 +21,15 @@ pub trait ApiKeyAuthHeader { // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 69655b140d2d..72b1aba8255b 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -168,7 +168,7 @@ where let result = api_impl .as_ref() - .test_special_tags(method, host, cookies, body) + .test_special_tags(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -202,7 +202,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -243,7 +247,7 @@ where let result = api_impl .as_ref() - .call123example(method, host, cookies) + .call123example(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -258,7 +262,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -315,7 +323,7 @@ where let result = api_impl .as_ref() - .fake_outer_boolean_serialize(method, host, cookies, body) + .fake_outer_boolean_serialize(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -349,7 +357,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -406,7 +418,7 @@ where let result = api_impl .as_ref() - .fake_outer_composite_serialize(method, host, cookies, body) + .fake_outer_composite_serialize(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -440,7 +452,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -497,7 +513,7 @@ where let result = api_impl .as_ref() - .fake_outer_number_serialize(method, host, cookies, body) + .fake_outer_number_serialize(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -531,7 +547,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -588,7 +608,7 @@ where let result = api_impl .as_ref() - .fake_outer_string_serialize(method, host, cookies, body) + .fake_outer_string_serialize(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -622,7 +642,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -665,7 +689,7 @@ where let result = api_impl .as_ref() - .fake_response_with_numerical_description(method, host, cookies) + .fake_response_with_numerical_description(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -680,7 +704,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -726,7 +754,7 @@ where let result = api_impl .as_ref() - .hyphen_param(method, host, cookies, path_params) + .hyphen_param(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -741,7 +769,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -801,7 +833,13 @@ where let result = api_impl .as_ref() - .test_body_with_query_params(method, host, cookies, query_params, body) + .test_body_with_query_params( + method.clone(), + host.clone(), + cookies.clone(), + query_params, + body, + ) .await; let mut response = Response::builder(); @@ -816,7 +854,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -870,7 +912,7 @@ where let result = api_impl .as_ref() - .test_client_model(method, host, cookies, body) + .test_client_model(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -904,7 +946,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -958,7 +1004,7 @@ where let result = api_impl .as_ref() - .test_endpoint_parameters(method, host, cookies, body) + .test_endpoint_parameters(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -977,7 +1023,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1098,7 +1148,14 @@ where let result = api_impl .as_ref() - .test_enum_parameters(method, host, cookies, header_params, query_params, body) + .test_enum_parameters( + method.clone(), + host.clone(), + cookies.clone(), + header_params, + query_params, + body, + ) .await; let mut response = Response::builder(); @@ -1117,7 +1174,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1171,7 +1232,7 @@ where let result = api_impl .as_ref() - .test_inline_additional_properties(method, host, cookies, body) + .test_inline_additional_properties(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -1186,7 +1247,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1240,7 +1305,7 @@ where let result = api_impl .as_ref() - .test_json_form_data(method, host, cookies, body) + .test_json_form_data(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -1255,7 +1320,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1309,7 +1378,7 @@ where let result = api_impl .as_ref() - .test_classname(method, host, cookies, body) + .test_classname(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -1345,7 +1414,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1395,7 +1468,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().add_pet(method, host, cookies, body).await; + let result = api_impl + .as_ref() + .add_pet(method.clone(), host.clone(), cookies.clone(), body) + .await; let mut response = Response::builder(); @@ -1409,7 +1485,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1487,7 +1567,13 @@ where let result = api_impl .as_ref() - .delete_pet(method, host, cookies, header_params, path_params) + .delete_pet( + method.clone(), + host.clone(), + cookies.clone(), + header_params, + path_params, + ) .await; let mut response = Response::builder(); @@ -1502,7 +1588,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1549,7 +1639,7 @@ where let result = api_impl .as_ref() - .find_pets_by_status(method, host, cookies, query_params) + .find_pets_by_status(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -1580,7 +1670,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1627,7 +1721,7 @@ where let result = api_impl .as_ref() - .find_pets_by_tags(method, host, cookies, query_params) + .find_pets_by_tags(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -1658,7 +1752,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1718,7 +1816,13 @@ where let result = api_impl .as_ref() - .get_pet_by_id(method, host, cookies, claims, path_params) + .get_pet_by_id( + method.clone(), + host.clone(), + cookies.clone(), + claims, + path_params, + ) .await; let mut response = Response::builder(); @@ -1753,7 +1857,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1807,7 +1915,7 @@ where let result = api_impl .as_ref() - .update_pet(method, host, cookies, body) + .update_pet(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -1830,7 +1938,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1896,7 +2008,13 @@ where let result = api_impl .as_ref() - .update_pet_with_form(method, host, cookies, path_params, body) + .update_pet_with_form( + method.clone(), + host.clone(), + cookies.clone(), + path_params, + body, + ) .await; let mut response = Response::builder(); @@ -1911,7 +2029,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1958,7 +2080,13 @@ where let result = api_impl .as_ref() - .upload_file(method, host, cookies, path_params, body) + .upload_file( + method.clone(), + host.clone(), + cookies.clone(), + path_params, + body, + ) .await; let mut response = Response::builder(); @@ -1992,7 +2120,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2038,7 +2170,7 @@ where let result = api_impl .as_ref() - .delete_order(method, host, cookies, path_params) + .delete_order(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -2057,7 +2189,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2112,7 +2248,7 @@ where let result = api_impl .as_ref() - .get_inventory(method, host, cookies, claims) + .get_inventory(method.clone(), host.clone(), cookies.clone(), claims) .await; let mut response = Response::builder(); @@ -2146,7 +2282,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2192,7 +2332,7 @@ where let result = api_impl .as_ref() - .get_order_by_id(method, host, cookies, path_params) + .get_order_by_id(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -2227,7 +2367,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2281,7 +2425,7 @@ where let result = api_impl .as_ref() - .place_order(method, host, cookies, body) + .place_order(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2312,7 +2456,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2366,7 +2514,7 @@ where let result = api_impl .as_ref() - .create_user(method, host, cookies, body) + .create_user(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2381,7 +2529,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2436,7 +2588,7 @@ where let result = api_impl .as_ref() - .create_users_with_array_input(method, host, cookies, body) + .create_users_with_array_input(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2451,7 +2603,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2506,7 +2662,7 @@ where let result = api_impl .as_ref() - .create_users_with_list_input(method, host, cookies, body) + .create_users_with_list_input(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -2521,7 +2677,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2567,7 +2727,7 @@ where let result = api_impl .as_ref() - .delete_user(method, host, cookies, path_params) + .delete_user(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -2586,7 +2746,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2632,7 +2796,7 @@ where let result = api_impl .as_ref() - .get_user_by_name(method, host, cookies, path_params) + .get_user_by_name(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -2667,7 +2831,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2713,7 +2881,7 @@ where let result = api_impl .as_ref() - .login_user(method, host, cookies, query_params) + .login_user(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -2781,7 +2949,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2820,7 +2992,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().logout_user(method, host, cookies).await; + let result = api_impl + .as_ref() + .logout_user(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -2834,7 +3009,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -2891,7 +3070,13 @@ where let result = api_impl .as_ref() - .update_user(method, host, cookies, path_params, body) + .update_user( + method.clone(), + host.clone(), + cookies.clone(), + path_params, + body, + ) .await; let mut response = Response::builder(); @@ -2910,7 +3095,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/petstore/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/petstore/README.md b/samples/server/petstore/rust-axum/output/petstore/README.md index 166405b99e04..9949db12c305 100644 --- a/samples/server/petstore/rust-axum/output/petstore/README.md +++ b/samples/server/petstore/rust-axum/output/petstore/README.md @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0.0 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs index c9aef0e1a9b2..2ab70901ac07 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs @@ -18,8 +18,15 @@ pub trait ApiKeyAuthHeader { // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index d108d680d4c9..27978b837516 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -113,7 +113,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().add_pet(method, host, cookies, body).await; + let result = api_impl + .as_ref() + .add_pet(method.clone(), host.clone(), cookies.clone(), body) + .await; let mut response = Response::builder(); @@ -143,7 +146,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -221,7 +228,13 @@ where let result = api_impl .as_ref() - .delete_pet(method, host, cookies, header_params, path_params) + .delete_pet( + method.clone(), + host.clone(), + cookies.clone(), + header_params, + path_params, + ) .await; let mut response = Response::builder(); @@ -236,7 +249,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -283,7 +300,7 @@ where let result = api_impl .as_ref() - .find_pets_by_status(method, host, cookies, query_params) + .find_pets_by_status(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -314,7 +331,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -361,7 +382,7 @@ where let result = api_impl .as_ref() - .find_pets_by_tags(method, host, cookies, query_params) + .find_pets_by_tags(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -392,7 +413,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -452,7 +477,13 @@ where let result = api_impl .as_ref() - .get_pet_by_id(method, host, cookies, claims, path_params) + .get_pet_by_id( + method.clone(), + host.clone(), + cookies.clone(), + claims, + path_params, + ) .await; let mut response = Response::builder(); @@ -487,7 +518,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -541,7 +576,7 @@ where let result = api_impl .as_ref() - .update_pet(method, host, cookies, body) + .update_pet(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -580,7 +615,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -646,7 +685,13 @@ where let result = api_impl .as_ref() - .update_pet_with_form(method, host, cookies, path_params, body) + .update_pet_with_form( + method.clone(), + host.clone(), + cookies.clone(), + path_params, + body, + ) .await; let mut response = Response::builder(); @@ -661,7 +706,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -708,7 +757,13 @@ where let result = api_impl .as_ref() - .upload_file(method, host, cookies, path_params, body) + .upload_file( + method.clone(), + host.clone(), + cookies.clone(), + path_params, + body, + ) .await; let mut response = Response::builder(); @@ -742,7 +797,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -788,7 +847,7 @@ where let result = api_impl .as_ref() - .delete_order(method, host, cookies, path_params) + .delete_order(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -807,7 +866,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -862,7 +925,7 @@ where let result = api_impl .as_ref() - .get_inventory(method, host, cookies, claims) + .get_inventory(method.clone(), host.clone(), cookies.clone(), claims) .await; let mut response = Response::builder(); @@ -896,7 +959,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -942,7 +1009,7 @@ where let result = api_impl .as_ref() - .get_order_by_id(method, host, cookies, path_params) + .get_order_by_id(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -977,7 +1044,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1031,7 +1102,7 @@ where let result = api_impl .as_ref() - .place_order(method, host, cookies, body) + .place_order(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -1062,7 +1133,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1130,7 +1205,7 @@ where let result = api_impl .as_ref() - .create_user(method, host, cookies, claims, body) + .create_user(method.clone(), host.clone(), cookies.clone(), claims, body) .await; let mut response = Response::builder(); @@ -1145,7 +1220,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1214,7 +1293,7 @@ where let result = api_impl .as_ref() - .create_users_with_array_input(method, host, cookies, claims, body) + .create_users_with_array_input(method.clone(), host.clone(), cookies.clone(), claims, body) .await; let mut response = Response::builder(); @@ -1229,7 +1308,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1298,7 +1381,7 @@ where let result = api_impl .as_ref() - .create_users_with_list_input(method, host, cookies, claims, body) + .create_users_with_list_input(method.clone(), host.clone(), cookies.clone(), claims, body) .await; let mut response = Response::builder(); @@ -1313,7 +1396,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1373,7 +1460,13 @@ where let result = api_impl .as_ref() - .delete_user(method, host, cookies, claims, path_params) + .delete_user( + method.clone(), + host.clone(), + cookies.clone(), + claims, + path_params, + ) .await; let mut response = Response::builder(); @@ -1392,7 +1485,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1438,7 +1535,7 @@ where let result = api_impl .as_ref() - .get_user_by_name(method, host, cookies, path_params) + .get_user_by_name(method.clone(), host.clone(), cookies.clone(), path_params) .await; let mut response = Response::builder(); @@ -1473,7 +1570,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1519,7 +1620,7 @@ where let result = api_impl .as_ref() - .login_user(method, host, cookies, query_params) + .login_user(method.clone(), host.clone(), cookies.clone(), query_params) .await; let mut response = Response::builder(); @@ -1603,7 +1704,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1658,7 +1763,7 @@ where let result = api_impl .as_ref() - .logout_user(method, host, cookies, claims) + .logout_user(method.clone(), host.clone(), cookies.clone(), claims) .await; let mut response = Response::builder(); @@ -1673,7 +1778,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -1744,7 +1853,14 @@ where let result = api_impl .as_ref() - .update_user(method, host, cookies, claims, path_params, body) + .update_user( + method.clone(), + host.clone(), + cookies.clone(), + claims, + path_params, + body, + ) .await; let mut response = Response::builder(); @@ -1763,7 +1879,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 36c44b9b3f06..580ec9920643 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 @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 1.0 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs index dce6c9a8e2de..29119d0a0fa6 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs @@ -3,8 +3,15 @@ pub mod default; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index d67e85fb1812..a0f652ce60f0 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -54,7 +54,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().ping_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .ping_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -68,7 +71,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 a1c0125fecbd..880ec2323a16 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 @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.1.9 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs index dce6c9a8e2de..29119d0a0fa6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs @@ -3,8 +3,15 @@ pub mod default; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs index 8462ff721d40..636183e81a7e 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs @@ -94,7 +94,7 @@ where let result = api_impl .as_ref() - .users_post(method, host, cookies, header_params) + .users_post(method.clone(), host.clone(), cookies.clone(), header_params) .await; let mut response = Response::builder(); @@ -128,7 +128,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/rust-axum-oneof/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 23afeff11c18..6c8dfa29b8f5 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 @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.0.1 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs index dce6c9a8e2de..29119d0a0fa6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs @@ -3,8 +3,15 @@ pub mod default; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs index 63d5890483b0..5475a2530929 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs @@ -67,7 +67,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().foo(method, host, cookies, body).await; + let result = api_impl + .as_ref() + .foo(method.clone(), host.clone(), cookies.clone(), body) + .await; let mut response = Response::builder(); @@ -100,7 +103,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 262ca27fc921..d6a8781dfe38 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 @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 2.3.4 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs index dce6c9a8e2de..29119d0a0fa6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs @@ -3,8 +3,15 @@ pub mod default; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index 2993fc5265a9..5d1a492eea8d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -64,7 +64,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().all_of_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .all_of_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -97,7 +100,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -136,7 +143,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().dummy_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .dummy_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -150,7 +160,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -204,7 +218,7 @@ where let result = api_impl .as_ref() - .dummy_put(method, host, cookies, body) + .dummy_put(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -219,7 +233,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -260,7 +278,7 @@ where let result = api_impl .as_ref() - .file_response_get(method, host, cookies) + .file_response_get(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -294,7 +312,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -335,7 +357,7 @@ where let result = api_impl .as_ref() - .get_structured_yaml(method, host, cookies) + .get_structured_yaml(method.clone(), host.clone(), cookies.clone()) .await; let mut response = Response::builder(); @@ -362,7 +384,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -410,7 +436,7 @@ where let result = api_impl .as_ref() - .html_post(method, host, cookies, body) + .html_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -437,7 +463,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -485,7 +515,7 @@ where let result = api_impl .as_ref() - .post_yaml(method, host, cookies, body) + .post_yaml(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -500,7 +530,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -539,7 +573,10 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl.as_ref().raw_json_get(method, host, cookies).await; + let result = api_impl + .as_ref() + .raw_json_get(method.clone(), host.clone(), cookies.clone()) + .await; let mut response = Response::builder(); @@ -572,7 +609,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; @@ -625,7 +666,7 @@ where let result = api_impl .as_ref() - .solo_object_post(method, host, cookies, body) + .solo_object_post(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -640,7 +681,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION index 884119126398..de37f5c4cf59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/.openapi-generator/VERSION @@ -1 +1 @@ -7.11.0-SNAPSHOT +7.12.0-SNAPSHOT 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 2dafd50e9caa..1699a54f8b45 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 @@ -12,7 +12,7 @@ server, you can easily generate a server stub. To see how to make this your own, look here: [README]((https://openapi-generator.tech)) - API version: 0.0.1 -- Generator version: 7.11.0-SNAPSHOT +- Generator version: 7.12.0-SNAPSHOT diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs index dce6c9a8e2de..29119d0a0fa6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs @@ -3,8 +3,15 @@ pub mod default; // Error handler for unhandled errors. #[async_trait::async_trait] pub trait ErrorHandler { - #[tracing::instrument(skip(self))] - async fn handle_error(&self, error: E) -> Result { + #[allow(unused_variables)] + #[tracing::instrument(skip_all)] + async fn handle_error( + &self, + method: ::http::Method, + host: axum::extract::Host, + cookies: axum_extra::extract::CookieJar, + error: E, + ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() .status(500) diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs index 138859c41044..c88256856af6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs @@ -41,7 +41,7 @@ where { let result = api_impl .as_ref() - .mail_put(method, host, cookies, body) + .mail_put(method.clone(), host.clone(), cookies.clone(), body) .await; let mut response = Response::builder(); @@ -56,7 +56,11 @@ where Err(why) => { // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(why).await; + + return api_impl + .as_ref() + .handle_error(method, host, cookies, why) + .await; } }; From fb7dae12a7ddd11bd39d6a70beed1c149a5f8007 Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Fri, 7 Feb 2025 11:56:42 +0100 Subject: [PATCH 3/9] Update axum to 0.8 --- .../languages/RustAxumServerCodegen.java | 5 +-- .../main/resources/rust-axum/Cargo.mustache | 6 ++-- .../resources/rust-axum/apis-mod.mustache | 2 +- .../main/resources/rust-axum/apis.mustache | 2 +- .../rust-axum/server-imports.mustache | 2 +- .../rust-axum/output/apikey-auths/Cargo.toml | 6 ++-- .../output/apikey-auths/src/apis/mod.rs | 2 +- .../output/apikey-auths/src/apis/payments.rs | 2 +- .../output/apikey-auths/src/server/mod.rs | 4 +-- .../rust-axum/output/multipart-v3/Cargo.toml | 6 ++-- .../output/multipart-v3/src/apis/default.rs | 2 +- .../output/multipart-v3/src/apis/mod.rs | 2 +- .../output/multipart-v3/src/server/mod.rs | 2 +- .../rust-axum/output/openapi-v3/Cargo.toml | 6 ++-- .../output/openapi-v3/src/apis/default.rs | 2 +- .../output/openapi-v3/src/apis/info_repo.rs | 2 +- .../output/openapi-v3/src/apis/mod.rs | 2 +- .../output/openapi-v3/src/apis/repo.rs | 2 +- .../output/openapi-v3/src/server/mod.rs | 8 ++--- .../rust-axum/output/ops-v3/Cargo.toml | 6 ++-- .../output/ops-v3/src/apis/default.rs | 2 +- .../rust-axum/output/ops-v3/src/apis/mod.rs | 2 +- .../rust-axum/output/ops-v3/src/server/mod.rs | 2 +- .../Cargo.toml | 6 ++-- .../src/apis/another_fake.rs | 2 +- .../src/apis/fake.rs | 2 +- .../src/apis/fake_classname_tags123.rs | 2 +- .../src/apis/mod.rs | 2 +- .../src/apis/pet.rs | 2 +- .../src/apis/store.rs | 2 +- .../src/apis/user.rs | 2 +- .../src/server/mod.rs | 32 +++++++++---------- .../rust-axum/output/petstore/Cargo.toml | 6 ++-- .../rust-axum/output/petstore/src/apis/mod.rs | 2 +- .../rust-axum/output/petstore/src/apis/pet.rs | 2 +- .../output/petstore/src/apis/store.rs | 2 +- .../output/petstore/src/apis/user.rs | 2 +- .../output/petstore/src/server/mod.rs | 30 ++++++++--------- .../output/ping-bearer-auth/Cargo.toml | 6 ++-- .../ping-bearer-auth/src/apis/default.rs | 2 +- .../output/ping-bearer-auth/src/apis/mod.rs | 2 +- .../output/ping-bearer-auth/src/server/mod.rs | 2 +- .../output/rust-axum-header-uuid/Cargo.toml | 6 ++-- .../rust-axum-header-uuid/src/apis/default.rs | 2 +- .../rust-axum-header-uuid/src/apis/mod.rs | 2 +- .../rust-axum-header-uuid/src/server/mod.rs | 2 +- .../output/rust-axum-oneof/Cargo.toml | 6 ++-- .../rust-axum-oneof/src/apis/default.rs | 2 +- .../output/rust-axum-oneof/src/apis/mod.rs | 2 +- .../output/rust-axum-oneof/src/server/mod.rs | 2 +- .../output/rust-axum-test/Cargo.toml | 6 ++-- .../output/rust-axum-test/src/apis/default.rs | 2 +- .../output/rust-axum-test/src/apis/mod.rs | 2 +- .../output/rust-axum-test/src/server/mod.rs | 2 +- .../rust-axum-validation-test/Cargo.toml | 6 ++-- .../src/apis/default.rs | 2 +- .../rust-axum-validation-test/src/apis/mod.rs | 2 +- .../src/server/mod.rs | 2 +- 58 files changed, 115 insertions(+), 118 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java index 44fccb193c1d..75b4493dde15 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java @@ -426,10 +426,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation String axumPath = op.path; for (CodegenParameter param : op.pathParams) { // Replace {baseName} with {paramName} for format string - String paramSearch = "{" + param.baseName + "}"; - String paramReplace = ":" + param.paramName; - - axumPath = axumPath.replace(paramSearch, paramReplace); + axumPath = axumPath.replace(param.baseName, param.paramName); } pathMethodOpMap .computeIfAbsent(axumPath, (key) -> new ArrayList<>()) 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 2dcdd5c9d7dd..23af1423c536 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache @@ -40,8 +40,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -62,7 +62,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache index d8832cbe17aa..6f02ee6f4063 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache @@ -37,7 +37,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E ) -> Result { diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache index 15870dba8ceb..a6366ab94b8f 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Multipart, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache index 28e323564d51..ee9ae4cfd99e 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Multipart, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 1f44d1228ae4..174c342084a5 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs index e99a23ce8ce8..2d8b6defcb56 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs @@ -33,7 +33,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs index 5053c2341499..6aa54868e222 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index cf844e731313..b307f75f82a1 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; @@ -32,7 +32,7 @@ where get(get_payment_methods::), ) .route( - "/v71/paymentMethods/:id", + "/v71/paymentMethods/{id}", get(get_payment_method_by_id::), ) .route("/v71/payments", post(post_make_payment::)) 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 a9857fc6b6d6..d4102dd4dd0e 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs index 6bf76a5edf9f..82e7335f3536 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs index 29119d0a0fa6..485bb4999526 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index f9244ef77231..5516b2299a54 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 d53ab13dcb78..d93c70177bea 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs index 26e15203fa7e..169077ce242e 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs index 48ab82f2c4c6..2a71e7f4ee21 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs index b10bc2c9bfac..1228d9000998 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs @@ -10,7 +10,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs index fc2a65b16bea..e56966070666 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index a846d6e23d7c..3c1032088d97 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; @@ -35,7 +35,7 @@ where .route("/complex-query-param", get(complex_query_param_get::) ) - .route("/enum_in_path/:path_param", + .route("/enum_in_path/{path_param}", get(enum_in_path_path_param_get::) ) .route("/form-test", @@ -56,7 +56,7 @@ where .route("/multiget", get(multiget_get::) ) - .route("/multiple-path-params-with-very-long-path-to-test-formatting/:path_param_a/:path_param_b", + .route("/multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b}", get(multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get::) ) .route("/multiple_auth_scheme", @@ -83,7 +83,7 @@ where .route("/repos", post(create_repo::) ) - .route("/repos/:repo_id", + .route("/repos/{repo_id}", get(get_repo_info::).get(get_repo_info::) ) .route("/required_octet_stream", 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 cf62658dc1f0..ac619e766161 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs index 5bf812e0f574..5e380ee9b073 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs index 29119d0a0fa6..485bb4999526 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs index 2d6199d6bf93..253368121c79 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 0b609777dec0..352b395aeb8f 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 @@ -20,8 +20,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -42,7 +42,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs index 5291cd90bd14..ab2f3f577b43 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs index ef29bf5a02cc..5f7b7baff222 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs index 867fab8a5df4..55a67eb995b8 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs index 16385340d000..a0522e8ffdf5 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs @@ -26,7 +26,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs index 0048d85c1a82..47bce9d611fd 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs index bd296c015fe7..1f45b8d30a23 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs index e6c36ba26360..43b9bb239667 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 72b1aba8255b..31b892e9a640 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; @@ -46,7 +46,7 @@ where put(test_body_with_query_params::), ) .route( - "/v2/fake/hyphenParam/:hyphen_param", + "/v2/fake/hyphenParam/{hyphen_param}", get(hyphen_param::), ) .route( @@ -84,33 +84,27 @@ where post(add_pet::).put(update_pet::), ) .route( - "/v2/pet/:pet_id", + "/v2/pet/findByStatus", + get(find_pets_by_status::), + ) + .route("/v2/pet/findByTags", get(find_pets_by_tags::)) + .route( + "/v2/pet/{pet_id}", delete(delete_pet::) .get(get_pet_by_id::) .post(update_pet_with_form::), ) .route( - "/v2/pet/:pet_id/uploadImage", + "/v2/pet/{pet_id}/uploadImage", post(upload_file::), ) - .route( - "/v2/pet/findByStatus", - get(find_pets_by_status::), - ) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) .route("/v2/store/inventory", get(get_inventory::)) .route("/v2/store/order", post(place_order::)) .route( - "/v2/store/order/:order_id", + "/v2/store/order/{order_id}", delete(delete_order::).get(get_order_by_id::), ) .route("/v2/user", post(create_user::)) - .route( - "/v2/user/:username", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), - ) .route( "/v2/user/createWithArray", post(create_users_with_array_input::), @@ -121,6 +115,12 @@ where ) .route("/v2/user/login", get(login_user::)) .route("/v2/user/logout", get(logout_user::)) + .route( + "/v2/user/{username}", + delete(delete_user::) + .get(get_user_by_name::) + .put(update_user::), + ) .with_state(api_impl) } diff --git a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml index 49676ee40c94..e64a8d672b80 100644 --- a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml @@ -19,8 +19,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -41,7 +41,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs index 2ab70901ac07..3095734d0a70 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs @@ -23,7 +23,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs index 1eaa525d087c..e2ac2ae84fcf 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs index 2bda82b2d040..eccf5686b541 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs index 0348b13b1e61..d5c6af060eef 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index 27978b837516..10bf9745bd91 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; @@ -33,33 +33,27 @@ where post(add_pet::).put(update_pet::), ) .route( - "/v2/pet/:pet_id", + "/v2/pet/findByStatus", + get(find_pets_by_status::), + ) + .route("/v2/pet/findByTags", get(find_pets_by_tags::)) + .route( + "/v2/pet/{pet_id}", delete(delete_pet::) .get(get_pet_by_id::) .post(update_pet_with_form::), ) .route( - "/v2/pet/:pet_id/uploadImage", + "/v2/pet/{pet_id}/uploadImage", post(upload_file::), ) - .route( - "/v2/pet/findByStatus", - get(find_pets_by_status::), - ) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) .route("/v2/store/inventory", get(get_inventory::)) .route("/v2/store/order", post(place_order::)) .route( - "/v2/store/order/:order_id", + "/v2/store/order/{order_id}", delete(delete_order::).get(get_order_by_id::), ) .route("/v2/user", post(create_user::)) - .route( - "/v2/user/:username", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), - ) .route( "/v2/user/createWithArray", post(create_users_with_array_input::), @@ -70,6 +64,12 @@ where ) .route("/v2/user/login", get(login_user::)) .route("/v2/user/logout", get(logout_user::)) + .route( + "/v2/user/{username}", + delete(delete_user::) + .get(get_user_by_name::) + .put(update_user::), + ) .with_state(api_impl) } 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 ff8b87cc4ed7..f1b0be05dc88 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs index 0fe333a1da80..4effbc57e60b 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs index 29119d0a0fa6..485bb4999526 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index a0f652ce60f0..07356b0925fe 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 ecfbde9106a7..1ba45f9703c3 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs index 962b5408b423..48ff8f426dff 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs index 29119d0a0fa6..485bb4999526 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs index 636183e81a7e..1929c8a07efd 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 849859898918..8d3fca9eb9e7 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs index c79516aafe22..29a1e7540c4b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs index 29119d0a0fa6..485bb4999526 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs index 5475a2530929..4e1cd6a832ca 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 9803ea83268c..0887417d6402 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs index 6b9d7202a9b2..58e6cd90ddfd 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs index 29119d0a0fa6..485bb4999526 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index 5d1a492eea8d..31b020d8df6d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 7d8fd93b600d..421ea6343c25 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.7" -axum-extra = { version = "0.9", features = ["cookie", "multipart"] } +axum = "0.8" +axum-extra = { version = "0.10", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } @@ -40,7 +40,7 @@ tokio = { version = "1", default-features = false, features = [ ] } tracing = { version = "0.1", features = ["attributes"] } uuid = { version = "1", features = ["serde"] } -validator = { version = "0.19", features = ["derive"] } +validator = { version = "0.20", features = ["derive"] } [dev-dependencies] tracing-subscriber = "0.3" diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs index 2157d0565695..dcf2ad05d0a3 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs index 29119d0a0fa6..485bb4999526 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: ::http::Method, - host: axum::extract::Host, + host: axum_extra::extract::Host, cookies: axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs index c88256856af6..bb62d8c38341 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart}; +use axum_extra::extract::{CookieJar, Host, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; From 3d833fd5ff99a3bb415c01a50656ac5754e7fdcc Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Fri, 7 Feb 2025 12:21:23 +0100 Subject: [PATCH 4/9] Make API methods take references instead of ownership --- .../resources/rust-axum/apis-mod.mustache | 6 +- .../main/resources/rust-axum/apis.mustache | 24 +- .../rust-axum/server-operation.mustache | 22 +- .../output/apikey-auths/src/apis/mod.rs | 6 +- .../output/apikey-auths/src/apis/payments.rs | 24 +- .../output/apikey-auths/src/server/mod.rs | 12 +- .../output/multipart-v3/src/apis/default.rs | 24 +- .../output/multipart-v3/src/apis/mod.rs | 6 +- .../output/multipart-v3/src/server/mod.rs | 12 +- .../output/openapi-v3/src/apis/default.rs | 206 +++++++------- .../output/openapi-v3/src/apis/info_repo.rs | 8 +- .../output/openapi-v3/src/apis/mod.rs | 6 +- .../output/openapi-v3/src/apis/repo.rs | 8 +- .../output/openapi-v3/src/server/mod.rs | 132 +++++---- .../output/ops-v3/src/apis/default.rs | 222 +++++++-------- .../rust-axum/output/ops-v3/src/apis/mod.rs | 6 +- .../rust-axum/output/ops-v3/src/server/mod.rs | 259 +++++------------- .../src/apis/another_fake.rs | 8 +- .../src/apis/fake.rs | 106 +++---- .../src/apis/fake_classname_tags123.rs | 8 +- .../src/apis/mod.rs | 6 +- .../src/apis/pet.rs | 72 ++--- .../src/apis/store.rs | 32 +-- .../src/apis/user.rs | 64 ++--- .../src/server/mod.rs | 186 +++++-------- .../rust-axum/output/petstore/src/apis/mod.rs | 6 +- .../rust-axum/output/petstore/src/apis/pet.rs | 72 ++--- .../output/petstore/src/apis/store.rs | 32 +-- .../output/petstore/src/apis/user.rs | 76 ++--- .../output/petstore/src/server/mod.rs | 117 +++----- .../ping-bearer-auth/src/apis/default.rs | 6 +- .../output/ping-bearer-auth/src/apis/mod.rs | 6 +- .../output/ping-bearer-auth/src/server/mod.rs | 7 +- .../rust-axum-header-uuid/src/apis/default.rs | 8 +- .../rust-axum-header-uuid/src/apis/mod.rs | 6 +- .../rust-axum-header-uuid/src/server/mod.rs | 4 +- .../rust-axum-oneof/src/apis/default.rs | 8 +- .../output/rust-axum-oneof/src/apis/mod.rs | 6 +- .../output/rust-axum-oneof/src/server/mod.rs | 7 +- .../output/rust-axum-test/src/apis/default.rs | 62 ++--- .../output/rust-axum-test/src/apis/mod.rs | 6 +- .../output/rust-axum-test/src/server/mod.rs | 42 ++- .../src/apis/default.rs | 8 +- .../rust-axum-validation-test/src/apis/mod.rs | 6 +- .../src/server/mod.rs | 4 +- 45 files changed, 876 insertions(+), 1078 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache index 6f02ee6f4063..08bae315d8d6 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache @@ -36,9 +36,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache index a6366ab94b8f..f28260c41d60 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache @@ -31,36 +31,36 @@ pub trait {{classnamePascalCase}}{{/required}}, + body: &{{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}, {{/x-consumes-plain-text}} {{#x-consumes-plain-text}} {{#isString}} - body: String, + body: &String, {{/isString}} {{^isString}} - body: Bytes, + body: &Bytes, {{/isString}} {{/x-consumes-plain-text}} {{/vendorExtensions}} @@ -68,10 +68,10 @@ pub trait {{classnamePascalCase}} Result<{{{operationId}}}Response, E>; {{/vendorExtensions}} diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache index 26095202be48..a3b08f9aacdc 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache @@ -187,38 +187,38 @@ where {{/disableValidator}} let result = api_impl.as_ref().{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( - method.clone(), - host.clone(), - cookies.clone(), + &method, + &host, + &cookies, {{#vendorExtensions}} {{#x-has-auth-methods}} - claims, + &claims, {{/x-has-auth-methods}} {{/vendorExtensions}} {{#headerParams.size}} - header_params, + &header_params, {{/headerParams.size}} {{#pathParams.size}} - path_params, + &path_params, {{/pathParams.size}} {{#queryParams.size}} - query_params, + &query_params, {{/queryParams.size}} {{#vendorExtensions}} {{^x-consumes-multipart-related}} {{^x-consumes-multipart}} {{#bodyParams}} {{#-first}} - body, + &body, {{/-first}} {{/bodyParams}} {{/x-consumes-multipart}} {{/x-consumes-multipart-related}} {{#x-consumes-multipart}} - body, + &body, {{/x-consumes-multipart}} {{#x-consumes-multipart-related}} - body, + &body, {{/x-consumes-multipart-related}} {{/vendorExtensions}} ).await; @@ -347,7 +347,7 @@ where // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(method, host, cookies, why).await; + return api_impl.as_ref().handle_error(&method, &host, &cookies, why).await; }, }; diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs index 2d8b6defcb56..e05630fbb0f6 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs @@ -32,9 +32,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs index 6aa54868e222..ed68a060ca65 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs @@ -48,10 +48,10 @@ pub trait Payments: /// GetPaymentMethodById - GET /v71/paymentMethods/{id} async fn get_payment_method_by_id( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetPaymentMethodByIdPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::GetPaymentMethodByIdPathParams, ) -> Result; /// Get payment methods. @@ -59,9 +59,9 @@ pub trait Payments: /// GetPaymentMethods - GET /v71/paymentMethods async fn get_payment_methods( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Make a payment. @@ -69,10 +69,10 @@ pub trait Payments: /// PostMakePayment - POST /v71/payments async fn post_make_payment( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + body: &Option, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index b307f75f82a1..062ceba85b96 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -76,7 +76,7 @@ where let result = api_impl .as_ref() - .get_payment_method_by_id(method.clone(), host.clone(), cookies.clone(), path_params) + .get_payment_method_by_id(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -136,7 +136,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -178,7 +178,7 @@ where let result = api_impl .as_ref() - .get_payment_methods(method.clone(), host.clone(), cookies.clone()) + .get_payment_methods(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -215,7 +215,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -288,7 +288,7 @@ where let result = api_impl .as_ref() - .post_make_payment(method.clone(), host.clone(), cookies.clone(), claims, body) + .post_make_payment(&method, &host, &cookies, &claims, &body) .await; let mut response = Response::builder(); @@ -348,7 +348,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs index 82e7335f3536..b9962b8d84af 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs @@ -38,27 +38,27 @@ pub trait Default: super::Error /// MultipartRelatedRequestPost - POST /multipart_related_request async fn multipart_related_request_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: axum::body::Body, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &axum::body::Body, ) -> Result; /// MultipartRequestPost - POST /multipart_request async fn multipart_request_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Multipart, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Multipart, ) -> Result; /// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types async fn multiple_identical_mime_types_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: axum::body::Body, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &axum::body::Body, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs index 485bb4999526..752f538755dd 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs @@ -7,9 +7,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index 5516b2299a54..e96fd12e11f4 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -69,7 +69,7 @@ where let result = api_impl .as_ref() - .multipart_related_request_post(method.clone(), host.clone(), cookies.clone(), body) + .multipart_related_request_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -87,7 +87,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -130,7 +130,7 @@ where let result = api_impl .as_ref() - .multipart_request_post(method.clone(), host.clone(), cookies.clone(), body) + .multipart_request_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -148,7 +148,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -192,7 +192,7 @@ where let result = api_impl .as_ref() - .multiple_identical_mime_types_post(method.clone(), host.clone(), cookies.clone(), body) + .multiple_identical_mime_types_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -210,7 +210,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs index 169077ce242e..d11bfd5a8215 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs @@ -278,37 +278,37 @@ pub trait Default: super::Error /// AnyOfGet - GET /any-of async fn any_of_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::AnyOfGetQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::AnyOfGetQueryParams, ) -> Result; /// CallbackWithHeaderPost - POST /callback-with-header async fn callback_with_header_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::CallbackWithHeaderPostQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::CallbackWithHeaderPostQueryParams, ) -> Result; /// ComplexQueryParamGet - GET /complex-query-param async fn complex_query_param_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::ComplexQueryParamGetQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::ComplexQueryParamGetQueryParams, ) -> Result; /// EnumInPathPathParamGet - GET /enum_in_path/{path_param} async fn enum_in_path_path_param_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::EnumInPathPathParamGetPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::EnumInPathPathParamGetPathParams, ) -> Result; /// Test a Form Post. @@ -316,45 +316,45 @@ pub trait Default: super::Error /// FormTest - POST /form-test async fn form_test( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::FormTestRequest, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::FormTestRequest, ) -> Result; /// GetWithBooleanParameter - GET /get-with-bool async fn get_with_boolean_parameter( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::GetWithBooleanParameterQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::GetWithBooleanParameterQueryParams, ) -> Result; /// JsonComplexQueryParamGet - GET /json-complex-query-param async fn json_complex_query_param_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::JsonComplexQueryParamGetQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::JsonComplexQueryParamGetQueryParams, ) -> Result; /// MandatoryRequestHeaderGet - GET /mandatory-request-header async fn mandatory_request_header_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::MandatoryRequestHeaderGetHeaderParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + header_params: &models::MandatoryRequestHeaderGetHeaderParams, ) -> Result; /// MergePatchJsonGet - GET /merge-patch-json async fn merge_patch_json_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Get some stuff.. @@ -362,42 +362,42 @@ pub trait Default: super::Error /// MultigetGet - GET /multiget async fn multiget_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// MultipleAuthSchemeGet - GET /multiple_auth_scheme async fn multiple_auth_scheme_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet - GET /multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b} async fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams, ) -> Result; /// OneOfGet - GET /one-of async fn one_of_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// OverrideServerGet - GET /override-server async fn override_server_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Get some stuff with parameters.. @@ -405,105 +405,105 @@ pub trait Default: super::Error /// ParamgetGet - GET /paramget async fn paramget_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::ParamgetGetQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::ParamgetGetQueryParams, ) -> Result; /// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme async fn readonly_auth_scheme_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// RegisterCallbackPost - POST /register-callback async fn register_callback_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::RegisterCallbackPostQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::RegisterCallbackPostQueryParams, ) -> Result; /// RequiredOctetStreamPut - PUT /required_octet_stream async fn required_octet_stream_put( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Bytes, ) -> Result; /// ResponsesWithHeadersGet - GET /responses_with_headers async fn responses_with_headers_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Rfc7807Get - GET /rfc7807 async fn rfc7807_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// TwoFirstLetterHeaders - POST /operation-two-first-letter-headers async fn two_first_letter_headers( &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::TwoFirstLetterHeadersHeaderParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + header_params: &models::TwoFirstLetterHeadersHeaderParams, ) -> Result; /// UntypedPropertyGet - GET /untyped_property async fn untyped_property_get( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Option, ) -> Result; /// UuidGet - GET /uuid async fn uuid_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// XmlExtraPost - POST /xml_extra async fn xml_extra_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Bytes, ) -> Result; /// XmlOtherPost - POST /xml_other async fn xml_other_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Bytes, ) -> Result; /// XmlOtherPut - PUT /xml_other async fn xml_other_put( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Bytes, ) -> Result; /// Post an array. It's important we test apostrophes, so include one here.. @@ -511,18 +511,18 @@ pub trait Default: super::Error /// XmlPost - POST /xml async fn xml_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Bytes, ) -> Result; /// XmlPut - PUT /xml async fn xml_put( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Bytes, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs index 2a71e7f4ee21..5b6bb90d18c1 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs @@ -24,9 +24,9 @@ pub trait InfoRepo: /// GetRepoInfo - GET /repos/{repoId} async fn get_repo_info( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetRepoInfoPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::GetRepoInfoPathParams, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs index 1228d9000998..4a7d1c8a6009 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs @@ -9,9 +9,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs index e56966070666..f89fdb58e46d 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs @@ -22,9 +22,9 @@ pub trait Repo: super::ErrorHan /// CreateRepo - POST /repos async fn create_repo( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::ObjectParam, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::ObjectParam, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index 3c1032088d97..01121d7b0dcb 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -146,7 +146,7 @@ where let result = api_impl .as_ref() - .any_of_get(method.clone(), host.clone(), cookies.clone(), query_params) + .any_of_get(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -229,7 +229,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -273,7 +273,7 @@ where let result = api_impl .as_ref() - .callback_with_header_post(method.clone(), host.clone(), cookies.clone(), query_params) + .callback_with_header_post(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -291,7 +291,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -335,7 +335,7 @@ where let result = api_impl .as_ref() - .complex_query_param_get(method.clone(), host.clone(), cookies.clone(), query_params) + .complex_query_param_get(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -353,7 +353,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -397,7 +397,7 @@ where let result = api_impl .as_ref() - .enum_in_path_path_param_get(method.clone(), host.clone(), cookies.clone(), path_params) + .enum_in_path_path_param_get(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -415,7 +415,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -467,7 +467,7 @@ where let result = api_impl .as_ref() - .form_test(method.clone(), host.clone(), cookies.clone(), body) + .form_test(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -485,7 +485,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -529,7 +529,7 @@ where let result = api_impl .as_ref() - .get_with_boolean_parameter(method.clone(), host.clone(), cookies.clone(), query_params) + .get_with_boolean_parameter(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -547,7 +547,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -591,7 +591,7 @@ where let result = api_impl .as_ref() - .json_complex_query_param_get(method.clone(), host.clone(), cookies.clone(), query_params) + .json_complex_query_param_get(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -609,7 +609,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -686,7 +686,7 @@ where let result = api_impl .as_ref() - .mandatory_request_header_get(method.clone(), host.clone(), cookies.clone(), header_params) + .mandatory_request_header_get(&method, &host, &cookies, &header_params) .await; let mut response = Response::builder(); @@ -704,7 +704,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -743,7 +743,7 @@ where let result = api_impl .as_ref() - .merge_patch_json_get(method.clone(), host.clone(), cookies.clone()) + .merge_patch_json_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -780,7 +780,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -819,7 +819,7 @@ where let result = api_impl .as_ref() - .multiget_get(method.clone(), host.clone(), cookies.clone()) + .multiget_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -973,7 +973,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1012,7 +1012,7 @@ where let result = api_impl .as_ref() - .multiple_auth_scheme_get(method.clone(), host.clone(), cookies.clone()) + .multiple_auth_scheme_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -1029,7 +1029,7 @@ where // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(method, host, cookies, why).await; + return api_impl.as_ref().handle_error(&method, &host, &cookies, why).await; }, }; @@ -1086,10 +1086,10 @@ where let result = api_impl .as_ref() .multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get( - method.clone(), - host.clone(), - cookies.clone(), - path_params, + &method, + &host, + &cookies, + &path_params, ) .await; @@ -1107,7 +1107,7 @@ where // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(method, host, cookies, why).await; + return api_impl.as_ref().handle_error(&method, &host, &cookies, why).await; }, }; @@ -1143,10 +1143,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .one_of_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().one_of_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1182,7 +1179,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1221,7 +1218,7 @@ where let result = api_impl .as_ref() - .override_server_get(method.clone(), host.clone(), cookies.clone()) + .override_server_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -1239,7 +1236,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1283,7 +1280,7 @@ where let result = api_impl .as_ref() - .paramget_get(method.clone(), host.clone(), cookies.clone(), query_params) + .paramget_get(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -1320,7 +1317,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1359,7 +1356,7 @@ where let result = api_impl .as_ref() - .readonly_auth_scheme_get(method.clone(), host.clone(), cookies.clone()) + .readonly_auth_scheme_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -1376,7 +1373,7 @@ where // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(method, host, cookies, why).await; + return api_impl.as_ref().handle_error(&method, &host, &cookies, why).await; }, }; @@ -1419,7 +1416,7 @@ where let result = api_impl .as_ref() - .register_callback_post(method.clone(), host.clone(), cookies.clone(), query_params) + .register_callback_post(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -1437,7 +1434,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1485,7 +1482,7 @@ where let result = api_impl .as_ref() - .required_octet_stream_put(method.clone(), host.clone(), cookies.clone(), body) + .required_octet_stream_put(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1503,7 +1500,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1542,7 +1539,7 @@ where let result = api_impl .as_ref() - .responses_with_headers_get(method.clone(), host.clone(), cookies.clone()) + .responses_with_headers_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -1668,7 +1665,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1707,7 +1704,7 @@ where let result = api_impl .as_ref() - .rfc7807_get(method.clone(), host.clone(), cookies.clone()) + .rfc7807_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -1783,7 +1780,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1870,7 +1867,7 @@ where let result = api_impl .as_ref() - .two_first_letter_headers(method.clone(), host.clone(), cookies.clone(), header_params) + .two_first_letter_headers(&method, &host, &cookies, &header_params) .await; let mut response = Response::builder(); @@ -1888,7 +1885,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1942,7 +1939,7 @@ where let result = api_impl .as_ref() - .untyped_property_get(method.clone(), host.clone(), cookies.clone(), body) + .untyped_property_get(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1959,7 +1956,7 @@ where // Application code returned an error. This should not happen, as the implementation should // return a valid response. - return api_impl.as_ref().handle_error(method, host, cookies, why).await; + return api_impl.as_ref().handle_error(&method, &host, &cookies, why).await; }, }; @@ -1995,10 +1992,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .uuid_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().uuid_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -2034,7 +2028,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2080,7 +2074,7 @@ where let result = api_impl .as_ref() - .xml_extra_post(method.clone(), host.clone(), cookies.clone(), body) + .xml_extra_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2102,7 +2096,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2148,7 +2142,7 @@ where let result = api_impl .as_ref() - .xml_other_post(method.clone(), host.clone(), cookies.clone(), body) + .xml_other_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2182,7 +2176,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2228,7 +2222,7 @@ where let result = api_impl .as_ref() - .xml_other_put(method.clone(), host.clone(), cookies.clone(), body) + .xml_other_put(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2250,7 +2244,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2296,7 +2290,7 @@ where let result = api_impl .as_ref() - .xml_post(method.clone(), host.clone(), cookies.clone(), body) + .xml_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2318,7 +2312,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2364,7 +2358,7 @@ where let result = api_impl .as_ref() - .xml_put(method.clone(), host.clone(), cookies.clone(), body) + .xml_put(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2386,7 +2380,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2430,7 +2424,7 @@ where let result = api_impl .as_ref() - .get_repo_info(method.clone(), host.clone(), cookies.clone(), path_params) + .get_repo_info(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -2467,7 +2461,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2519,7 +2513,7 @@ where let result = api_impl .as_ref() - .create_repo(method.clone(), host.clone(), cookies.clone(), body) + .create_repo(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2537,7 +2531,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs index 5e380ee9b073..a2a61814d788 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs @@ -310,296 +310,296 @@ pub trait Default: super::Error /// Op10Get - GET /op10 async fn op10_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op11Get - GET /op11 async fn op11_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op12Get - GET /op12 async fn op12_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op13Get - GET /op13 async fn op13_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op14Get - GET /op14 async fn op14_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op15Get - GET /op15 async fn op15_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op16Get - GET /op16 async fn op16_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op17Get - GET /op17 async fn op17_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op18Get - GET /op18 async fn op18_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op19Get - GET /op19 async fn op19_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op1Get - GET /op1 async fn op1_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op20Get - GET /op20 async fn op20_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op21Get - GET /op21 async fn op21_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op22Get - GET /op22 async fn op22_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op23Get - GET /op23 async fn op23_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op24Get - GET /op24 async fn op24_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op25Get - GET /op25 async fn op25_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op26Get - GET /op26 async fn op26_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op27Get - GET /op27 async fn op27_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op28Get - GET /op28 async fn op28_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op29Get - GET /op29 async fn op29_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op2Get - GET /op2 async fn op2_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op30Get - GET /op30 async fn op30_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op31Get - GET /op31 async fn op31_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op32Get - GET /op32 async fn op32_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op33Get - GET /op33 async fn op33_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op34Get - GET /op34 async fn op34_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op35Get - GET /op35 async fn op35_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op36Get - GET /op36 async fn op36_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op37Get - GET /op37 async fn op37_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op3Get - GET /op3 async fn op3_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op4Get - GET /op4 async fn op4_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op5Get - GET /op5 async fn op5_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op6Get - GET /op6 async fn op6_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op7Get - GET /op7 async fn op7_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op8Get - GET /op8 async fn op8_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Op9Get - GET /op9 async fn op9_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs index 485bb4999526..752f538755dd 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs @@ -7,9 +7,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs index 253368121c79..aa55774ce5fe 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs @@ -90,10 +90,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op10_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op10_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -110,7 +107,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -150,10 +147,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op11_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op11_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -170,7 +164,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -210,10 +204,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op12_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op12_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -230,7 +221,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -270,10 +261,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op13_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op13_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -290,7 +278,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -330,10 +318,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op14_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op14_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -350,7 +335,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -390,10 +375,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op15_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op15_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -410,7 +392,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -450,10 +432,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op16_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op16_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -470,7 +449,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -510,10 +489,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op17_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op17_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -530,7 +506,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -570,10 +546,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op18_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op18_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -590,7 +563,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -630,10 +603,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op19_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op19_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -650,7 +620,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -690,10 +660,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op1_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op1_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -710,7 +677,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -750,10 +717,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op20_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op20_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -770,7 +734,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -810,10 +774,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op21_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op21_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -830,7 +791,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -870,10 +831,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op22_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op22_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -890,7 +848,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -930,10 +888,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op23_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op23_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -950,7 +905,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -990,10 +945,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op24_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op24_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1010,7 +962,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1050,10 +1002,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op25_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op25_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1070,7 +1019,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1110,10 +1059,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op26_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op26_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1130,7 +1076,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1170,10 +1116,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op27_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op27_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1190,7 +1133,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1230,10 +1173,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op28_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op28_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1250,7 +1190,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1290,10 +1230,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op29_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op29_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1310,7 +1247,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1350,10 +1287,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op2_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op2_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1370,7 +1304,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1410,10 +1344,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op30_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op30_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1430,7 +1361,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1470,10 +1401,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op31_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op31_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1490,7 +1418,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1530,10 +1458,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op32_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op32_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1550,7 +1475,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1590,10 +1515,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op33_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op33_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1610,7 +1532,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1650,10 +1572,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op34_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op34_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1670,7 +1589,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1710,10 +1629,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op35_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op35_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1730,7 +1646,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1770,10 +1686,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op36_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op36_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1790,7 +1703,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1830,10 +1743,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op37_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op37_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1850,7 +1760,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1890,10 +1800,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op3_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op3_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1910,7 +1817,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1950,10 +1857,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op4_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op4_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -1970,7 +1874,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2010,10 +1914,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op5_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op5_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -2030,7 +1931,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2070,10 +1971,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op6_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op6_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -2090,7 +1988,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2130,10 +2028,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op7_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op7_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -2150,7 +2045,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2190,10 +2085,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op8_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op8_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -2210,7 +2102,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2250,10 +2142,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .op9_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().op9_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -2270,7 +2159,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs index ab2f3f577b43..9ac9a5922b24 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs @@ -26,9 +26,9 @@ pub trait AnotherFake: /// TestSpecialTags - PATCH /v2/another-fake/dummy async fn test_special_tags( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Client, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Client, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs index 5f7b7baff222..f44e44f12737 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs @@ -122,72 +122,72 @@ pub trait Fake: super::ErrorHan /// Call123example - GET /v2/fake/operation-with-numeric-id async fn call123example( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean async fn fake_outer_boolean_serialize( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Option, ) -> Result; /// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite async fn fake_outer_composite_serialize( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Option, ) -> Result; /// FakeOuterNumberSerialize - POST /v2/fake/outer/number async fn fake_outer_number_serialize( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Option, ) -> Result; /// FakeOuterStringSerialize - POST /v2/fake/outer/string async fn fake_outer_string_serialize( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Option, ) -> Result; /// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description async fn fake_response_with_numerical_description( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param} async fn hyphen_param( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::HyphenParamPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::HyphenParamPathParams, ) -> Result; /// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params async fn test_body_with_query_params( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::TestBodyWithQueryParamsQueryParams, - body: models::User, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::TestBodyWithQueryParamsQueryParams, + body: &models::User, ) -> Result; /// To test \"client\" model. @@ -195,10 +195,10 @@ pub trait Fake: super::ErrorHan /// TestClientModel - PATCH /v2/fake async fn test_client_model( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Client, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Client, ) -> Result; /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트. @@ -206,10 +206,10 @@ pub trait Fake: super::ErrorHan /// TestEndpointParameters - POST /v2/fake async fn test_endpoint_parameters( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::TestEndpointParametersRequest, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::TestEndpointParametersRequest, ) -> Result; /// To test enum parameters. @@ -217,12 +217,12 @@ pub trait Fake: super::ErrorHan /// TestEnumParameters - GET /v2/fake async fn test_enum_parameters( &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::TestEnumParametersHeaderParams, - query_params: models::TestEnumParametersQueryParams, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + header_params: &models::TestEnumParametersHeaderParams, + query_params: &models::TestEnumParametersQueryParams, + body: &Option, ) -> Result; /// test inline additionalProperties. @@ -230,10 +230,10 @@ pub trait Fake: super::ErrorHan /// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties async fn test_inline_additional_properties( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: std::collections::HashMap, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &std::collections::HashMap, ) -> Result; /// test json serialization of form data. @@ -241,9 +241,9 @@ pub trait Fake: super::ErrorHan /// TestJsonFormData - GET /v2/fake/jsonFormData async fn test_json_form_data( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::TestJsonFormDataRequest, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::TestJsonFormDataRequest, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs index 55a67eb995b8..73f26630691f 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs @@ -26,9 +26,9 @@ pub trait FakeClassnameTags123: /// TestClassname - PATCH /v2/fake_classname_test async fn test_classname( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Client, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Client, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs index a0522e8ffdf5..9c08cf65b059 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs @@ -25,9 +25,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs index 47bce9d611fd..050e9c72db95 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs @@ -94,10 +94,10 @@ pub trait Pet: super::ErrorHand /// AddPet - POST /v2/pet async fn add_pet( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Pet, ) -> Result; /// Deletes a pet. @@ -105,11 +105,11 @@ pub trait Pet: super::ErrorHand /// DeletePet - DELETE /v2/pet/{petId} async fn delete_pet( &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::DeletePetHeaderParams, - path_params: models::DeletePetPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + header_params: &models::DeletePetHeaderParams, + path_params: &models::DeletePetPathParams, ) -> Result; /// Finds Pets by status. @@ -117,10 +117,10 @@ pub trait Pet: super::ErrorHand /// FindPetsByStatus - GET /v2/pet/findByStatus async fn find_pets_by_status( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByStatusQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::FindPetsByStatusQueryParams, ) -> Result; /// Finds Pets by tags. @@ -128,10 +128,10 @@ pub trait Pet: super::ErrorHand /// FindPetsByTags - GET /v2/pet/findByTags async fn find_pets_by_tags( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByTagsQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::FindPetsByTagsQueryParams, ) -> Result; /// Find pet by ID. @@ -139,11 +139,11 @@ pub trait Pet: super::ErrorHand /// GetPetById - GET /v2/pet/{petId} async fn get_pet_by_id( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - path_params: models::GetPetByIdPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + path_params: &models::GetPetByIdPathParams, ) -> Result; /// Update an existing pet. @@ -151,10 +151,10 @@ pub trait Pet: super::ErrorHand /// UpdatePet - PUT /v2/pet async fn update_pet( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Pet, ) -> Result; /// Updates a pet in the store with form data. @@ -162,11 +162,11 @@ pub trait Pet: super::ErrorHand /// UpdatePetWithForm - POST /v2/pet/{petId} async fn update_pet_with_form( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UpdatePetWithFormPathParams, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::UpdatePetWithFormPathParams, + body: &Option, ) -> Result; /// uploads an image. @@ -174,10 +174,10 @@ pub trait Pet: super::ErrorHand /// UploadFile - POST /v2/pet/{petId}/uploadImage async fn upload_file( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UploadFilePathParams, - body: Multipart, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::UploadFilePathParams, + body: &Multipart, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs index 1f45b8d30a23..d828340cabe5 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs @@ -58,10 +58,10 @@ pub trait Store: super::ErrorHa /// DeleteOrder - DELETE /v2/store/order/{order_id} async fn delete_order( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::DeleteOrderPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::DeleteOrderPathParams, ) -> Result; /// Returns pet inventories by status. @@ -69,10 +69,10 @@ pub trait Store: super::ErrorHa /// GetInventory - GET /v2/store/inventory async fn get_inventory( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, ) -> Result; /// Find purchase order by ID. @@ -80,10 +80,10 @@ pub trait Store: super::ErrorHa /// GetOrderById - GET /v2/store/order/{order_id} async fn get_order_by_id( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetOrderByIdPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::GetOrderByIdPathParams, ) -> Result; /// Place an order for a pet. @@ -91,9 +91,9 @@ pub trait Store: super::ErrorHa /// PlaceOrder - POST /v2/store/order async fn place_order( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Order, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Order, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs index 43b9bb239667..1f56de373719 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs @@ -94,10 +94,10 @@ pub trait User: super::ErrorHan /// CreateUser - POST /v2/user async fn create_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::User, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::User, ) -> Result; /// Creates list of users with given input array. @@ -105,10 +105,10 @@ pub trait User: super::ErrorHan /// CreateUsersWithArrayInput - POST /v2/user/createWithArray async fn create_users_with_array_input( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Vec, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Vec, ) -> Result; /// Creates list of users with given input array. @@ -116,10 +116,10 @@ pub trait User: super::ErrorHan /// CreateUsersWithListInput - POST /v2/user/createWithList async fn create_users_with_list_input( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Vec, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &Vec, ) -> Result; /// Delete user. @@ -127,10 +127,10 @@ pub trait User: super::ErrorHan /// DeleteUser - DELETE /v2/user/{username} async fn delete_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::DeleteUserPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::DeleteUserPathParams, ) -> Result; /// Get user by user name. @@ -138,10 +138,10 @@ pub trait User: super::ErrorHan /// GetUserByName - GET /v2/user/{username} async fn get_user_by_name( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetUserByNamePathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::GetUserByNamePathParams, ) -> Result; /// Logs user into the system. @@ -149,10 +149,10 @@ pub trait User: super::ErrorHan /// LoginUser - GET /v2/user/login async fn login_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::LoginUserQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::LoginUserQueryParams, ) -> Result; /// Logs out current logged in user session. @@ -160,9 +160,9 @@ pub trait User: super::ErrorHan /// LogoutUser - GET /v2/user/logout async fn logout_user( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Updated user. @@ -170,10 +170,10 @@ pub trait User: super::ErrorHan /// UpdateUser - PUT /v2/user/{username} async fn update_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UpdateUserPathParams, - body: models::User, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::UpdateUserPathParams, + body: &models::User, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 31b892e9a640..802af1c0d5c4 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -168,7 +168,7 @@ where let result = api_impl .as_ref() - .test_special_tags(method.clone(), host.clone(), cookies.clone(), body) + .test_special_tags(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -205,7 +205,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -247,7 +247,7 @@ where let result = api_impl .as_ref() - .call123example(method.clone(), host.clone(), cookies.clone()) + .call123example(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -265,7 +265,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -323,7 +323,7 @@ where let result = api_impl .as_ref() - .fake_outer_boolean_serialize(method.clone(), host.clone(), cookies.clone(), body) + .fake_outer_boolean_serialize(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -360,7 +360,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -418,7 +418,7 @@ where let result = api_impl .as_ref() - .fake_outer_composite_serialize(method.clone(), host.clone(), cookies.clone(), body) + .fake_outer_composite_serialize(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -455,7 +455,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -513,7 +513,7 @@ where let result = api_impl .as_ref() - .fake_outer_number_serialize(method.clone(), host.clone(), cookies.clone(), body) + .fake_outer_number_serialize(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -550,7 +550,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -608,7 +608,7 @@ where let result = api_impl .as_ref() - .fake_outer_string_serialize(method.clone(), host.clone(), cookies.clone(), body) + .fake_outer_string_serialize(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -645,7 +645,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -689,7 +689,7 @@ where let result = api_impl .as_ref() - .fake_response_with_numerical_description(method.clone(), host.clone(), cookies.clone()) + .fake_response_with_numerical_description(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -707,7 +707,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -754,7 +754,7 @@ where let result = api_impl .as_ref() - .hyphen_param(method.clone(), host.clone(), cookies.clone(), path_params) + .hyphen_param(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -772,7 +772,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -833,13 +833,7 @@ where let result = api_impl .as_ref() - .test_body_with_query_params( - method.clone(), - host.clone(), - cookies.clone(), - query_params, - body, - ) + .test_body_with_query_params(&method, &host, &cookies, &query_params, &body) .await; let mut response = Response::builder(); @@ -857,7 +851,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -912,7 +906,7 @@ where let result = api_impl .as_ref() - .test_client_model(method.clone(), host.clone(), cookies.clone(), body) + .test_client_model(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -949,7 +943,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1004,7 +998,7 @@ where let result = api_impl .as_ref() - .test_endpoint_parameters(method.clone(), host.clone(), cookies.clone(), body) + .test_endpoint_parameters(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1026,7 +1020,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1149,12 +1143,12 @@ where let result = api_impl .as_ref() .test_enum_parameters( - method.clone(), - host.clone(), - cookies.clone(), - header_params, - query_params, - body, + &method, + &host, + &cookies, + &header_params, + &query_params, + &body, ) .await; @@ -1177,7 +1171,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1232,7 +1226,7 @@ where let result = api_impl .as_ref() - .test_inline_additional_properties(method.clone(), host.clone(), cookies.clone(), body) + .test_inline_additional_properties(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1250,7 +1244,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1305,7 +1299,7 @@ where let result = api_impl .as_ref() - .test_json_form_data(method.clone(), host.clone(), cookies.clone(), body) + .test_json_form_data(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1323,7 +1317,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1378,7 +1372,7 @@ where let result = api_impl .as_ref() - .test_classname(method.clone(), host.clone(), cookies.clone(), body) + .test_classname(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1417,7 +1411,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1470,7 +1464,7 @@ where let result = api_impl .as_ref() - .add_pet(method.clone(), host.clone(), cookies.clone(), body) + .add_pet(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1488,7 +1482,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1567,13 +1561,7 @@ where let result = api_impl .as_ref() - .delete_pet( - method.clone(), - host.clone(), - cookies.clone(), - header_params, - path_params, - ) + .delete_pet(&method, &host, &cookies, &header_params, &path_params) .await; let mut response = Response::builder(); @@ -1591,7 +1579,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1639,7 +1627,7 @@ where let result = api_impl .as_ref() - .find_pets_by_status(method.clone(), host.clone(), cookies.clone(), query_params) + .find_pets_by_status(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -1673,7 +1661,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1721,7 +1709,7 @@ where let result = api_impl .as_ref() - .find_pets_by_tags(method.clone(), host.clone(), cookies.clone(), query_params) + .find_pets_by_tags(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -1755,7 +1743,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1816,13 +1804,7 @@ where let result = api_impl .as_ref() - .get_pet_by_id( - method.clone(), - host.clone(), - cookies.clone(), - claims, - path_params, - ) + .get_pet_by_id(&method, &host, &cookies, &claims, &path_params) .await; let mut response = Response::builder(); @@ -1860,7 +1842,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1915,7 +1897,7 @@ where let result = api_impl .as_ref() - .update_pet(method.clone(), host.clone(), cookies.clone(), body) + .update_pet(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1941,7 +1923,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2008,13 +1990,7 @@ where let result = api_impl .as_ref() - .update_pet_with_form( - method.clone(), - host.clone(), - cookies.clone(), - path_params, - body, - ) + .update_pet_with_form(&method, &host, &cookies, &path_params, &body) .await; let mut response = Response::builder(); @@ -2032,7 +2008,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2080,13 +2056,7 @@ where let result = api_impl .as_ref() - .upload_file( - method.clone(), - host.clone(), - cookies.clone(), - path_params, - body, - ) + .upload_file(&method, &host, &cookies, &path_params, &body) .await; let mut response = Response::builder(); @@ -2123,7 +2093,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2170,7 +2140,7 @@ where let result = api_impl .as_ref() - .delete_order(method.clone(), host.clone(), cookies.clone(), path_params) + .delete_order(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -2192,7 +2162,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2248,7 +2218,7 @@ where let result = api_impl .as_ref() - .get_inventory(method.clone(), host.clone(), cookies.clone(), claims) + .get_inventory(&method, &host, &cookies, &claims) .await; let mut response = Response::builder(); @@ -2285,7 +2255,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2332,7 +2302,7 @@ where let result = api_impl .as_ref() - .get_order_by_id(method.clone(), host.clone(), cookies.clone(), path_params) + .get_order_by_id(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -2370,7 +2340,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2425,7 +2395,7 @@ where let result = api_impl .as_ref() - .place_order(method.clone(), host.clone(), cookies.clone(), body) + .place_order(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2459,7 +2429,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2514,7 +2484,7 @@ where let result = api_impl .as_ref() - .create_user(method.clone(), host.clone(), cookies.clone(), body) + .create_user(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2532,7 +2502,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2588,7 +2558,7 @@ where let result = api_impl .as_ref() - .create_users_with_array_input(method.clone(), host.clone(), cookies.clone(), body) + .create_users_with_array_input(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2606,7 +2576,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2662,7 +2632,7 @@ where let result = api_impl .as_ref() - .create_users_with_list_input(method.clone(), host.clone(), cookies.clone(), body) + .create_users_with_list_input(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -2680,7 +2650,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2727,7 +2697,7 @@ where let result = api_impl .as_ref() - .delete_user(method.clone(), host.clone(), cookies.clone(), path_params) + .delete_user(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -2749,7 +2719,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2796,7 +2766,7 @@ where let result = api_impl .as_ref() - .get_user_by_name(method.clone(), host.clone(), cookies.clone(), path_params) + .get_user_by_name(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -2834,7 +2804,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2881,7 +2851,7 @@ where let result = api_impl .as_ref() - .login_user(method.clone(), host.clone(), cookies.clone(), query_params) + .login_user(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -2952,7 +2922,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -2994,7 +2964,7 @@ where let result = api_impl .as_ref() - .logout_user(method.clone(), host.clone(), cookies.clone()) + .logout_user(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -3012,7 +2982,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -3070,13 +3040,7 @@ where let result = api_impl .as_ref() - .update_user( - method.clone(), - host.clone(), - cookies.clone(), - path_params, - body, - ) + .update_user(&method, &host, &cookies, &path_params, &body) .await; let mut response = Response::builder(); @@ -3098,7 +3062,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs index 3095734d0a70..aac123780614 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs @@ -22,9 +22,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs index e2ac2ae84fcf..7ae490554433 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs @@ -98,10 +98,10 @@ pub trait Pet: super::ErrorHand /// AddPet - POST /v2/pet async fn add_pet( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Pet, ) -> Result; /// Deletes a pet. @@ -109,11 +109,11 @@ pub trait Pet: super::ErrorHand /// DeletePet - DELETE /v2/pet/{petId} async fn delete_pet( &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::DeletePetHeaderParams, - path_params: models::DeletePetPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + header_params: &models::DeletePetHeaderParams, + path_params: &models::DeletePetPathParams, ) -> Result; /// Finds Pets by status. @@ -121,10 +121,10 @@ pub trait Pet: super::ErrorHand /// FindPetsByStatus - GET /v2/pet/findByStatus async fn find_pets_by_status( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByStatusQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::FindPetsByStatusQueryParams, ) -> Result; /// Finds Pets by tags. @@ -132,10 +132,10 @@ pub trait Pet: super::ErrorHand /// FindPetsByTags - GET /v2/pet/findByTags async fn find_pets_by_tags( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByTagsQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::FindPetsByTagsQueryParams, ) -> Result; /// Find pet by ID. @@ -143,11 +143,11 @@ pub trait Pet: super::ErrorHand /// GetPetById - GET /v2/pet/{petId} async fn get_pet_by_id( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - path_params: models::GetPetByIdPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + path_params: &models::GetPetByIdPathParams, ) -> Result; /// Update an existing pet. @@ -155,10 +155,10 @@ pub trait Pet: super::ErrorHand /// UpdatePet - PUT /v2/pet async fn update_pet( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Pet, ) -> Result; /// Updates a pet in the store with form data. @@ -166,11 +166,11 @@ pub trait Pet: super::ErrorHand /// UpdatePetWithForm - POST /v2/pet/{petId} async fn update_pet_with_form( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UpdatePetWithFormPathParams, - body: Option, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::UpdatePetWithFormPathParams, + body: &Option, ) -> Result; /// uploads an image. @@ -178,10 +178,10 @@ pub trait Pet: super::ErrorHand /// UploadFile - POST /v2/pet/{petId}/uploadImage async fn upload_file( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UploadFilePathParams, - body: Multipart, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::UploadFilePathParams, + body: &Multipart, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs index eccf5686b541..d3297bf7637e 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs @@ -58,10 +58,10 @@ pub trait Store: super::ErrorHa /// DeleteOrder - DELETE /v2/store/order/{orderId} async fn delete_order( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::DeleteOrderPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::DeleteOrderPathParams, ) -> Result; /// Returns pet inventories by status. @@ -69,10 +69,10 @@ pub trait Store: super::ErrorHa /// GetInventory - GET /v2/store/inventory async fn get_inventory( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, ) -> Result; /// Find purchase order by ID. @@ -80,10 +80,10 @@ pub trait Store: super::ErrorHa /// GetOrderById - GET /v2/store/order/{orderId} async fn get_order_by_id( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetOrderByIdPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::GetOrderByIdPathParams, ) -> Result; /// Place an order for a pet. @@ -91,9 +91,9 @@ pub trait Store: super::ErrorHa /// PlaceOrder - POST /v2/store/order async fn place_order( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Order, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Order, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs index d5c6af060eef..69adadd29a15 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs @@ -97,11 +97,11 @@ pub trait User: super::ErrorHan /// CreateUser - POST /v2/user async fn create_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - body: models::User, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + body: &models::User, ) -> Result; /// Creates list of users with given input array. @@ -109,11 +109,11 @@ pub trait User: super::ErrorHan /// CreateUsersWithArrayInput - POST /v2/user/createWithArray async fn create_users_with_array_input( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - body: Vec, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + body: &Vec, ) -> Result; /// Creates list of users with given input array. @@ -121,11 +121,11 @@ pub trait User: super::ErrorHan /// CreateUsersWithListInput - POST /v2/user/createWithList async fn create_users_with_list_input( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - body: Vec, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + body: &Vec, ) -> Result; /// Delete user. @@ -133,11 +133,11 @@ pub trait User: super::ErrorHan /// DeleteUser - DELETE /v2/user/{username} async fn delete_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - path_params: models::DeleteUserPathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + path_params: &models::DeleteUserPathParams, ) -> Result; /// Get user by user name. @@ -145,10 +145,10 @@ pub trait User: super::ErrorHan /// GetUserByName - GET /v2/user/{username} async fn get_user_by_name( &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetUserByNamePathParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + path_params: &models::GetUserByNamePathParams, ) -> Result; /// Logs user into the system. @@ -156,10 +156,10 @@ pub trait User: super::ErrorHan /// LoginUser - GET /v2/user/login async fn login_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::LoginUserQueryParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + query_params: &models::LoginUserQueryParams, ) -> Result; /// Logs out current logged in user session. @@ -167,10 +167,10 @@ pub trait User: super::ErrorHan /// LogoutUser - GET /v2/user/logout async fn logout_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, ) -> Result; /// Updated user. @@ -178,11 +178,11 @@ pub trait User: super::ErrorHan /// UpdateUser - PUT /v2/user/{username} async fn update_user( &self, - method: Method, - host: Host, - cookies: CookieJar, - claims: Self::Claims, - path_params: models::UpdateUserPathParams, - body: models::User, + method: &Method, + host: &Host, + cookies: &CookieJar, + claims: &Self::Claims, + path_params: &models::UpdateUserPathParams, + body: &models::User, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index 10bf9745bd91..8e006b5f3da6 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -115,7 +115,7 @@ where let result = api_impl .as_ref() - .add_pet(method.clone(), host.clone(), cookies.clone(), body) + .add_pet(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -149,7 +149,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -228,13 +228,7 @@ where let result = api_impl .as_ref() - .delete_pet( - method.clone(), - host.clone(), - cookies.clone(), - header_params, - path_params, - ) + .delete_pet(&method, &host, &cookies, &header_params, &path_params) .await; let mut response = Response::builder(); @@ -252,7 +246,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -300,7 +294,7 @@ where let result = api_impl .as_ref() - .find_pets_by_status(method.clone(), host.clone(), cookies.clone(), query_params) + .find_pets_by_status(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -334,7 +328,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -382,7 +376,7 @@ where let result = api_impl .as_ref() - .find_pets_by_tags(method.clone(), host.clone(), cookies.clone(), query_params) + .find_pets_by_tags(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -416,7 +410,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -477,13 +471,7 @@ where let result = api_impl .as_ref() - .get_pet_by_id( - method.clone(), - host.clone(), - cookies.clone(), - claims, - path_params, - ) + .get_pet_by_id(&method, &host, &cookies, &claims, &path_params) .await; let mut response = Response::builder(); @@ -521,7 +509,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -576,7 +564,7 @@ where let result = api_impl .as_ref() - .update_pet(method.clone(), host.clone(), cookies.clone(), body) + .update_pet(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -618,7 +606,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -685,13 +673,7 @@ where let result = api_impl .as_ref() - .update_pet_with_form( - method.clone(), - host.clone(), - cookies.clone(), - path_params, - body, - ) + .update_pet_with_form(&method, &host, &cookies, &path_params, &body) .await; let mut response = Response::builder(); @@ -709,7 +691,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -757,13 +739,7 @@ where let result = api_impl .as_ref() - .upload_file( - method.clone(), - host.clone(), - cookies.clone(), - path_params, - body, - ) + .upload_file(&method, &host, &cookies, &path_params, &body) .await; let mut response = Response::builder(); @@ -800,7 +776,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -847,7 +823,7 @@ where let result = api_impl .as_ref() - .delete_order(method.clone(), host.clone(), cookies.clone(), path_params) + .delete_order(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -869,7 +845,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -925,7 +901,7 @@ where let result = api_impl .as_ref() - .get_inventory(method.clone(), host.clone(), cookies.clone(), claims) + .get_inventory(&method, &host, &cookies, &claims) .await; let mut response = Response::builder(); @@ -962,7 +938,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1009,7 +985,7 @@ where let result = api_impl .as_ref() - .get_order_by_id(method.clone(), host.clone(), cookies.clone(), path_params) + .get_order_by_id(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -1047,7 +1023,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1102,7 +1078,7 @@ where let result = api_impl .as_ref() - .place_order(method.clone(), host.clone(), cookies.clone(), body) + .place_order(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -1136,7 +1112,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1205,7 +1181,7 @@ where let result = api_impl .as_ref() - .create_user(method.clone(), host.clone(), cookies.clone(), claims, body) + .create_user(&method, &host, &cookies, &claims, &body) .await; let mut response = Response::builder(); @@ -1223,7 +1199,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1293,7 +1269,7 @@ where let result = api_impl .as_ref() - .create_users_with_array_input(method.clone(), host.clone(), cookies.clone(), claims, body) + .create_users_with_array_input(&method, &host, &cookies, &claims, &body) .await; let mut response = Response::builder(); @@ -1311,7 +1287,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1381,7 +1357,7 @@ where let result = api_impl .as_ref() - .create_users_with_list_input(method.clone(), host.clone(), cookies.clone(), claims, body) + .create_users_with_list_input(&method, &host, &cookies, &claims, &body) .await; let mut response = Response::builder(); @@ -1399,7 +1375,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1460,13 +1436,7 @@ where let result = api_impl .as_ref() - .delete_user( - method.clone(), - host.clone(), - cookies.clone(), - claims, - path_params, - ) + .delete_user(&method, &host, &cookies, &claims, &path_params) .await; let mut response = Response::builder(); @@ -1488,7 +1458,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1535,7 +1505,7 @@ where let result = api_impl .as_ref() - .get_user_by_name(method.clone(), host.clone(), cookies.clone(), path_params) + .get_user_by_name(&method, &host, &cookies, &path_params) .await; let mut response = Response::builder(); @@ -1573,7 +1543,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1620,7 +1590,7 @@ where let result = api_impl .as_ref() - .login_user(method.clone(), host.clone(), cookies.clone(), query_params) + .login_user(&method, &host, &cookies, &query_params) .await; let mut response = Response::builder(); @@ -1707,7 +1677,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1763,7 +1733,7 @@ where let result = api_impl .as_ref() - .logout_user(method.clone(), host.clone(), cookies.clone(), claims) + .logout_user(&method, &host, &cookies, &claims) .await; let mut response = Response::builder(); @@ -1781,7 +1751,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -1853,14 +1823,7 @@ where let result = api_impl .as_ref() - .update_user( - method.clone(), - host.clone(), - cookies.clone(), - claims, - path_params, - body, - ) + .update_user(&method, &host, &cookies, &claims, &path_params, &body) .await; let mut response = Response::builder(); @@ -1882,7 +1845,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs index 4effbc57e60b..922820b5eea9 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs @@ -22,8 +22,8 @@ pub trait Default: super::Error /// PingGet - GET /ping async fn ping_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs index 485bb4999526..752f538755dd 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs @@ -7,9 +7,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index 07356b0925fe..157bff6832ce 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -54,10 +54,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .ping_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().ping_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -74,7 +71,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs index 48ff8f426dff..13e3dd8c0d6d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs @@ -22,9 +22,9 @@ pub trait Default: super::Error /// UsersPost - POST /users async fn users_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::UsersPostHeaderParams, + method: &Method, + host: &Host, + cookies: &CookieJar, + header_params: &models::UsersPostHeaderParams, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs index 485bb4999526..752f538755dd 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs @@ -7,9 +7,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs index 1929c8a07efd..c4609394babc 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs @@ -94,7 +94,7 @@ where let result = api_impl .as_ref() - .users_post(method.clone(), host.clone(), cookies.clone(), header_params) + .users_post(&method, &host, &cookies, &header_params) .await; let mut response = Response::builder(); @@ -131,7 +131,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs index 29a1e7540c4b..51ecf8aa400d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs @@ -22,9 +22,9 @@ pub trait Default: super::Error /// Foo - POST / async fn foo( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Message, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Message, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs index 485bb4999526..752f538755dd 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs @@ -7,9 +7,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs index 4e1cd6a832ca..6f0124dfbd59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs @@ -67,10 +67,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .foo(method.clone(), host.clone(), cookies.clone(), body) - .await; + let result = api_impl.as_ref().foo(&method, &host, &cookies, &body).await; let mut response = Response::builder(); @@ -106,7 +103,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs index 58e6cd90ddfd..3ac221be44b6 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs @@ -86,9 +86,9 @@ pub trait Default: super::Error /// AllOfGet - GET /allOf async fn all_of_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// A dummy endpoint to make the spec valid.. @@ -96,18 +96,18 @@ pub trait Default: super::Error /// DummyGet - GET /dummy async fn dummy_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// DummyPut - PUT /dummy async fn dummy_put( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::FooDummyPutRequest, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::FooDummyPutRequest, ) -> Result; /// Get a file. @@ -115,17 +115,17 @@ pub trait Default: super::Error /// FileResponseGet - GET /file_response async fn file_response_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// GetStructuredYaml - GET /get-structured-yaml async fn get_structured_yaml( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Test HTML handling. @@ -133,19 +133,19 @@ pub trait Default: super::Error /// HtmlPost - POST /html async fn html_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: String, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &String, ) -> Result; /// PostYaml - POST /post-yaml async fn post_yaml( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: String, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &String, ) -> Result; /// Get an arbitrary JSON blob.. @@ -153,9 +153,9 @@ pub trait Default: super::Error /// RawJsonGet - GET /raw_json async fn raw_json_get( &self, - method: Method, - host: Host, - cookies: CookieJar, + method: &Method, + host: &Host, + cookies: &CookieJar, ) -> Result; /// Send an arbitrary JSON blob. @@ -163,9 +163,9 @@ pub trait Default: super::Error /// SoloObjectPost - POST /solo-object async fn solo_object_post( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: crate::types::Object, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &crate::types::Object, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs index 485bb4999526..752f538755dd 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs @@ -7,9 +7,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index 31b020d8df6d..66fe370aab2e 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -64,10 +64,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .all_of_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().all_of_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -103,7 +100,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -143,10 +140,7 @@ where .map_err(|_| StatusCode::BAD_REQUEST); }; - let result = api_impl - .as_ref() - .dummy_get(method.clone(), host.clone(), cookies.clone()) - .await; + let result = api_impl.as_ref().dummy_get(&method, &host, &cookies).await; let mut response = Response::builder(); @@ -163,7 +157,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -218,7 +212,7 @@ where let result = api_impl .as_ref() - .dummy_put(method.clone(), host.clone(), cookies.clone(), body) + .dummy_put(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -236,7 +230,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -278,7 +272,7 @@ where let result = api_impl .as_ref() - .file_response_get(method.clone(), host.clone(), cookies.clone()) + .file_response_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -315,7 +309,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -357,7 +351,7 @@ where let result = api_impl .as_ref() - .get_structured_yaml(method.clone(), host.clone(), cookies.clone()) + .get_structured_yaml(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -387,7 +381,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -436,7 +430,7 @@ where let result = api_impl .as_ref() - .html_post(method.clone(), host.clone(), cookies.clone(), body) + .html_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -466,7 +460,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -515,7 +509,7 @@ where let result = api_impl .as_ref() - .post_yaml(method.clone(), host.clone(), cookies.clone(), body) + .post_yaml(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -533,7 +527,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -575,7 +569,7 @@ where let result = api_impl .as_ref() - .raw_json_get(method.clone(), host.clone(), cookies.clone()) + .raw_json_get(&method, &host, &cookies) .await; let mut response = Response::builder(); @@ -612,7 +606,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; @@ -666,7 +660,7 @@ where let result = api_impl .as_ref() - .solo_object_post(method.clone(), host.clone(), cookies.clone(), body) + .solo_object_post(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -684,7 +678,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs index dcf2ad05d0a3..97185f3e6819 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs @@ -22,9 +22,9 @@ pub trait Default: super::Error /// MailPut - PUT /mail async fn mail_put( &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Email, + method: &Method, + host: &Host, + cookies: &CookieJar, + body: &models::Email, ) -> Result; } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs index 485bb4999526..752f538755dd 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs @@ -7,9 +7,9 @@ pub trait ErrorHandler { #[tracing::instrument(skip_all)] async fn handle_error( &self, - method: ::http::Method, - host: axum_extra::extract::Host, - cookies: axum_extra::extract::CookieJar, + method: &::http::Method, + host: &axum_extra::extract::Host, + cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { tracing::error!("Unhandled error: {:?}", error); diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs index bb62d8c38341..be9c3aeecc3e 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs @@ -41,7 +41,7 @@ where { let result = api_impl .as_ref() - .mail_put(method.clone(), host.clone(), cookies.clone(), body) + .mail_put(&method, &host, &cookies, &body) .await; let mut response = Response::builder(); @@ -59,7 +59,7 @@ where return api_impl .as_ref() - .handle_error(method, host, cookies, why) + .handle_error(&method, &host, &cookies, why) .await; } }; From 0e025adf45717f71037848b05edb5deb49e52395 Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Fri, 7 Feb 2025 13:36:53 +0100 Subject: [PATCH 5/9] Multipart is also part of the axum update --- .../src/main/resources/rust-axum/Cargo.mustache | 4 ++-- .../src/main/resources/rust-axum/apis.mustache | 2 +- .../src/main/resources/rust-axum/server-imports.mustache | 2 +- .../server/petstore/rust-axum/output/apikey-auths/Cargo.toml | 4 ++-- .../rust-axum/output/apikey-auths/src/apis/payments.rs | 2 +- .../petstore/rust-axum/output/apikey-auths/src/server/mod.rs | 2 +- .../server/petstore/rust-axum/output/multipart-v3/Cargo.toml | 4 ++-- .../rust-axum/output/multipart-v3/src/apis/default.rs | 2 +- .../petstore/rust-axum/output/multipart-v3/src/server/mod.rs | 2 +- .../server/petstore/rust-axum/output/openapi-v3/Cargo.toml | 4 ++-- .../petstore/rust-axum/output/openapi-v3/src/apis/default.rs | 2 +- .../rust-axum/output/openapi-v3/src/apis/info_repo.rs | 2 +- .../petstore/rust-axum/output/openapi-v3/src/apis/repo.rs | 2 +- .../petstore/rust-axum/output/openapi-v3/src/server/mod.rs | 2 +- samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml | 4 ++-- .../petstore/rust-axum/output/ops-v3/src/apis/default.rs | 2 +- .../server/petstore/rust-axum/output/ops-v3/src/server/mod.rs | 2 +- .../Cargo.toml | 4 ++-- .../src/apis/another_fake.rs | 2 +- .../src/apis/fake.rs | 2 +- .../src/apis/fake_classname_tags123.rs | 2 +- .../src/apis/pet.rs | 2 +- .../src/apis/store.rs | 2 +- .../src/apis/user.rs | 2 +- .../src/server/mod.rs | 2 +- samples/server/petstore/rust-axum/output/petstore/Cargo.toml | 4 ++-- .../server/petstore/rust-axum/output/petstore/src/apis/pet.rs | 2 +- .../petstore/rust-axum/output/petstore/src/apis/store.rs | 2 +- .../petstore/rust-axum/output/petstore/src/apis/user.rs | 2 +- .../petstore/rust-axum/output/petstore/src/server/mod.rs | 2 +- .../petstore/rust-axum/output/ping-bearer-auth/Cargo.toml | 4 ++-- .../rust-axum/output/ping-bearer-auth/src/apis/default.rs | 2 +- .../rust-axum/output/ping-bearer-auth/src/server/mod.rs | 2 +- .../rust-axum/output/rust-axum-header-uuid/Cargo.toml | 4 ++-- .../output/rust-axum-header-uuid/src/apis/default.rs | 2 +- .../rust-axum/output/rust-axum-header-uuid/src/server/mod.rs | 2 +- .../petstore/rust-axum/output/rust-axum-oneof/Cargo.toml | 4 ++-- .../rust-axum/output/rust-axum-oneof/src/apis/default.rs | 2 +- .../rust-axum/output/rust-axum-oneof/src/server/mod.rs | 2 +- .../petstore/rust-axum/output/rust-axum-test/Cargo.toml | 4 ++-- .../rust-axum/output/rust-axum-test/src/apis/default.rs | 2 +- .../rust-axum/output/rust-axum-test/src/server/mod.rs | 2 +- .../rust-axum/output/rust-axum-validation-test/Cargo.toml | 4 ++-- .../output/rust-axum-validation-test/src/apis/default.rs | 2 +- .../output/rust-axum-validation-test/src/server/mod.rs | 2 +- 45 files changed, 57 insertions(+), 57 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 23af1423c536..ba37ecdeb0de 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache @@ -40,8 +40,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache index f28260c41d60..7bcb98eb47db 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Multipart, Host}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache index ee9ae4cfd99e..6ca3300e4f11 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Multipart, Host}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 174c342084a5..d99bd53b1fe3 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs index ed68a060ca65..5bff9b674790 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index 062ceba85b96..a55fa2b18bda 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 d4102dd4dd0e..9b19309ec211 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs index b9962b8d84af..84c0c79e9544 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index e96fd12e11f4..e098a8c29b08 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 d93c70177bea..5dd596ed3f60 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs index d11bfd5a8215..65b74d4a39c5 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs index 5b6bb90d18c1..822576c53466 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs index f89fdb58e46d..f3c5c204493d 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index 01121d7b0dcb..fd17b920227a 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 ac619e766161..b4cb37fab58a 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs index a2a61814d788..f82fc8ea9707 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs index aa55774ce5fe..f1658b2cc69c 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 352b395aeb8f..ea81193f6c5e 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 @@ -20,8 +20,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs index 9ac9a5922b24..f3a796904b3d 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs index f44e44f12737..3baac16a6e52 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs index 73f26630691f..4987f71681ea 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs index 050e9c72db95..c7f7c19f1809 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs index d828340cabe5..c53e0608da9c 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs index 1f56de373719..1c68461fdf67 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 802af1c0d5c4..a02a906a80d2 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; diff --git a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml index e64a8d672b80..3486b3a99ca2 100644 --- a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml @@ -19,8 +19,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs index 7ae490554433..aedef6a80c77 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs index d3297bf7637e..d564986ceaf1 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs index 69adadd29a15..5bf728968880 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index 8e006b5f3da6..9fba7852109b 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 f1b0be05dc88..6881b23a29d2 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs index 922820b5eea9..d35c79e55408 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index 157bff6832ce..579474fa03aa 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 1ba45f9703c3..dc3fc8fbb866 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs index 13e3dd8c0d6d..f6a1555ba92c 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs index c4609394babc..bb933d9d6ce0 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 8d3fca9eb9e7..fc3aaa306ddf 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs index 51ecf8aa400d..bd39840e27c9 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs index 6f0124dfbd59..5ebf7f1f7bf1 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 0887417d6402..cb26009936a9 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs index 3ac221be44b6..a4f22925474e 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index 66fe370aab2e..a12cfd64478b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 421ea6343c25..0d1de6020337 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = "0.8" -axum-extra = { version = "0.10", features = ["cookie", "multipart"] } +axum = { version = "0.8", features = ["multipart"] } +axum-extra = { version = "0.10", features = ["cookie"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs index 97185f3e6819..7f26aebebd61 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs index be9c3aeecc3e..4f7e9afac62d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host, Multipart}; +use axum_extra::extract::{CookieJar, Host}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; From a58e0def79f64cd39fb9dc92befdd7eea49ee2da Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Fri, 7 Feb 2025 13:58:49 +0100 Subject: [PATCH 6/9] Prevent replacing path names with the same name as a dynamic path parameter --- .../codegen/languages/RustAxumServerCodegen.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java index 75b4493dde15..57cb7d9ddf6e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java @@ -426,7 +426,10 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation String axumPath = op.path; for (CodegenParameter param : op.pathParams) { // Replace {baseName} with {paramName} for format string - axumPath = axumPath.replace(param.baseName, param.paramName); + String paramSearch = "{" + param.baseName + "}"; + String paramReplace = "{" + param.paramName + "}"; + + axumPath = axumPath.replace(paramSearch, paramReplace); } pathMethodOpMap .computeIfAbsent(axumPath, (key) -> new ArrayList<>()) From e9ebd575f6ecb9145664cef0d6ef03389e342c1d Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Fri, 7 Feb 2025 20:11:10 +0100 Subject: [PATCH 7/9] Use status code name instead of number --- .../src/main/resources/rust-axum/apis-mod.mustache | 2 +- .../petstore/rust-axum/output/apikey-auths/src/apis/mod.rs | 2 +- .../petstore/rust-axum/output/multipart-v3/src/apis/mod.rs | 2 +- .../server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs | 2 +- samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs | 2 +- .../src/apis/mod.rs | 2 +- .../server/petstore/rust-axum/output/petstore/src/apis/mod.rs | 2 +- .../petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs | 2 +- .../rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs | 2 +- .../petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs | 2 +- .../petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs | 2 +- .../rust-axum/output/rust-axum-validation-test/src/apis/mod.rs | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache index 08bae315d8d6..3a75bc1abcdf 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache @@ -43,7 +43,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs index e05630fbb0f6..cb001b59d6a1 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs @@ -39,7 +39,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs index 752f538755dd..be654b5f14ce 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs @@ -14,7 +14,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs index 4a7d1c8a6009..134b27873bfb 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs @@ -16,7 +16,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs index 752f538755dd..be654b5f14ce 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs @@ -14,7 +14,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs index 9c08cf65b059..a8a2d0c7550d 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs @@ -32,7 +32,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs index aac123780614..2710cd128b63 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs @@ -29,7 +29,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs index 752f538755dd..be654b5f14ce 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs @@ -14,7 +14,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs index 752f538755dd..be654b5f14ce 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs @@ -14,7 +14,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs index 752f538755dd..be654b5f14ce 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs @@ -14,7 +14,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs index 752f538755dd..be654b5f14ce 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs @@ -14,7 +14,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs index 752f538755dd..be654b5f14ce 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs @@ -14,7 +14,7 @@ pub trait ErrorHandler { ) -> Result { tracing::error!("Unhandled error: {:?}", error); axum::response::Response::builder() - .status(500) + .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body(axum::body::Body::empty()) .map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR) } From a36fe9dd5df689fd8214e9386300dfbde58823bf Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Fri, 7 Feb 2025 20:14:56 +0100 Subject: [PATCH 8/9] Rollback axum update --- .../src/main/resources/rust-axum/Cargo.mustache | 4 ++-- .../src/main/resources/rust-axum/apis-mod.mustache | 2 +- .../src/main/resources/rust-axum/apis.mustache | 2 +- .../src/main/resources/rust-axum/server-imports.mustache | 2 +- .../server/petstore/rust-axum/output/apikey-auths/Cargo.toml | 4 ++-- .../petstore/rust-axum/output/apikey-auths/src/apis/mod.rs | 2 +- .../rust-axum/output/apikey-auths/src/apis/payments.rs | 2 +- .../petstore/rust-axum/output/apikey-auths/src/server/mod.rs | 2 +- .../server/petstore/rust-axum/output/multipart-v3/Cargo.toml | 4 ++-- .../rust-axum/output/multipart-v3/src/apis/default.rs | 2 +- .../petstore/rust-axum/output/multipart-v3/src/apis/mod.rs | 2 +- .../petstore/rust-axum/output/multipart-v3/src/server/mod.rs | 2 +- .../server/petstore/rust-axum/output/openapi-v3/Cargo.toml | 4 ++-- .../petstore/rust-axum/output/openapi-v3/src/apis/default.rs | 2 +- .../rust-axum/output/openapi-v3/src/apis/info_repo.rs | 2 +- .../petstore/rust-axum/output/openapi-v3/src/apis/mod.rs | 2 +- .../petstore/rust-axum/output/openapi-v3/src/apis/repo.rs | 2 +- .../petstore/rust-axum/output/openapi-v3/src/server/mod.rs | 2 +- samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml | 4 ++-- .../petstore/rust-axum/output/ops-v3/src/apis/default.rs | 2 +- .../server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs | 2 +- .../server/petstore/rust-axum/output/ops-v3/src/server/mod.rs | 2 +- .../Cargo.toml | 4 ++-- .../src/apis/another_fake.rs | 2 +- .../src/apis/fake.rs | 2 +- .../src/apis/fake_classname_tags123.rs | 2 +- .../src/apis/mod.rs | 2 +- .../src/apis/pet.rs | 2 +- .../src/apis/store.rs | 2 +- .../src/apis/user.rs | 2 +- .../src/server/mod.rs | 2 +- samples/server/petstore/rust-axum/output/petstore/Cargo.toml | 4 ++-- .../server/petstore/rust-axum/output/petstore/src/apis/mod.rs | 2 +- .../server/petstore/rust-axum/output/petstore/src/apis/pet.rs | 2 +- .../petstore/rust-axum/output/petstore/src/apis/store.rs | 2 +- .../petstore/rust-axum/output/petstore/src/apis/user.rs | 2 +- .../petstore/rust-axum/output/petstore/src/server/mod.rs | 2 +- .../petstore/rust-axum/output/ping-bearer-auth/Cargo.toml | 4 ++-- .../rust-axum/output/ping-bearer-auth/src/apis/default.rs | 2 +- .../rust-axum/output/ping-bearer-auth/src/apis/mod.rs | 2 +- .../rust-axum/output/ping-bearer-auth/src/server/mod.rs | 2 +- .../rust-axum/output/rust-axum-header-uuid/Cargo.toml | 4 ++-- .../output/rust-axum-header-uuid/src/apis/default.rs | 2 +- .../rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs | 2 +- .../rust-axum/output/rust-axum-header-uuid/src/server/mod.rs | 2 +- .../petstore/rust-axum/output/rust-axum-oneof/Cargo.toml | 4 ++-- .../rust-axum/output/rust-axum-oneof/src/apis/default.rs | 2 +- .../petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs | 2 +- .../rust-axum/output/rust-axum-oneof/src/server/mod.rs | 2 +- .../petstore/rust-axum/output/rust-axum-test/Cargo.toml | 4 ++-- .../rust-axum/output/rust-axum-test/src/apis/default.rs | 2 +- .../petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs | 2 +- .../rust-axum/output/rust-axum-test/src/server/mod.rs | 2 +- .../rust-axum/output/rust-axum-validation-test/Cargo.toml | 4 ++-- .../output/rust-axum-validation-test/src/apis/default.rs | 2 +- .../output/rust-axum-validation-test/src/apis/mod.rs | 2 +- .../output/rust-axum-validation-test/src/server/mod.rs | 2 +- 57 files changed, 69 insertions(+), 69 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 ba37ecdeb0de..56ad9103f575 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/Cargo.mustache @@ -40,8 +40,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache index 3a75bc1abcdf..122aa90cb976 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache @@ -37,7 +37,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E ) -> Result { diff --git a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache index 7bcb98eb47db..f6f69c1854a3 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/apis.mustache @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache index 6ca3300e4f11..28e323564d51 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-imports.mustache @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 d99bd53b1fe3..9f5dc9ccc8eb 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/apikey-auths/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs index cb001b59d6a1..b411dafe544a 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/mod.rs @@ -33,7 +33,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs index 5bff9b674790..01c97e2874c5 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/apis/payments.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index a55fa2b18bda..c6d0a3b8711f 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 9b19309ec211..14a77bf61a09 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/multipart-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs index 84c0c79e9544..ff1e7b6353d7 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs index be654b5f14ce..189958193a59 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index e098a8c29b08..5deba8406f0c 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 5dd596ed3f60..8ca134992a3b 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/openapi-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs index 65b74d4a39c5..1e7c5186c981 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs index 822576c53466..116f1283534f 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/info_repo.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs index 134b27873bfb..8d27762fd6d9 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/mod.rs @@ -10,7 +10,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs index f3c5c204493d..d66414a5f9ef 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/apis/repo.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index fd17b920227a..f3f500138516 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 b4cb37fab58a..593a385ae810 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/ops-v3/Cargo.toml @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs index f82fc8ea9707..300e1e48e8b5 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs index be654b5f14ce..189958193a59 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs index f1658b2cc69c..c27bd65a859b 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 ea81193f6c5e..bb08b714ed11 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 @@ -20,8 +20,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs index f3a796904b3d..0594b1698397 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/another_fake.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs index 3baac16a6e52..86c3f00a5637 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs index 4987f71681ea..95b565f4203d 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/fake_classname_tags123.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs index a8a2d0c7550d..0b10eed0b611 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/mod.rs @@ -26,7 +26,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs index c7f7c19f1809..62f4fa27b493 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/pet.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs index c53e0608da9c..9ceedb0f32c7 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/store.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs index 1c68461fdf67..bb42e89a031e 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/apis/user.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index a02a906a80d2..32e5a3042783 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; diff --git a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml index 3486b3a99ca2..e2f53672a539 100644 --- a/samples/server/petstore/rust-axum/output/petstore/Cargo.toml +++ b/samples/server/petstore/rust-axum/output/petstore/Cargo.toml @@ -19,8 +19,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs index 2710cd128b63..b3bea180cfde 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/mod.rs @@ -23,7 +23,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs index aedef6a80c77..a3cf82acb948 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/pet.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs index d564986ceaf1..bc8b22fcddc3 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/store.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs index 5bf728968880..91e30ee7637c 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/apis/user.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index 9fba7852109b..8bb552797d28 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 6881b23a29d2..0ef3a0b7a976 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs index d35c79e55408..7e86a4c6713c 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs index be654b5f14ce..189958193a59 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index 579474fa03aa..6cc123686069 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 dc3fc8fbb866..61a1be517f9b 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs index f6a1555ba92c..c2d71af1d828 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs index be654b5f14ce..189958193a59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs index bb933d9d6ce0..4c13730cf906 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 fc3aaa306ddf..6f1c1537e730 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs index bd39840e27c9..dd9fae3277fb 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs index be654b5f14ce..189958193a59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs index 5ebf7f1f7bf1..31e7d18306f7 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 cb26009936a9..e5673ab75676 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs index a4f22925474e..914ccacd9708 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs index be654b5f14ce..189958193a59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index a12cfd64478b..344af2c02581 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; 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 0d1de6020337..f4a38c11157a 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 @@ -18,8 +18,8 @@ conversion = [ [dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["multipart"] } -axum-extra = { version = "0.10", features = ["cookie"] } +axum = "0.7" +axum-extra = { version = "0.9", features = ["cookie", "multipart"] } base64 = "0.22" bytes = "1" chrono = { version = "0.4", features = ["serde"] } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs index 7f26aebebd61..99614283bc48 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/default.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use axum::extract::*; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::Method; use serde::{Deserialize, Serialize}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs index be654b5f14ce..189958193a59 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/apis/mod.rs @@ -8,7 +8,7 @@ pub trait ErrorHandler { async fn handle_error( &self, method: &::http::Method, - host: &axum_extra::extract::Host, + host: &axum::extract::Host, cookies: &axum_extra::extract::CookieJar, error: E, ) -> Result { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs index 4f7e9afac62d..55d30ae25f9b 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use axum::{body::Body, extract::*, response::Response, routing::*}; -use axum_extra::extract::{CookieJar, Host}; +use axum_extra::extract::{CookieJar, Multipart}; use bytes::Bytes; use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; use tracing::error; From 5d3845afc7f075a1db8827e9f8ae2b84d85277ff Mon Sep 17 00:00:00 2001 From: "victoria.casasampere@beethedata.com" Date: Fri, 7 Feb 2025 20:16:43 +0100 Subject: [PATCH 9/9] Forgot paths --- .../languages/RustAxumServerCodegen.java | 2 +- .../output/apikey-auths/src/server/mod.rs | 2 +- .../output/openapi-v3/src/server/mod.rs | 6 ++-- .../src/server/mod.rs | 30 +++++++++---------- .../output/petstore/src/server/mod.rs | 28 ++++++++--------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java index 57cb7d9ddf6e..44fccb193c1d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java @@ -427,7 +427,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation for (CodegenParameter param : op.pathParams) { // Replace {baseName} with {paramName} for format string String paramSearch = "{" + param.baseName + "}"; - String paramReplace = "{" + param.paramName + "}"; + String paramReplace = ":" + param.paramName; axumPath = axumPath.replace(paramSearch, paramReplace); } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index c6d0a3b8711f..46899c5f2539 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -32,7 +32,7 @@ where get(get_payment_methods::), ) .route( - "/v71/paymentMethods/{id}", + "/v71/paymentMethods/:id", get(get_payment_method_by_id::), ) .route("/v71/payments", post(post_make_payment::)) diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index f3f500138516..3cf9e4a70bfa 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -35,7 +35,7 @@ where .route("/complex-query-param", get(complex_query_param_get::) ) - .route("/enum_in_path/{path_param}", + .route("/enum_in_path/:path_param", get(enum_in_path_path_param_get::) ) .route("/form-test", @@ -56,7 +56,7 @@ where .route("/multiget", get(multiget_get::) ) - .route("/multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b}", + .route("/multiple-path-params-with-very-long-path-to-test-formatting/:path_param_a/:path_param_b", get(multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get::) ) .route("/multiple_auth_scheme", @@ -83,7 +83,7 @@ where .route("/repos", post(create_repo::) ) - .route("/repos/{repo_id}", + .route("/repos/:repo_id", get(get_repo_info::).get(get_repo_info::) ) .route("/required_octet_stream", diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 32e5a3042783..9eedd8a6d0b2 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -46,7 +46,7 @@ where put(test_body_with_query_params::), ) .route( - "/v2/fake/hyphenParam/{hyphen_param}", + "/v2/fake/hyphenParam/:hyphen_param", get(hyphen_param::), ) .route( @@ -84,27 +84,33 @@ where post(add_pet::).put(update_pet::), ) .route( - "/v2/pet/findByStatus", - get(find_pets_by_status::), - ) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) - .route( - "/v2/pet/{pet_id}", + "/v2/pet/:pet_id", delete(delete_pet::) .get(get_pet_by_id::) .post(update_pet_with_form::), ) .route( - "/v2/pet/{pet_id}/uploadImage", + "/v2/pet/:pet_id/uploadImage", post(upload_file::), ) + .route( + "/v2/pet/findByStatus", + get(find_pets_by_status::), + ) + .route("/v2/pet/findByTags", get(find_pets_by_tags::)) .route("/v2/store/inventory", get(get_inventory::)) .route("/v2/store/order", post(place_order::)) .route( - "/v2/store/order/{order_id}", + "/v2/store/order/:order_id", delete(delete_order::).get(get_order_by_id::), ) .route("/v2/user", post(create_user::)) + .route( + "/v2/user/:username", + delete(delete_user::) + .get(get_user_by_name::) + .put(update_user::), + ) .route( "/v2/user/createWithArray", post(create_users_with_array_input::), @@ -115,12 +121,6 @@ where ) .route("/v2/user/login", get(login_user::)) .route("/v2/user/logout", get(logout_user::)) - .route( - "/v2/user/{username}", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), - ) .with_state(api_impl) } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index 8bb552797d28..e143adb5f88c 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -33,27 +33,33 @@ where post(add_pet::).put(update_pet::), ) .route( - "/v2/pet/findByStatus", - get(find_pets_by_status::), - ) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) - .route( - "/v2/pet/{pet_id}", + "/v2/pet/:pet_id", delete(delete_pet::) .get(get_pet_by_id::) .post(update_pet_with_form::), ) .route( - "/v2/pet/{pet_id}/uploadImage", + "/v2/pet/:pet_id/uploadImage", post(upload_file::), ) + .route( + "/v2/pet/findByStatus", + get(find_pets_by_status::), + ) + .route("/v2/pet/findByTags", get(find_pets_by_tags::)) .route("/v2/store/inventory", get(get_inventory::)) .route("/v2/store/order", post(place_order::)) .route( - "/v2/store/order/{order_id}", + "/v2/store/order/:order_id", delete(delete_order::).get(get_order_by_id::), ) .route("/v2/user", post(create_user::)) + .route( + "/v2/user/:username", + delete(delete_user::) + .get(get_user_by_name::) + .put(update_user::), + ) .route( "/v2/user/createWithArray", post(create_users_with_array_input::), @@ -64,12 +70,6 @@ where ) .route("/v2/user/login", get(login_user::)) .route("/v2/user/logout", get(logout_user::)) - .route( - "/v2/user/{username}", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), - ) .with_state(api_impl) }