From bb831dad9ab94d7e926ed1c48101660910c9dcfc Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 17 Aug 2024 16:01:11 +0800 Subject: [PATCH] Make the rust hyper client `Send` so it can be used in rust threads more easily (#19375) * Add externCrateName property to rust hyper client This is follows the lead of the rust hyper server generator and provides an externCrateName. This is because the crate name used for importing can be different from the package name, because dashes `-` get converted to underscores `_`. This allows us to write example code in rustdoc that compiles successfully. * Get the rustdoc examples to actually compile * Make rust hyper client thread safe * Fix compile time issue with reqwest client test * Add a test for thread safety * Generate rust hyper samples * Use https for petstore api to fix client tests http://petstore.swagger.io/v2 is 301 redirecting to https://petstore.swagger.io/v2 and this is breaking posts to the API. When the client recieves a redirect it does not resend the POST data, instead it switches to GET. This is in line with how browsers behave when encountering a 301 redirect on a POST request. * Make rust hyper client structs `Sync` too This trait is also helpful in making the api work well with threads. * Use a getCrateName function instead of adding more state * update samples --------- Co-authored-by: Krishna Rajendran --- .../codegen/languages/RustClientCodegen.java | 7 ++++ .../main/resources/rust/hyper/api.mustache | 12 +++--- .../main/resources/rust/hyper/client.mustache | 4 +- .../rust/hyper/configuration.mustache | 14 +++++-- .../src/main/resources/rust/request.rs | 2 +- .../api-with-ref-param/src/apis/client.rs | 4 +- .../src/apis/configuration.rs | 14 +++++-- .../src/apis/default_api.rs | 12 +++--- .../api-with-ref-param/src/apis/request.rs | 2 +- .../hyper/composed-oneof/src/apis/client.rs | 4 +- .../composed-oneof/src/apis/configuration.rs | 14 +++++-- .../composed-oneof/src/apis/default_api.rs | 16 ++++---- .../hyper/composed-oneof/src/apis/request.rs | 2 +- .../rust/hyper/emptyObject/src/apis/client.rs | 4 +- .../emptyObject/src/apis/configuration.rs | 14 +++++-- .../hyper/emptyObject/src/apis/default_api.rs | 12 +++--- .../hyper/emptyObject/src/apis/request.rs | 2 +- .../hyper/oneOf-array-map/src/apis/client.rs | 4 +- .../oneOf-array-map/src/apis/configuration.rs | 14 +++++-- .../oneOf-array-map/src/apis/default_api.rs | 16 ++++---- .../hyper/oneOf-array-map/src/apis/request.rs | 2 +- .../hyper/oneOf-reuseRef/src/apis/client.rs | 4 +- .../oneOf-reuseRef/src/apis/configuration.rs | 14 +++++-- .../oneOf-reuseRef/src/apis/default_api.rs | 12 +++--- .../hyper/oneOf-reuseRef/src/apis/request.rs | 2 +- .../rust/hyper/oneOf/src/apis/bar_api.rs | 12 +++--- .../rust/hyper/oneOf/src/apis/client.rs | 4 +- .../hyper/oneOf/src/apis/configuration.rs | 14 +++++-- .../rust/hyper/oneOf/src/apis/foo_api.rs | 16 ++++---- .../rust/hyper/oneOf/src/apis/request.rs | 2 +- .../rust/hyper/petstore/src/apis/client.rs | 4 +- .../hyper/petstore/src/apis/configuration.rs | 14 +++++-- .../rust/hyper/petstore/src/apis/fake_api.rs | 12 +++--- .../rust/hyper/petstore/src/apis/pet_api.rs | 40 +++++++++---------- .../rust/hyper/petstore/src/apis/request.rs | 2 +- .../rust/hyper/petstore/src/apis/store_api.rs | 24 +++++------ .../hyper/petstore/src/apis/testing_api.rs | 16 ++++---- .../rust/hyper/petstore/src/apis/user_api.rs | 40 +++++++++---------- .../rust/hyper/petstore/tests/thread_test.rs | 17 ++++++++ 39 files changed, 248 insertions(+), 176 deletions(-) create mode 100644 samples/client/petstore/rust/hyper/petstore/tests/thread_test.rs diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index cb880c97541..0b712e34a92 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -55,6 +55,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon @Setter private boolean avoidBoxedModels = false; public static final String PACKAGE_NAME = "packageName"; + public static final String EXTERN_CRATE_NAME = "externCrateName"; public static final String PACKAGE_VERSION = "packageVersion"; public static final String HYPER_LIBRARY = "hyper"; public static final String HYPER0X_LIBRARY = "hyper0x"; @@ -367,6 +368,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); + additionalProperties.put(EXTERN_CRATE_NAME, getExternCrateName()); additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); @@ -423,6 +425,11 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon } + private String getExternCrateName() { + // The external name used when importing a crate has all '-' replaced with '_'. + return packageName.replace('-', '_'); + } + private boolean getSupportAsync() { return supportAsync; } diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache index 7d99ca76c79..ad0410bc9e4 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache @@ -1,5 +1,5 @@ {{>partial_header}} -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -15,22 +15,22 @@ use super::request as __internal_request; pub struct {{{classname}}}Client where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl {{{classname}}}Client where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> {{{classname}}}Client { + pub fn new(configuration: Arc>) -> {{{classname}}}Client { {{{classname}}}Client { configuration, } } } -pub trait {{{classname}}} { +pub trait {{{classname}}}: Send + Sync { {{#operations}} {{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin>>>; + fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin> + Send>>; {{/operation}} {{/operations}} } @@ -40,7 +40,7 @@ impl{{{classname}}} for {{{classname}}}Client {{#operations}} {{#operation}} #[allow(unused_mut)] - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin>>> { + fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod.toUpperCase}}}, "{{{path}}}".to_string()) {{#hasAuthMethods}} {{#authMethods}} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache index 54203d36e4f..d54e33488df 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -21,7 +21,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { {{#apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache index 3581bf0ee32..43a48ff2a44 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache @@ -33,10 +33,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use {{externCrateName}}::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -51,6 +52,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use {{externCrateName}}::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/modules/openapi-generator/src/main/resources/rust/request.rs b/modules/openapi-generator/src/main/resources/rust/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/modules/openapi-generator/src/main/resources/rust/request.rs +++ b/modules/openapi-generator/src/main/resources/rust/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/client.rs b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/client.rs index 0702fb3c752..5554552ee23 100644 --- a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/client.rs +++ b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/client.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -11,7 +11,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())), diff --git a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/configuration.rs b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/configuration.rs index a36bab029a6..ee8e15a6c4d 100644 --- a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/configuration.rs @@ -42,10 +42,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use api_ref_param_hyper::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -60,6 +61,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use api_ref_param_hyper::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/default_api.rs b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/default_api.rs index 03e9e272f45..8d86606eb1c 100644 --- a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/default_api.rs +++ b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/default_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,26 +24,26 @@ use super::request as __internal_request; pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl DefaultApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> DefaultApiClient { + pub fn new(configuration: Arc>) -> DefaultApiClient { DefaultApiClient { configuration, } } } -pub trait DefaultApi { - fn demo_color_get(&self, color: models::Color) -> Pin>>>; +pub trait DefaultApi: Send + Sync { + fn demo_color_get(&self, color: models::Color) -> Pin> + Send>>; } implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn demo_color_get(&self, color: models::Color) -> Pin>>> { + fn demo_color_get(&self, color: models::Color) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/demo/{color}".to_string()) ; req = req.with_path_param("color".to_string(), color.to_string()); diff --git a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/request.rs b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/request.rs +++ b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/others/rust/hyper/composed-oneof/src/apis/client.rs b/samples/client/others/rust/hyper/composed-oneof/src/apis/client.rs index 0702fb3c752..5554552ee23 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/apis/client.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/apis/client.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -11,7 +11,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())), diff --git a/samples/client/others/rust/hyper/composed-oneof/src/apis/configuration.rs b/samples/client/others/rust/hyper/composed-oneof/src/apis/configuration.rs index 8f7d059ecbb..d3dcd988619 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/apis/configuration.rs @@ -42,10 +42,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use composed_oneof_hyper::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -60,6 +61,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use composed_oneof_hyper::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/samples/client/others/rust/hyper/composed-oneof/src/apis/default_api.rs b/samples/client/others/rust/hyper/composed-oneof/src/apis/default_api.rs index 6b8604dd916..fb068549f49 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/apis/default_api.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/apis/default_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,27 +24,27 @@ use super::request as __internal_request; pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl DefaultApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> DefaultApiClient { + pub fn new(configuration: Arc>) -> DefaultApiClient { DefaultApiClient { configuration, } } } -pub trait DefaultApi { - fn create_state(&self, create_state_request: models::CreateStateRequest) -> Pin>>>; - fn get_state(&self, ) -> Pin>>>; +pub trait DefaultApi: Send + Sync { + fn create_state(&self, create_state_request: models::CreateStateRequest) -> Pin> + Send>>; + fn get_state(&self, ) -> Pin> + Send>>; } implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn create_state(&self, create_state_request: models::CreateStateRequest) -> Pin>>> { + fn create_state(&self, create_state_request: models::CreateStateRequest) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/state".to_string()) ; req = req.with_body_param(create_state_request); @@ -54,7 +54,7 @@ implDefaultApi for DefaultApiClient } #[allow(unused_mut)] - fn get_state(&self, ) -> Pin>>> { + fn get_state(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/state".to_string()) ; diff --git a/samples/client/others/rust/hyper/composed-oneof/src/apis/request.rs b/samples/client/others/rust/hyper/composed-oneof/src/apis/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/apis/request.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/apis/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/others/rust/hyper/emptyObject/src/apis/client.rs b/samples/client/others/rust/hyper/emptyObject/src/apis/client.rs index 0702fb3c752..5554552ee23 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/client.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/client.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -11,7 +11,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())), diff --git a/samples/client/others/rust/hyper/emptyObject/src/apis/configuration.rs b/samples/client/others/rust/hyper/emptyObject/src/apis/configuration.rs index 0576e0bfa59..c43936dd19a 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/configuration.rs @@ -42,10 +42,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use empty_object_hyper::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -60,6 +61,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use empty_object_hyper::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/samples/client/others/rust/hyper/emptyObject/src/apis/default_api.rs b/samples/client/others/rust/hyper/emptyObject/src/apis/default_api.rs index b5d0f3e85fb..cc1fc0d583f 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/default_api.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/default_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,26 +24,26 @@ use super::request as __internal_request; pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl DefaultApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> DefaultApiClient { + pub fn new(configuration: Arc>) -> DefaultApiClient { DefaultApiClient { configuration, } } } -pub trait DefaultApi { - fn endpoint_get(&self, ) -> Pin>>>; +pub trait DefaultApi: Send + Sync { + fn endpoint_get(&self, ) -> Pin> + Send>>; } implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn endpoint_get(&self, ) -> Pin>>> { + fn endpoint_get(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/endpoint".to_string()) ; diff --git a/samples/client/others/rust/hyper/emptyObject/src/apis/request.rs b/samples/client/others/rust/hyper/emptyObject/src/apis/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/request.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/client.rs b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/client.rs index 0702fb3c752..5554552ee23 100644 --- a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/client.rs +++ b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/client.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -11,7 +11,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())), diff --git a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/configuration.rs b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/configuration.rs index 14b8ac197b8..2317d8c54d1 100644 --- a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/configuration.rs @@ -42,10 +42,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use oneof_array_map_hyper::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -60,6 +61,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use oneof_array_map_hyper::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/default_api.rs b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/default_api.rs index 219604dba07..ba864fa834f 100644 --- a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/default_api.rs +++ b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/default_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,27 +24,27 @@ use super::request as __internal_request; pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl DefaultApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> DefaultApiClient { + pub fn new(configuration: Arc>) -> DefaultApiClient { DefaultApiClient { configuration, } } } -pub trait DefaultApi { - fn root_get(&self, ) -> Pin>>>; - fn test(&self, body: Option) -> Pin>>>; +pub trait DefaultApi: Send + Sync { + fn root_get(&self, ) -> Pin> + Send>>; + fn test(&self, body: Option) -> Pin> + Send>>; } implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn root_get(&self, ) -> Pin>>> { + fn root_get(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/".to_string()) ; @@ -52,7 +52,7 @@ implDefaultApi for DefaultApiClient } #[allow(unused_mut)] - fn test(&self, body: Option) -> Pin>>> { + fn test(&self, body: Option) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::PUT, "/".to_string()) ; req = req.with_body_param(body); diff --git a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/request.rs b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/request.rs +++ b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/client.rs b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/client.rs index 0702fb3c752..5554552ee23 100644 --- a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/client.rs +++ b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/client.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -11,7 +11,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())), diff --git a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/configuration.rs b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/configuration.rs index 974ec289c31..5a8d201fc02 100644 --- a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/configuration.rs @@ -42,10 +42,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use oneof_reuse_ref_hyper::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -60,6 +61,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use oneof_reuse_ref_hyper::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/default_api.rs b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/default_api.rs index 6d193a52b4e..866bb2606db 100644 --- a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/default_api.rs +++ b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/default_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,26 +24,26 @@ use super::request as __internal_request; pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl DefaultApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> DefaultApiClient { + pub fn new(configuration: Arc>) -> DefaultApiClient { DefaultApiClient { configuration, } } } -pub trait DefaultApi { - fn get_fruit(&self, ) -> Pin>>>; +pub trait DefaultApi: Send + Sync { + fn get_fruit(&self, ) -> Pin> + Send>>; } implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn get_fruit(&self, ) -> Pin>>> { + fn get_fruit(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/example".to_string()) ; diff --git a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/request.rs b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/request.rs +++ b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/others/rust/hyper/oneOf/src/apis/bar_api.rs b/samples/client/others/rust/hyper/oneOf/src/apis/bar_api.rs index f00ea150c31..d70aa52bef2 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/bar_api.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/bar_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,26 +24,26 @@ use super::request as __internal_request; pub struct BarApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl BarApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> BarApiClient { + pub fn new(configuration: Arc>) -> BarApiClient { BarApiClient { configuration, } } } -pub trait BarApi { - fn create_bar(&self, bar_create: models::BarCreate) -> Pin>>>; +pub trait BarApi: Send + Sync { + fn create_bar(&self, bar_create: models::BarCreate) -> Pin> + Send>>; } implBarApi for BarApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn create_bar(&self, bar_create: models::BarCreate) -> Pin>>> { + fn create_bar(&self, bar_create: models::BarCreate) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/bar".to_string()) ; req = req.with_body_param(bar_create); diff --git a/samples/client/others/rust/hyper/oneOf/src/apis/client.rs b/samples/client/others/rust/hyper/oneOf/src/apis/client.rs index d01360bc001..63168b47f5f 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/client.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/client.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -12,7 +12,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { bar_api: Box::new(crate::apis::BarApiClient::new(rc.clone())), diff --git a/samples/client/others/rust/hyper/oneOf/src/apis/configuration.rs b/samples/client/others/rust/hyper/oneOf/src/apis/configuration.rs index 608bb9bca28..fe2facacee4 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/configuration.rs @@ -42,10 +42,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use oneof_hyper::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -60,6 +61,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use oneof_hyper::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/samples/client/others/rust/hyper/oneOf/src/apis/foo_api.rs b/samples/client/others/rust/hyper/oneOf/src/apis/foo_api.rs index fee425fd6e8..94e2007b910 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/foo_api.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/foo_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,27 +24,27 @@ use super::request as __internal_request; pub struct FooApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl FooApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> FooApiClient { + pub fn new(configuration: Arc>) -> FooApiClient { FooApiClient { configuration, } } } -pub trait FooApi { - fn create_foo(&self, foo: Option) -> Pin>>>; - fn get_all_foos(&self, ) -> Pin, Error>>>>; +pub trait FooApi: Send + Sync { + fn create_foo(&self, foo: Option) -> Pin> + Send>>; + fn get_all_foos(&self, ) -> Pin, Error>> + Send>>; } implFooApi for FooApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn create_foo(&self, foo: Option) -> Pin>>> { + fn create_foo(&self, foo: Option) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/foo".to_string()) ; req = req.with_body_param(foo); @@ -53,7 +53,7 @@ implFooApi for FooApiClient } #[allow(unused_mut)] - fn get_all_foos(&self, ) -> Pin, Error>>>> { + fn get_all_foos(&self, ) -> Pin, Error>> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/foo".to_string()) ; diff --git a/samples/client/others/rust/hyper/oneOf/src/apis/request.rs b/samples/client/others/rust/hyper/oneOf/src/apis/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/request.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs index 0847578a83c..cdbaf556cfb 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::sync::Arc; use hyper; use hyper_util::client::legacy::connect::Connect; @@ -15,7 +15,7 @@ pub struct APIClient { impl APIClient { pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { - let rc = Rc::new(configuration); + let rc = Arc::new(configuration); APIClient { fake_api: Box::new(crate::apis::FakeApiClient::new(rc.clone())), diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs index be6df1cd28e..5e23b02c1fc 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs @@ -42,10 +42,11 @@ impl Configuration { /// # Example /// /// ``` - /// let api_config = { - /// api_key: "my-api-key", - /// ...Configuration::new() - /// } + /// # use petstore_hyper::apis::configuration::Configuration; + /// let api_config = Configuration { + /// basic_auth: Some(("user".into(), None)), + /// ..Configuration::new() + /// }; /// ``` pub fn new() -> Configuration { Configuration::default() @@ -60,6 +61,11 @@ impl Configuration /// # Example /// /// ``` + /// # use core::time::Duration; + /// # use petstore_hyper::apis::configuration::Configuration; + /// use hyper_util::client::legacy::Client; + /// use hyper_util::rt::TokioExecutor; + /// /// let client = Client::builder(TokioExecutor::new()) /// .pool_idle_timeout(Duration::from_secs(30)) /// .build_http(); diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs index dcbe3fb669f..80db3f2c9c6 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,26 +24,26 @@ use super::request as __internal_request; pub struct FakeApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl FakeApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> FakeApiClient { + pub fn new(configuration: Arc>) -> FakeApiClient { FakeApiClient { configuration, } } } -pub trait FakeApi { - fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin>>>; +pub trait FakeApi: Send + Sync { + fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin> + Send>>; } implFakeApi for FakeApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin>>> { + fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{username}".to_string()) ; req = req.with_path_param("username".to_string(), username.to_string()); diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs index ecff2f24485..be6a699465c 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,33 +24,33 @@ use super::request as __internal_request; pub struct PetApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl PetApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> PetApiClient { + pub fn new(configuration: Arc>) -> PetApiClient { PetApiClient { configuration, } } } -pub trait PetApi { - fn add_pet(&self, pet: models::Pet) -> Pin>>>; - fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Pin>>>; - fn find_pets_by_status(&self, status: Vec) -> Pin, Error>>>>; - fn find_pets_by_tags(&self, tags: Vec) -> Pin, Error>>>>; - fn get_pet_by_id(&self, pet_id: i64) -> Pin>>>; - fn update_pet(&self, pet: models::Pet) -> Pin>>>; - fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Pin>>>; - fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Pin>>>; +pub trait PetApi: Send + Sync { + fn add_pet(&self, pet: models::Pet) -> Pin> + Send>>; + fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Pin> + Send>>; + fn find_pets_by_status(&self, status: Vec) -> Pin, Error>> + Send>>; + fn find_pets_by_tags(&self, tags: Vec) -> Pin, Error>> + Send>>; + fn get_pet_by_id(&self, pet_id: i64) -> Pin> + Send>>; + fn update_pet(&self, pet: models::Pet) -> Pin> + Send>>; + fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Pin> + Send>>; + fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Pin> + Send>>; } implPetApi for PetApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn add_pet(&self, pet: models::Pet) -> Pin>>> { + fn add_pet(&self, pet: models::Pet) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/pet".to_string()) .with_auth(__internal_request::Auth::Oauth) ; @@ -60,7 +60,7 @@ implPetApi for PetApiClient } #[allow(unused_mut)] - fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Pin>>> { + fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::DELETE, "/pet/{petId}".to_string()) .with_auth(__internal_request::Auth::Oauth) ; @@ -74,7 +74,7 @@ implPetApi for PetApiClient } #[allow(unused_mut)] - fn find_pets_by_status(&self, status: Vec) -> Pin, Error>>>> { + fn find_pets_by_status(&self, status: Vec) -> Pin, Error>> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/pet/findByStatus".to_string()) .with_auth(__internal_request::Auth::Oauth) ; @@ -84,7 +84,7 @@ implPetApi for PetApiClient } #[allow(unused_mut)] - fn find_pets_by_tags(&self, tags: Vec) -> Pin, Error>>>> { + fn find_pets_by_tags(&self, tags: Vec) -> Pin, Error>> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/pet/findByTags".to_string()) .with_auth(__internal_request::Auth::Oauth) ; @@ -94,7 +94,7 @@ implPetApi for PetApiClient } #[allow(unused_mut)] - fn get_pet_by_id(&self, pet_id: i64) -> Pin>>> { + fn get_pet_by_id(&self, pet_id: i64) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/pet/{petId}".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -108,7 +108,7 @@ implPetApi for PetApiClient } #[allow(unused_mut)] - fn update_pet(&self, pet: models::Pet) -> Pin>>> { + fn update_pet(&self, pet: models::Pet) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::PUT, "/pet".to_string()) .with_auth(__internal_request::Auth::Oauth) ; @@ -118,7 +118,7 @@ implPetApi for PetApiClient } #[allow(unused_mut)] - fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Pin>>> { + fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/pet/{petId}".to_string()) .with_auth(__internal_request::Auth::Oauth) ; @@ -135,7 +135,7 @@ implPetApi for PetApiClient } #[allow(unused_mut)] - fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Pin>>> { + fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/pet/{petId}/uploadImage".to_string()) .with_auth(__internal_request::Auth::Oauth) ; diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs index b92c977b726..a6f7b74cc6e 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs @@ -109,7 +109,7 @@ impl Request { pub fn execute<'a, C, U>( self, conf: &configuration::Configuration, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs index 67cbbe4fd4b..df714e9528e 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/store_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,29 +24,29 @@ use super::request as __internal_request; pub struct StoreApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl StoreApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> StoreApiClient { + pub fn new(configuration: Arc>) -> StoreApiClient { StoreApiClient { configuration, } } } -pub trait StoreApi { - fn delete_order(&self, order_id: &str) -> Pin>>>; - fn get_inventory(&self, ) -> Pin, Error>>>>; - fn get_order_by_id(&self, order_id: i64) -> Pin>>>; - fn place_order(&self, order: models::Order) -> Pin>>>; +pub trait StoreApi: Send + Sync { + fn delete_order(&self, order_id: &str) -> Pin> + Send>>; + fn get_inventory(&self, ) -> Pin, Error>> + Send>>; + fn get_order_by_id(&self, order_id: i64) -> Pin> + Send>>; + fn place_order(&self, order: models::Order) -> Pin> + Send>>; } implStoreApi for StoreApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn delete_order(&self, order_id: &str) -> Pin>>> { + fn delete_order(&self, order_id: &str) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::DELETE, "/store/order/{orderId}".to_string()) ; req = req.with_path_param("orderId".to_string(), order_id.to_string()); @@ -56,7 +56,7 @@ implStoreApi for StoreApiClient } #[allow(unused_mut)] - fn get_inventory(&self, ) -> Pin, Error>>>> { + fn get_inventory(&self, ) -> Pin, Error>> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/store/inventory".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -69,7 +69,7 @@ implStoreApi for StoreApiClient } #[allow(unused_mut)] - fn get_order_by_id(&self, order_id: i64) -> Pin>>> { + fn get_order_by_id(&self, order_id: i64) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/store/order/{orderId}".to_string()) ; req = req.with_path_param("orderId".to_string(), order_id.to_string()); @@ -78,7 +78,7 @@ implStoreApi for StoreApiClient } #[allow(unused_mut)] - fn place_order(&self, order: models::Order) -> Pin>>> { + fn place_order(&self, order: models::Order) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/store/order".to_string()) ; req = req.with_body_param(order); diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs index c7444f54f53..fc1876aa030 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,27 +24,27 @@ use super::request as __internal_request; pub struct TestingApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl TestingApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> TestingApiClient { + pub fn new(configuration: Arc>) -> TestingApiClient { TestingApiClient { configuration, } } } -pub trait TestingApi { - fn tests_file_response_get(&self, ) -> Pin>>>; - fn tests_type_testing_get(&self, ) -> Pin>>>; +pub trait TestingApi: Send + Sync { + fn tests_file_response_get(&self, ) -> Pin> + Send>>; + fn tests_type_testing_get(&self, ) -> Pin> + Send>>; } implTestingApi for TestingApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn tests_file_response_get(&self, ) -> Pin>>> { + fn tests_file_response_get(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/fileResponse".to_string()) ; @@ -52,7 +52,7 @@ implTestingApi for TestingApiClient } #[allow(unused_mut)] - fn tests_type_testing_get(&self, ) -> Pin>>> { + fn tests_type_testing_get(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/typeTesting".to_string()) ; diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs index d3ff8e9cda6..174d2ae9ff5 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/user_api.rs @@ -8,7 +8,7 @@ * Generated by: https://openapi-generator.tech */ -use std::rc::Rc; +use std::sync::Arc; use std::borrow::Borrow; use std::pin::Pin; #[allow(unused_imports)] @@ -24,33 +24,33 @@ use super::request as __internal_request; pub struct UserApiClient where C: Clone + std::marker::Send + Sync + 'static { - configuration: Rc>, + configuration: Arc>, } impl UserApiClient where C: Clone + std::marker::Send + Sync { - pub fn new(configuration: Rc>) -> UserApiClient { + pub fn new(configuration: Arc>) -> UserApiClient { UserApiClient { configuration, } } } -pub trait UserApi { - fn create_user(&self, user: models::User) -> Pin>>>; - fn create_users_with_array_input(&self, user: Vec) -> Pin>>>; - fn create_users_with_list_input(&self, user: Vec) -> Pin>>>; - fn delete_user(&self, username: &str) -> Pin>>>; - fn get_user_by_name(&self, username: &str) -> Pin>>>; - fn login_user(&self, username: &str, password: &str) -> Pin>>>; - fn logout_user(&self, ) -> Pin>>>; - fn update_user(&self, username: &str, user: models::User) -> Pin>>>; +pub trait UserApi: Send + Sync { + fn create_user(&self, user: models::User) -> Pin> + Send>>; + fn create_users_with_array_input(&self, user: Vec) -> Pin> + Send>>; + fn create_users_with_list_input(&self, user: Vec) -> Pin> + Send>>; + fn delete_user(&self, username: &str) -> Pin> + Send>>; + fn get_user_by_name(&self, username: &str) -> Pin> + Send>>; + fn login_user(&self, username: &str, password: &str) -> Pin> + Send>>; + fn logout_user(&self, ) -> Pin> + Send>>; + fn update_user(&self, username: &str, user: models::User) -> Pin> + Send>>; } implUserApi for UserApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] - fn create_user(&self, user: models::User) -> Pin>>> { + fn create_user(&self, user: models::User) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/user".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -65,7 +65,7 @@ implUserApi for UserApiClient } #[allow(unused_mut)] - fn create_users_with_array_input(&self, user: Vec) -> Pin>>> { + fn create_users_with_array_input(&self, user: Vec) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/user/createWithArray".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -80,7 +80,7 @@ implUserApi for UserApiClient } #[allow(unused_mut)] - fn create_users_with_list_input(&self, user: Vec) -> Pin>>> { + fn create_users_with_list_input(&self, user: Vec) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::POST, "/user/createWithList".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -95,7 +95,7 @@ implUserApi for UserApiClient } #[allow(unused_mut)] - fn delete_user(&self, username: &str) -> Pin>>> { + fn delete_user(&self, username: &str) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::DELETE, "/user/{username}".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -110,7 +110,7 @@ implUserApi for UserApiClient } #[allow(unused_mut)] - fn get_user_by_name(&self, username: &str) -> Pin>>> { + fn get_user_by_name(&self, username: &str) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/user/{username}".to_string()) ; req = req.with_path_param("username".to_string(), username.to_string()); @@ -119,7 +119,7 @@ implUserApi for UserApiClient } #[allow(unused_mut)] - fn login_user(&self, username: &str, password: &str) -> Pin>>> { + fn login_user(&self, username: &str, password: &str) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/user/login".to_string()) ; req = req.with_query_param("username".to_string(), username.to_string()); @@ -129,7 +129,7 @@ implUserApi for UserApiClient } #[allow(unused_mut)] - fn logout_user(&self, ) -> Pin>>> { + fn logout_user(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/user/logout".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, @@ -143,7 +143,7 @@ implUserApi for UserApiClient } #[allow(unused_mut)] - fn update_user(&self, username: &str, user: models::User) -> Pin>>> { + fn update_user(&self, username: &str, user: models::User) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::PUT, "/user/{username}".to_string()) .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ in_header: true, diff --git a/samples/client/petstore/rust/hyper/petstore/tests/thread_test.rs b/samples/client/petstore/rust/hyper/petstore/tests/thread_test.rs new file mode 100644 index 00000000000..c61cc37b1a0 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/tests/thread_test.rs @@ -0,0 +1,17 @@ +#[cfg(test)] +mod tests { + use petstore_hyper::apis::client::APIClient; + use petstore_hyper::apis::configuration::Configuration; + use std::thread; + + #[test] + fn test_client_is_send_for_threads() { + let client = APIClient::new(Configuration::new()); + + let handle = thread::spawn(move || { + let _ = client.fake_api().test_nullable_required_param("username", None, None); + }); + + handle.join().expect("Thread panicked!"); + } +}