From b705972cade0d2dce04e946a7c2afb4931593321 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 14 Jul 2024 22:11:08 +0800 Subject: [PATCH] Upgrade rust-hyper to use hyper 1.0 (#19115) * Upgrade to rust-hyper to use hyper 1.0 * Update rust-hyper samples for hyper 1.0 upgrade * update cargo * update samples * update samples * update doc * Default client configuration for rust-hyper --------- Co-authored-by: Krishna Rajendran --- bin/configs/rust-hyper0x-petstore.yaml | 8 + docs/generators/rust.md | 2 +- .../codegen/languages/RustClientCodegen.java | 7 +- .../src/main/resources/rust/Cargo.mustache | 7 + .../main/resources/rust/hyper/api.mustache | 7 +- .../resources/rust/hyper/api_mod.mustache | 31 +- .../main/resources/rust/hyper/client.mustache | 3 +- .../rust/hyper/configuration.mustache | 51 ++- .../main/resources/rust/hyper0x/api.mustache | 173 +++++++ .../resources/rust/hyper0x/api_mod.mustache | 64 +++ .../resources/rust/hyper0x/client.mustache | 54 +++ .../rust/hyper0x/configuration.mustache | 34 ++ .../src/main/resources/rust/request.rs | 19 +- samples/client/others/rust/Cargo.lock | 424 ++++++++++++++---- .../rust/hyper/api-with-ref-param/Cargo.toml | 5 +- .../api-with-ref-param/src/apis/client.rs | 3 +- .../src/apis/configuration.rs | 51 ++- .../src/apis/default_api.rs | 7 +- .../hyper/api-with-ref-param/src/apis/mod.rs | 31 +- .../api-with-ref-param/src/apis/request.rs | 19 +- .../rust/hyper/composed-oneof/Cargo.toml | 5 +- .../hyper/composed-oneof/src/apis/client.rs | 3 +- .../composed-oneof/src/apis/configuration.rs | 51 ++- .../composed-oneof/src/apis/default_api.rs | 7 +- .../rust/hyper/composed-oneof/src/apis/mod.rs | 31 +- .../hyper/composed-oneof/src/apis/request.rs | 19 +- .../others/rust/hyper/emptyObject/Cargo.toml | 5 +- .../rust/hyper/emptyObject/src/apis/client.rs | 3 +- .../emptyObject/src/apis/configuration.rs | 51 ++- .../hyper/emptyObject/src/apis/default_api.rs | 7 +- .../rust/hyper/emptyObject/src/apis/mod.rs | 31 +- .../hyper/emptyObject/src/apis/request.rs | 19 +- .../rust/hyper/oneOf-array-map/Cargo.toml | 5 +- .../hyper/oneOf-array-map/src/apis/client.rs | 3 +- .../oneOf-array-map/src/apis/configuration.rs | 51 ++- .../oneOf-array-map/src/apis/default_api.rs | 7 +- .../hyper/oneOf-array-map/src/apis/mod.rs | 31 +- .../hyper/oneOf-array-map/src/apis/request.rs | 19 +- .../rust/hyper/oneOf-reuseRef/Cargo.toml | 5 +- .../hyper/oneOf-reuseRef/src/apis/client.rs | 3 +- .../oneOf-reuseRef/src/apis/configuration.rs | 51 ++- .../oneOf-reuseRef/src/apis/default_api.rs | 7 +- .../rust/hyper/oneOf-reuseRef/src/apis/mod.rs | 31 +- .../hyper/oneOf-reuseRef/src/apis/request.rs | 19 +- .../client/others/rust/hyper/oneOf/Cargo.toml | 5 +- .../rust/hyper/oneOf/src/apis/bar_api.rs | 7 +- .../rust/hyper/oneOf/src/apis/client.rs | 3 +- .../hyper/oneOf/src/apis/configuration.rs | 51 ++- .../rust/hyper/oneOf/src/apis/foo_api.rs | 7 +- .../others/rust/hyper/oneOf/src/apis/mod.rs | 31 +- .../rust/hyper/oneOf/src/apis/request.rs | 19 +- .../petstore/rust/hyper/petstore/Cargo.toml | 5 +- .../rust/hyper/petstore/src/apis/client.rs | 3 +- .../hyper/petstore/src/apis/configuration.rs | 51 ++- .../rust/hyper/petstore/src/apis/fake_api.rs | 7 +- .../rust/hyper/petstore/src/apis/mod.rs | 31 +- .../rust/hyper/petstore/src/apis/pet_api.rs | 7 +- .../rust/hyper/petstore/src/apis/request.rs | 19 +- .../rust/hyper/petstore/src/apis/store_api.rs | 7 +- .../hyper/petstore/src/apis/testing_api.rs | 7 +- .../rust/hyper/petstore/src/apis/user_api.rs | 7 +- .../petstore/rust/hyper0x/petstore/.gitignore | 3 + .../petstore/.openapi-generator-ignore | 23 + .../hyper0x/petstore/.openapi-generator/FILES | 53 +++ .../petstore/.openapi-generator/VERSION | 1 + .../rust/hyper0x/petstore/.travis.yml | 1 + .../petstore/rust/hyper0x/petstore/Cargo.toml | 19 + .../petstore/rust/hyper0x/petstore/README.md | 84 ++++ .../hyper0x/petstore/docs/ActionContainer.md | 11 + .../rust/hyper0x/petstore/docs/ApiResponse.md | 13 + .../hyper0x/petstore/docs/ArrayItemRefTest.md | 12 + .../rust/hyper0x/petstore/docs/Baz.md | 14 + .../rust/hyper0x/petstore/docs/Category.md | 12 + .../hyper0x/petstore/docs/EnumArrayTesting.md | 11 + .../rust/hyper0x/petstore/docs/FakeApi.md | 41 ++ .../hyper0x/petstore/docs/NullableArray.md | 14 + .../hyper0x/petstore/docs/OptionalTesting.md | 14 + .../rust/hyper0x/petstore/docs/Order.md | 16 + .../rust/hyper0x/petstore/docs/Pet.md | 16 + .../rust/hyper0x/petstore/docs/PetApi.md | 261 +++++++++++ .../hyper0x/petstore/docs/PropertyTest.md | 11 + .../rust/hyper0x/petstore/docs/Ref.md | 11 + .../rust/hyper0x/petstore/docs/Return.md | 13 + .../rust/hyper0x/petstore/docs/StoreApi.md | 129 ++++++ .../rust/hyper0x/petstore/docs/Tag.md | 12 + .../rust/hyper0x/petstore/docs/TestingApi.md | 60 +++ .../rust/hyper0x/petstore/docs/TypeTesting.md | 18 + .../petstore/docs/UniqueItemArrayTesting.md | 11 + .../rust/hyper0x/petstore/docs/User.md | 18 + .../rust/hyper0x/petstore/docs/UserApi.md | 255 +++++++++++ .../rust/hyper0x/petstore/git_push.sh | 57 +++ .../petstore/src/apis/configuration.rs | 43 ++ .../hyper0x/petstore/src/apis/fake_api.rs | 61 +++ .../rust/hyper0x/petstore/src/apis/mod.rs | 62 +++ .../rust/hyper0x/petstore/src/apis/pet_api.rs | 152 +++++++ .../hyper0x/petstore/src/apis/store_api.rs | 88 ++++ .../hyper0x/petstore/src/apis/testing_api.rs | 61 +++ .../hyper0x/petstore/src/apis/user_api.rs | 160 +++++++ .../petstore/rust/hyper0x/petstore/src/lib.rs | 11 + .../petstore/src/models/action_container.rs | 27 ++ .../petstore/src/models/api_response.rs | 35 ++ .../src/models/array_item_ref_test.rs | 32 ++ .../rust/hyper0x/petstore/src/models/baz.rs | 42 ++ .../hyper0x/petstore/src/models/category.rs | 32 ++ .../petstore/src/models/enum_array_testing.rs | 45 ++ .../rust/hyper0x/petstore/src/models/mod.rs | 34 ++ .../hyper0x/petstore/src/models/model_ref.rs | 29 ++ .../petstore/src/models/model_return.rs | 35 ++ .../petstore/src/models/nullable_array.rs | 36 ++ .../petstore/src/models/optional_testing.rs | 38 ++ .../rust/hyper0x/petstore/src/models/order.rs | 61 +++ .../rust/hyper0x/petstore/src/models/pet.rs | 61 +++ .../petstore/src/models/property_test.rs | 29 ++ .../rust/hyper0x/petstore/src/models/tag.rs | 32 ++ .../petstore/src/models/type_testing.rs | 54 +++ .../src/models/unique_item_array_testing.rs | 46 ++ .../rust/hyper0x/petstore/src/models/user.rs | 51 +++ 117 files changed, 4019 insertions(+), 283 deletions(-) create mode 100644 bin/configs/rust-hyper0x-petstore.yaml create mode 100644 modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache create mode 100644 modules/openapi-generator/src/main/resources/rust/hyper0x/api_mod.mustache create mode 100644 modules/openapi-generator/src/main/resources/rust/hyper0x/client.mustache create mode 100644 modules/openapi-generator/src/main/resources/rust/hyper0x/configuration.mustache create mode 100644 samples/client/petstore/rust/hyper0x/petstore/.gitignore create mode 100644 samples/client/petstore/rust/hyper0x/petstore/.openapi-generator-ignore create mode 100644 samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES create mode 100644 samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/VERSION create mode 100644 samples/client/petstore/rust/hyper0x/petstore/.travis.yml create mode 100644 samples/client/petstore/rust/hyper0x/petstore/Cargo.toml create mode 100644 samples/client/petstore/rust/hyper0x/petstore/README.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/ActionContainer.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/ApiResponse.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/Baz.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/Category.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/FakeApi.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/NullableArray.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/OptionalTesting.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/Order.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/Ref.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/Return.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/StoreApi.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/Tag.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/User.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/docs/UserApi.md create mode 100644 samples/client/petstore/rust/hyper0x/petstore/git_push.sh create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/apis/configuration.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/apis/mod.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/apis/store_api.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/apis/user_api.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/lib.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/action_container.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/api_response.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/array_item_ref_test.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/baz.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/category.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/enum_array_testing.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/model_ref.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/model_return.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/nullable_array.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/optional_testing.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/pet.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/property_test.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/tag.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs create mode 100644 samples/client/petstore/rust/hyper0x/petstore/src/models/user.rs diff --git a/bin/configs/rust-hyper0x-petstore.yaml b/bin/configs/rust-hyper0x-petstore.yaml new file mode 100644 index 00000000000..adaf9b7e373 --- /dev/null +++ b/bin/configs/rust-hyper0x-petstore.yaml @@ -0,0 +1,8 @@ +generatorName: rust +outputDir: samples/client/petstore/rust/hyper0x/petstore +library: hyper0x +inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/rust +additionalProperties: + supportAsync: "false" + packageName: petstore-hyper0x diff --git a/docs/generators/rust.md b/docs/generators/rust.md index 5da5f95b342..1b4ff6f400d 100644 --- a/docs/generators/rust.md +++ b/docs/generators/rust.md @@ -22,7 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |bestFitInt|Use best fitting integer type where minimum or maximum is set| |false| |enumNameSuffix|Suffix that will be appended to all enum names.| || |hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true| -|library|library template (sub-template) to use.|
**hyper**
HTTP client: Hyper.
**reqwest**
HTTP client: Reqwest.
|reqwest| +|library|library template (sub-template) to use.|
**hyper**
HTTP client: Hyper (v1.x).
**hyper0x**
HTTP client: Hyper (v0.x).
**reqwest**
HTTP client: Reqwest.
|reqwest| |packageName|Rust package name (convention: lowercase).| |openapi| |packageVersion|Rust package version.| |1.0.0| |preferUnsignedInt|Prefer unsigned integers where minimum value is >= 0| |false| 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 9dd063204be..cb880c97541 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 @@ -57,6 +57,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon public static final String PACKAGE_NAME = "packageName"; public static final String PACKAGE_VERSION = "packageVersion"; public static final String HYPER_LIBRARY = "hyper"; + public static final String HYPER0X_LIBRARY = "hyper0x"; public static final String REQWEST_LIBRARY = "reqwest"; public static final String SUPPORT_ASYNC = "supportAsync"; public static final String SUPPORT_MIDDLEWARE = "supportMiddleware"; @@ -202,7 +203,8 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon cliOptions.add(new CliOption(AVOID_BOXED_MODELS, "If set, `Box` will not be used for models", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); - supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper."); + supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper (v1.x)."); + supportedLibraries.put(HYPER0X_LIBRARY, "HTTP client: Hyper (v0.x)."); supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest."); CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use."); @@ -371,6 +373,9 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon if (HYPER_LIBRARY.equals(getLibrary())) { additionalProperties.put(HYPER_LIBRARY, "true"); + } else if (HYPER0X_LIBRARY.equals(getLibrary())) { + additionalProperties.put(HYPER_LIBRARY, "true"); + additionalProperties.put(HYPER0X_LIBRARY, "true"); } else if (REQWEST_LIBRARY.equals(getLibrary())) { additionalProperties.put(REQWEST_LIBRARY, "true"); } else { diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache index 7b4e15d2505..239b1a8474e 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -40,8 +40,15 @@ serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } {{#hyper}} +{{#hyper0x}} hyper = { version = "~0.14", features = ["full"] } hyper-tls = "~0.5" +{{/hyper0x}} +{{^hyper0x}} +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } +{{/hyper0x}} http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 f59705ea7b7..7d99ca76c79 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache @@ -6,18 +6,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct {{{classname}}}Client +pub struct {{{classname}}}Client where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl {{{classname}}}Client +impl {{{classname}}}Client where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> {{{classname}}}Client { {{{classname}}}Client { @@ -34,7 +35,7 @@ pub trait {{{classname}}} { {{/operations}} } -impl{{{classname}}} for {{{classname}}}Client +impl{{{classname}}} for {{{classname}}}Client where C: Clone + std::marker::Send + Sync { {{#operations}} {{#operation}} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/api_mod.mustache index 51a42ef361a..67baa441cea 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/api_mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/api_mod.mustache @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 25124d94b36..54203d36e4f 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache @@ -1,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -18,7 +19,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 ee6f407d31b..3581bf0ee32 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache @@ -1,11 +1,15 @@ {{>partial_header}} use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -19,9 +23,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "{{{basePath}}}".to_owned(), user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, @@ -32,3 +68,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache new file mode 100644 index 00000000000..f59705ea7b7 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache @@ -0,0 +1,173 @@ +{{>partial_header}} +use std::rc::Rc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct {{{classname}}}Client + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Rc>, +} + +impl {{{classname}}}Client + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Rc>) -> {{{classname}}}Client { + {{{classname}}}Client { + configuration, + } + } +} + +pub trait {{{classname}}} { +{{#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>>>; +{{/operation}} +{{/operations}} +} + +impl{{{classname}}} for {{{classname}}}Client + where C: Clone + std::marker::Send + Sync { + {{#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>>> { + let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod.toUpperCase}}}, "{{{path}}}".to_string()) + {{#hasAuthMethods}} + {{#authMethods}} + {{#isApiKey}} + .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ + in_header: {{#isKeyInHeader}}true{{/isKeyInHeader}}{{^isKeyInHeader}}false{{/isKeyInHeader}}, + in_query: {{#isKeyInQuery}}true{{/isKeyInQuery}}{{^isKeyInQuery}}false{{/isKeyInQuery}}, + param_name: "{{{keyParamName}}}".to_owned(), + })) + {{/isApiKey}} + {{#isBasicBasic}} + .with_auth(__internal_request::Auth::Basic) + {{/isBasicBasic}} + {{#isOAuth}} + .with_auth(__internal_request::Auth::Oauth) + {{/isOAuth}} + {{/authMethods}} + {{/hasAuthMethods}} + ; + {{#queryParams}} + {{#required}} + {{^isNullable}} + req = req.with_query_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); + {{/isNullable}} + {{#isNullable}} + match {{{paramName}}} { + Some(param_value) => { req = req.with_query_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, + None => { req = req.with_query_param("{{{baseName}}}".to_string(), "".to_string()); }, + } + {{/isNullable}} + {{/required}} + {{^required}} + if let Some(ref s) = {{{paramName}}} { + let query_value = {{#isArray}}s.iter().map(|s| s.to_string()).collect::>().join(","){{/isArray}}{{^isArray}}s.to_string(){{/isArray}}; + req = req.with_query_param("{{{baseName}}}".to_string(), query_value); + } + {{/required}} + {{/queryParams}} + {{#pathParams}} + {{#required}} + {{^isNullable}} + req = req.with_path_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); + {{/isNullable}} + {{#isNullable}} + match {{{paramName}}} { + Some(param_value) => { req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, + None => { req = req.with_path_param("{{{baseName}}}".to_string(), "".to_string()); }, + } + {{/isNullable}} + {{/required}} + {{^required}} + if let Some(param_value) = {{{paramName}}} { + req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); + } + {{/required}} + {{/pathParams}} + {{#hasHeaderParams}} + {{#headerParams}} + {{#required}} + {{^isNullable}} + req = req.with_header_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); + {{/isNullable}} + {{#isNullable}} + match {{{paramName}}} { + Some(param_value) => { req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, + None => { req = req.with_header_param("{{{baseName}}}".to_string(), "".to_string()); }, + } + {{/isNullable}} + {{/required}} + {{^required}} + if let Some(param_value) = {{{paramName}}} { + req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); + } + {{/required}} + {{/headerParams}} + {{/hasHeaderParams}} + {{#hasFormParams}} + {{#formParams}} + {{#isFile}} + {{#required}} + {{^isNullable}} + req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); + {{/isNullable}} + {{#isNullable}} + match {{{paramName}}} { + Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, + None => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, + } + {{/isNullable}} + {{/required}} + {{^required}} + if let Some(param_value) = {{{paramName}}} { + req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); + } + {{/required}} + {{/isFile}} + {{^isFile}} + {{#required}} + {{^isNullable}} + req = req.with_form_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); + {{/isNullable}} + {{#isNullable}} + match {{{paramName}}} { + Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, + None => { req = req.with_form_param("{{{baseName}}}".to_string(), "".to_string()); }, + } + {{/isNullable}} + {{/required}} + {{^required}} + if let Some(param_value) = {{{paramName}}} { + req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); + } + {{/required}} + {{/isFile}} + {{/formParams}} + {{/hasFormParams}} + {{#hasBodyParam}} + {{#bodyParams}} + req = req.with_body_param({{{paramName}}}); + {{/bodyParams}} + {{/hasBodyParam}} + {{^returnType}} + req = req.returns_nothing(); + {{/returnType}} + + req.execute(self.configuration.borrow()) + } + +{{/operation}} +{{/operations}} +} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper0x/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/hyper0x/api_mod.mustache new file mode 100644 index 00000000000..51a42ef361a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/rust/hyper0x/api_mod.mustache @@ -0,0 +1,64 @@ +use http; +use hyper; +use serde_json; + +#[derive(Debug)] +pub enum Error { + Api(ApiError), + Header(hyper::http::header::InvalidHeaderValue), + Http(http::Error), + Hyper(hyper::Error), + Serde(serde_json::Error), + UriError(http::uri::InvalidUri), +} + +#[derive(Debug)] +pub struct ApiError { + pub code: hyper::StatusCode, + pub body: hyper::body::Body, +} + +impl From<(hyper::StatusCode, hyper::body::Body)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { + Error::Api(ApiError { + code: e.0, + body: e.1, + }) + } +} + +impl From for Error { + fn from(e: http::Error) -> Self { + Error::Http(e) + } +} + +impl From for Error { + fn from(e: hyper::Error) -> Self { + Error::Hyper(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +mod request; + +{{#apiInfo}} +{{#apis}} +mod {{{classFilename}}}; +{{#operations}} +{{#operation}} +{{#-last}} +pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client }; +{{/-last}} +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} + +pub mod configuration; +pub mod client; diff --git a/modules/openapi-generator/src/main/resources/rust/hyper0x/client.mustache b/modules/openapi-generator/src/main/resources/rust/hyper0x/client.mustache new file mode 100644 index 00000000000..25124d94b36 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/rust/hyper0x/client.mustache @@ -0,0 +1,54 @@ +use std::rc::Rc; + +use hyper; +use super::configuration::Configuration; + +pub struct APIClient { +{{#apiInfo}} +{{#apis}} +{{#operations}} +{{#operation}} + {{#-last}} + {{{classFilename}}}: Box, + {{/-last}} +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} +} + +impl APIClient { + pub fn new(configuration: Configuration) -> APIClient + where C: Clone + std::marker::Send + Sync + 'static { + let rc = Rc::new(configuration); + + APIClient { +{{#apiInfo}} +{{#apis}} +{{#operations}} +{{#operation}} + {{#-last}} + {{{classFilename}}}: Box::new(crate::apis::{{{classname}}}Client::new(rc.clone())), + {{/-last}} +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} + } + } + +{{#apiInfo}} +{{#apis}} +{{#operations}} +{{#operation}} +{{#-last}} + pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classname}}}{ + self.{{{classFilename}}}.as_ref() + } + +{{/-last}} +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} +} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper0x/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/hyper0x/configuration.mustache new file mode 100644 index 00000000000..ee6f407d31b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/rust/hyper0x/configuration.mustache @@ -0,0 +1,34 @@ +{{>partial_header}} +use hyper; + +pub struct Configuration + where C: Clone + std::marker::Send + Sync + 'static { + pub base_path: String, + pub user_agent: Option, + pub client: hyper::client::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration + where C: Clone + std::marker::Send + Sync { + pub fn new(client: hyper::client::Client) -> Configuration { + Configuration { + base_path: "{{{basePath}}}".to_owned(), + user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, + client, + basic_auth: None, + oauth_access_token: None, + api_key: None, + } + } +} diff --git a/modules/openapi-generator/src/main/resources/rust/request.rs b/modules/openapi-generator/src/main/resources/rust/request.rs index db4d55e47b1..b92c977b726 100644 --- a/modules/openapi-generator/src/main/resources/rust/request.rs +++ b/modules/openapi-generator/src/main/resources/rust/request.rs @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } diff --git a/samples/client/others/rust/Cargo.lock b/samples/client/others/rust/Cargo.lock index 3505b332dae..706f45503fa 100644 --- a/samples/client/others/rust/Cargo.lock +++ b/samples/client/others/rust/Cargo.lock @@ -23,11 +23,11 @@ version = "0.0.0" dependencies = [ "base64 0.7.0", "futures", - "http", + "http 0.2.11", + "http-body-util", "hyper", - "hyper-tls", + "hyper-util", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -39,12 +39,17 @@ version = "0.0.0" dependencies = [ "reqwest", "serde", - "serde_derive", "serde_json", "url", "uuid", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.1.0" @@ -78,9 +83,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" @@ -108,9 +113,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "5208975e568d83b6b05cc0a063c8e7e9acc2b43bee6da15616a5b73e109d7437" [[package]] name = "cfg-if" @@ -124,11 +129,11 @@ version = "1.0.0" dependencies = [ "base64 0.7.0", "futures", - "http", + "http 0.2.11", + "http-body-util", "hyper", - "hyper-tls", + "hyper-util", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -140,7 +145,6 @@ version = "1.0.0" dependencies = [ "reqwest", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -168,11 +172,11 @@ version = "1.0.0" dependencies = [ "base64 0.7.0", "futures", - "http", + "http 0.2.11", + "http-body-util", "hyper", - "hyper-tls", + "hyper-util", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -184,7 +188,6 @@ version = "1.0.0" dependencies = [ "reqwest", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -258,9 +261,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -373,16 +376,16 @@ checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "h2" -version = "0.3.24" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", - "http", + "http 1.1.0", "indexmap", "slab", "tokio", @@ -414,13 +417,36 @@ dependencies = [ ] [[package]] -name = "http-body" -version = "0.4.6" +name = "http" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", - "http", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body", "pin-project-lite", ] @@ -438,46 +464,83 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.28" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", "h2", - "http", + "http 1.1.0", "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", - "socket2", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", + "http-body-util", "hyper", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -542,9 +605,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linux-raw-sys" @@ -618,16 +681,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.31.1" @@ -649,11 +702,11 @@ version = "0.0.1" dependencies = [ "base64 0.7.0", "futures", - "http", + "http 0.2.11", + "http-body-util", "hyper", - "hyper-tls", + "hyper-util", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -665,7 +718,6 @@ version = "0.0.1" dependencies = [ "reqwest", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -677,11 +729,11 @@ version = "0.0.1" dependencies = [ "base64 0.7.0", "futures", - "http", + "http 0.2.11", + "http-body-util", "hyper", - "hyper-tls", + "hyper-util", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -693,7 +745,6 @@ version = "0.0.1" dependencies = [ "reqwest", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -705,11 +756,11 @@ version = "1.0.0" dependencies = [ "base64 0.7.0", "futures", - "http", + "http 0.2.11", + "http-body-util", "hyper", - "hyper-tls", + "hyper-util", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -721,7 +772,6 @@ version = "1.0.0" dependencies = [ "reqwest", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -773,9 +823,29 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "pin-project-lite" @@ -828,7 +898,6 @@ version = "0.1.0" dependencies = [ "reqwest", "serde", - "serde_derive", "serde_json", "url", "uuid", @@ -836,20 +905,24 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.24" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bytes", "encoding_rs", + "futures-channel", "futures-core", "futures-util", "h2", - "http", + "http 1.1.0", "http-body", + "http-body-util", "hyper", + "hyper-rustls", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -875,6 +948,21 @@ dependencies = [ "winreg", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -896,12 +984,43 @@ dependencies = [ ] [[package]] -name = "rustls-pemfile" -version = "1.0.4" +name = "rustls" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ - "base64 0.21.7", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.1", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + +[[package]] +name = "rustls-webpki" +version = "0.102.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -953,6 +1072,9 @@ name = "serde" version = "1.0.173" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91f70896d6720bc714a4a57d22fc91f1db634680e65c8efe13323f1fa38d53f" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" @@ -997,6 +1119,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "socket2" version = "0.5.4" @@ -1007,6 +1135,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.26" @@ -1020,9 +1160,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "system-configuration" @@ -1083,7 +1223,6 @@ dependencies = [ "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "windows-sys 0.48.0", @@ -1099,6 +1238,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -1113,6 +1263,27 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + [[package]] name = "tower-service" version = "0.3.2" @@ -1175,10 +1346,16 @@ dependencies = [ ] [[package]] -name = "url" -version = "2.4.0" +name = "untrusted" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1187,9 +1364,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.4.1" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "getrandom", "serde", @@ -1331,6 +1508,15 @@ dependencies = [ "windows-targets 0.48.0", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -1361,6 +1547,22 @@ dependencies = [ "windows_x86_64_msvc 0.48.0", ] +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -1373,6 +1575,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -1385,6 +1593,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -1397,6 +1611,18 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -1409,6 +1635,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -1421,6 +1653,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -1433,6 +1671,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -1446,11 +1690,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] -name = "winreg" -version = "0.50.0" +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", "windows-sys 0.48.0", ] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/samples/client/others/rust/hyper/api-with-ref-param/Cargo.toml b/samples/client/others/rust/hyper/api-with-ref-param/Cargo.toml index bbf7d006f49..dee5baf694f 100644 --- a/samples/client/others/rust/hyper/api-with-ref-param/Cargo.toml +++ b/samples/client/others/rust/hyper/api-with-ref-param/Cargo.toml @@ -12,8 +12,9 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -hyper = { version = "~0.14", features = ["full"] } -hyper-tls = "~0.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 021112f848c..0702fb3c752 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,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -8,7 +9,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 bc8b7d53f16..a36bab029a6 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 @@ -9,12 +9,16 @@ */ use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -28,9 +32,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "http://localhost".to_owned(), user_agent: Some("OpenAPI-Generator/0.0.0/rust".to_owned()), @@ -41,3 +77,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} 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 fc935532992..03e9e272f45 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct DefaultApiClient +pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl DefaultApiClient +impl DefaultApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> DefaultApiClient { DefaultApiClient { @@ -39,7 +40,7 @@ pub trait DefaultApi { fn demo_color_get(&self, color: models::Color) -> Pin>>>; } -implDefaultApi for DefaultApiClient +implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn demo_color_get(&self, color: models::Color) -> Pin>>> { diff --git a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/mod.rs b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/mod.rs index 4d85ccfc475..58227e44cb3 100644 --- a/samples/client/others/rust/hyper/api-with-ref-param/src/apis/mod.rs +++ b/samples/client/others/rust/hyper/api-with-ref-param/src/apis/mod.rs @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 db4d55e47b1..b92c977b726 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 @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } diff --git a/samples/client/others/rust/hyper/composed-oneof/Cargo.toml b/samples/client/others/rust/hyper/composed-oneof/Cargo.toml index c91777db137..596638d25ac 100644 --- a/samples/client/others/rust/hyper/composed-oneof/Cargo.toml +++ b/samples/client/others/rust/hyper/composed-oneof/Cargo.toml @@ -12,8 +12,9 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -hyper = { version = "~0.14", features = ["full"] } -hyper-tls = "~0.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 021112f848c..0702fb3c752 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,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -8,7 +9,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 22d9ed18fd9..8f7d059ecbb 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 @@ -9,12 +9,16 @@ */ use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -28,9 +32,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "http://localhost:8000".to_owned(), user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), @@ -41,3 +77,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} 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 3db27d7c1bc..6b8604dd916 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct DefaultApiClient +pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl DefaultApiClient +impl DefaultApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> DefaultApiClient { DefaultApiClient { @@ -40,7 +41,7 @@ pub trait DefaultApi { fn get_state(&self, ) -> Pin>>>; } -implDefaultApi for DefaultApiClient +implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn create_state(&self, create_state_request: models::CreateStateRequest) -> Pin>>> { diff --git a/samples/client/others/rust/hyper/composed-oneof/src/apis/mod.rs b/samples/client/others/rust/hyper/composed-oneof/src/apis/mod.rs index 4d85ccfc475..58227e44cb3 100644 --- a/samples/client/others/rust/hyper/composed-oneof/src/apis/mod.rs +++ b/samples/client/others/rust/hyper/composed-oneof/src/apis/mod.rs @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 db4d55e47b1..b92c977b726 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 @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } diff --git a/samples/client/others/rust/hyper/emptyObject/Cargo.toml b/samples/client/others/rust/hyper/emptyObject/Cargo.toml index 7e570fe7056..240ccddee96 100644 --- a/samples/client/others/rust/hyper/emptyObject/Cargo.toml +++ b/samples/client/others/rust/hyper/emptyObject/Cargo.toml @@ -12,8 +12,9 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -hyper = { version = "~0.14", features = ["full"] } -hyper-tls = "~0.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 021112f848c..0702fb3c752 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/client.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/client.rs @@ -1,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -8,7 +9,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 565960de859..0576e0bfa59 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/configuration.rs @@ -9,12 +9,16 @@ */ use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -28,9 +32,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "http://localhost".to_owned(), user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), @@ -41,3 +77,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} 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 1ad9fa3768e..b5d0f3e85fb 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct DefaultApiClient +pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl DefaultApiClient +impl DefaultApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> DefaultApiClient { DefaultApiClient { @@ -39,7 +40,7 @@ pub trait DefaultApi { fn endpoint_get(&self, ) -> Pin>>>; } -implDefaultApi for DefaultApiClient +implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn endpoint_get(&self, ) -> Pin>>> { diff --git a/samples/client/others/rust/hyper/emptyObject/src/apis/mod.rs b/samples/client/others/rust/hyper/emptyObject/src/apis/mod.rs index 4d85ccfc475..58227e44cb3 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/mod.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/mod.rs @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 db4d55e47b1..b92c977b726 100644 --- a/samples/client/others/rust/hyper/emptyObject/src/apis/request.rs +++ b/samples/client/others/rust/hyper/emptyObject/src/apis/request.rs @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } diff --git a/samples/client/others/rust/hyper/oneOf-array-map/Cargo.toml b/samples/client/others/rust/hyper/oneOf-array-map/Cargo.toml index 7e1c7960f6d..9209f8063af 100644 --- a/samples/client/others/rust/hyper/oneOf-array-map/Cargo.toml +++ b/samples/client/others/rust/hyper/oneOf-array-map/Cargo.toml @@ -12,8 +12,9 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -hyper = { version = "~0.14", features = ["full"] } -hyper-tls = "~0.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 021112f848c..0702fb3c752 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,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -8,7 +9,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 4a2bb63cbef..14b8ac197b8 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 @@ -9,12 +9,16 @@ */ use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -28,9 +32,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "http://localhost".to_owned(), user_agent: Some("OpenAPI-Generator/0.0.1/rust".to_owned()), @@ -41,3 +77,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} 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 90082edd0ee..219604dba07 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct DefaultApiClient +pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl DefaultApiClient +impl DefaultApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> DefaultApiClient { DefaultApiClient { @@ -40,7 +41,7 @@ pub trait DefaultApi { fn test(&self, body: Option) -> Pin>>>; } -implDefaultApi for DefaultApiClient +implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn root_get(&self, ) -> Pin>>> { diff --git a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/mod.rs b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/mod.rs index 4d85ccfc475..58227e44cb3 100644 --- a/samples/client/others/rust/hyper/oneOf-array-map/src/apis/mod.rs +++ b/samples/client/others/rust/hyper/oneOf-array-map/src/apis/mod.rs @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 db4d55e47b1..b92c977b726 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 @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } diff --git a/samples/client/others/rust/hyper/oneOf-reuseRef/Cargo.toml b/samples/client/others/rust/hyper/oneOf-reuseRef/Cargo.toml index 6ff45ef734e..167cd6a0ae5 100644 --- a/samples/client/others/rust/hyper/oneOf-reuseRef/Cargo.toml +++ b/samples/client/others/rust/hyper/oneOf-reuseRef/Cargo.toml @@ -11,8 +11,9 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -hyper = { version = "~0.14", features = ["full"] } -hyper-tls = "~0.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 021112f848c..0702fb3c752 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,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -8,7 +9,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 fdbc91ffdf0..974ec289c31 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 @@ -9,12 +9,16 @@ */ use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -28,9 +32,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "http://api.example.xyz/v1".to_owned(), user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), @@ -41,3 +77,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} 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 9e2ede9bb93..6d193a52b4e 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct DefaultApiClient +pub struct DefaultApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl DefaultApiClient +impl DefaultApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> DefaultApiClient { DefaultApiClient { @@ -39,7 +40,7 @@ pub trait DefaultApi { fn get_fruit(&self, ) -> Pin>>>; } -implDefaultApi for DefaultApiClient +implDefaultApi for DefaultApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn get_fruit(&self, ) -> Pin>>> { diff --git a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/mod.rs b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/mod.rs index 4d85ccfc475..58227e44cb3 100644 --- a/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/mod.rs +++ b/samples/client/others/rust/hyper/oneOf-reuseRef/src/apis/mod.rs @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 db4d55e47b1..b92c977b726 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 @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } diff --git a/samples/client/others/rust/hyper/oneOf/Cargo.toml b/samples/client/others/rust/hyper/oneOf/Cargo.toml index 647e2769394..82e821be70e 100644 --- a/samples/client/others/rust/hyper/oneOf/Cargo.toml +++ b/samples/client/others/rust/hyper/oneOf/Cargo.toml @@ -12,8 +12,9 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -hyper = { version = "~0.14", features = ["full"] } -hyper-tls = "~0.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 588e9451b9e..f00ea150c31 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct BarApiClient +pub struct BarApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl BarApiClient +impl BarApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> BarApiClient { BarApiClient { @@ -39,7 +40,7 @@ pub trait BarApi { fn create_bar(&self, bar_create: models::BarCreate) -> Pin>>>; } -implBarApi for BarApiClient +implBarApi for BarApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn create_bar(&self, bar_create: models::BarCreate) -> Pin>>> { 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 50a8c070c15..d01360bc001 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/client.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/client.rs @@ -1,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -9,7 +10,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 ceb9b776914..608bb9bca28 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/configuration.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/configuration.rs @@ -9,12 +9,16 @@ */ use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -28,9 +32,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "http://localhost:8080".to_owned(), user_agent: Some("OpenAPI-Generator/0.0.1/rust".to_owned()), @@ -41,3 +77,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} 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 95cc653a9cd..fee425fd6e8 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct FooApiClient +pub struct FooApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl FooApiClient +impl FooApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> FooApiClient { FooApiClient { @@ -40,7 +41,7 @@ pub trait FooApi { fn get_all_foos(&self, ) -> Pin, Error>>>>; } -implFooApi for FooApiClient +implFooApi for FooApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn create_foo(&self, foo: Option) -> Pin>>> { diff --git a/samples/client/others/rust/hyper/oneOf/src/apis/mod.rs b/samples/client/others/rust/hyper/oneOf/src/apis/mod.rs index 288eec40a0e..69fded9b6dc 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/mod.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/mod.rs @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 db4d55e47b1..b92c977b726 100644 --- a/samples/client/others/rust/hyper/oneOf/src/apis/request.rs +++ b/samples/client/others/rust/hyper/oneOf/src/apis/request.rs @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } diff --git a/samples/client/petstore/rust/hyper/petstore/Cargo.toml b/samples/client/petstore/rust/hyper/petstore/Cargo.toml index d8b82608d37..3f243da8d4b 100644 --- a/samples/client/petstore/rust/hyper/petstore/Cargo.toml +++ b/samples/client/petstore/rust/hyper/petstore/Cargo.toml @@ -12,8 +12,9 @@ serde_with = { version = "^3.8", default-features = false, features = ["base64", serde_json = "^1.0" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } -hyper = { version = "~0.14", features = ["full"] } -hyper-tls = "~0.5" +hyper = { version = "^1.3.1", features = ["full"] } +hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } +http-body-util = { version = "0.1.2" } http = "~0.2" base64 = "~0.7.0" futures = "^0.3" 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 c38f01cdc55..0847578a83c 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/client.rs @@ -1,6 +1,7 @@ use std::rc::Rc; use hyper; +use hyper_util::client::legacy::connect::Connect; use super::configuration::Configuration; pub struct APIClient { @@ -12,7 +13,7 @@ pub struct APIClient { } impl APIClient { - pub fn new(configuration: Configuration) -> APIClient + pub fn new(configuration: Configuration) -> APIClient where C: Clone + std::marker::Send + Sync + 'static { let rc = Rc::new(configuration); 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 ae41a752976..be6df1cd28e 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/configuration.rs @@ -9,12 +9,16 @@ */ use hyper; +use hyper_util::client::legacy::Client; +use hyper_util::client::legacy::connect::Connect; +use hyper_util::client::legacy::connect::HttpConnector; +use hyper_util::rt::TokioExecutor; -pub struct Configuration +pub struct Configuration where C: Clone + std::marker::Send + Sync + 'static { pub base_path: String, pub user_agent: Option, - pub client: hyper::client::Client, + pub client: Client, pub basic_auth: Option, pub oauth_access_token: Option, pub api_key: Option, @@ -28,9 +32,41 @@ pub struct ApiKey { pub key: String, } -impl Configuration +impl Configuration { + /// Construct a default [`Configuration`](Self) with a hyper client using a default + /// [`HttpConnector`](hyper_util::client::legacy::connect::HttpConnector). + /// + /// Use [`with_client`](Configuration::with_client) to construct a Configuration with a + /// custom hyper client. + /// + /// # Example + /// + /// ``` + /// let api_config = { + /// api_key: "my-api-key", + /// ...Configuration::new() + /// } + /// ``` + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Configuration where C: Clone + std::marker::Send + Sync { - pub fn new(client: hyper::client::Client) -> Configuration { + + /// Construct a new Configuration with a custom hyper client. + /// + /// # Example + /// + /// ``` + /// let client = Client::builder(TokioExecutor::new()) + /// .pool_idle_timeout(Duration::from_secs(30)) + /// .build_http(); + /// + /// let api_config = Configuration::with_client(client); + /// ``` + pub fn with_client(client: Client) -> Configuration { Configuration { base_path: "http://petstore.swagger.io/v2".to_owned(), user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), @@ -41,3 +77,10 @@ impl Configuration } } } + +impl Default for Configuration { + fn default() -> Self { + let client = Client::builder(TokioExecutor::new()).build_http(); + Configuration::with_client(client) + } +} 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 685b7262fff..dcbe3fb669f 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct FakeApiClient +pub struct FakeApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl FakeApiClient +impl FakeApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> FakeApiClient { FakeApiClient { @@ -39,7 +40,7 @@ pub trait FakeApi { fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin>>>; } -implFakeApi for FakeApiClient +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>>> { diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs index df848ad3c6b..888d6b88236 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/mod.rs @@ -1,25 +1,38 @@ -use http; +use std::fmt; +use std::fmt::Debug; + use hyper; +use hyper::http; +use hyper_util::client::legacy::connect::Connect; use serde_json; #[derive(Debug)] pub enum Error { Api(ApiError), - Header(hyper::http::header::InvalidHeaderValue), + Header(http::header::InvalidHeaderValue), Http(http::Error), Hyper(hyper::Error), + HyperClient(hyper_util::client::legacy::Error), Serde(serde_json::Error), UriError(http::uri::InvalidUri), } -#[derive(Debug)] pub struct ApiError { pub code: hyper::StatusCode, - pub body: hyper::body::Body, + pub body: hyper::body::Incoming, } -impl From<(hyper::StatusCode, hyper::body::Body)> for Error { - fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { +impl Debug for ApiError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ApiError") + .field("code", &self.code) + .field("body", &"hyper::body::Incoming") + .finish() + } +} + +impl From<(hyper::StatusCode, hyper::body::Incoming)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Incoming)) -> Self { Error::Api(ApiError { code: e.0, body: e.1, @@ -33,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: hyper_util::client::legacy::Error) -> Self { + Error::HyperClient(e) + } +} + impl From for Error { fn from(e: hyper::Error) -> Self { Error::Hyper(e) 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 a81f1291681..ecff2f24485 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct PetApiClient +pub struct PetApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl PetApiClient +impl PetApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> PetApiClient { PetApiClient { @@ -46,7 +47,7 @@ pub trait PetApi { fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Pin>>>; } -implPetApi for PetApiClient +implPetApi for PetApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn add_pet(&self, pet: models::Pet) -> Pin>>> { 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 db4d55e47b1..b92c977b726 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs @@ -4,7 +4,9 @@ use std::pin::Pin; use futures; use futures::Future; use futures::future::*; +use http_body_util::BodyExt; use hyper; +use hyper_util::client::legacy::connect::Connect; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT}; use serde; use serde_json; @@ -109,7 +111,7 @@ impl Request { conf: &configuration::Configuration, ) -> Pin> + 'a>> where - C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync, + C: Connect + Clone + std::marker::Send + Sync, U: Sized + std::marker::Send + 'a, for<'de> U: serde::Deserialize<'de>, { @@ -203,13 +205,13 @@ impl Request { for (k, v) in self.form_params { enc.append_pair(&k, &v); } - req_builder.body(hyper::Body::from(enc.finish())) + req_builder.body(enc.finish()) } else if let Some(body) = self.serialized_body { req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); req_headers.insert(CONTENT_LENGTH, body.len().into()); - req_builder.body(hyper::Body::from(body)) + req_builder.body(body) } else { - req_builder.body(hyper::Body::default()) + req_builder.body(String::new()) }; let request = match request_result { Ok(request) => request, @@ -233,9 +235,12 @@ impl Request { // need to impl default for all models. futures::future::ok::(serde_json::from_str("null").expect("serde null value")).boxed() } else { - hyper::body::to_bytes(response.into_body()) - .map(|bytes| serde_json::from_slice(&bytes.unwrap())) - .map_err(|e| Error::from(e)).boxed() + let collect = response.into_body().collect().map_err(Error::from); + collect.map(|collected| { + collected.and_then(|collected| { + serde_json::from_slice(&collected.to_bytes()).map_err(Error::from) + }) + }).boxed() } })) } 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 d1984b9e698..67cbbe4fd4b 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct StoreApiClient +pub struct StoreApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl StoreApiClient +impl StoreApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> StoreApiClient { StoreApiClient { @@ -42,7 +43,7 @@ pub trait StoreApi { fn place_order(&self, order: models::Order) -> Pin>>>; } -implStoreApi for StoreApiClient +implStoreApi for StoreApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn delete_order(&self, order_id: &str) -> Pin>>> { 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 a7df972d733..c7444f54f53 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct TestingApiClient +pub struct TestingApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl TestingApiClient +impl TestingApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> TestingApiClient { TestingApiClient { @@ -40,7 +41,7 @@ pub trait TestingApi { fn tests_type_testing_get(&self, ) -> Pin>>>; } -implTestingApi for TestingApiClient +implTestingApi for TestingApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn tests_file_response_get(&self, ) -> Pin>>> { 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 3511933ac8b..d3ff8e9cda6 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 @@ -15,18 +15,19 @@ use std::pin::Pin; use std::option::Option; use hyper; +use hyper_util::client::legacy::connect::Connect; use futures::Future; use crate::models; use super::{Error, configuration}; use super::request as __internal_request; -pub struct UserApiClient +pub struct UserApiClient where C: Clone + std::marker::Send + Sync + 'static { configuration: Rc>, } -impl UserApiClient +impl UserApiClient where C: Clone + std::marker::Send + Sync { pub fn new(configuration: Rc>) -> UserApiClient { UserApiClient { @@ -46,7 +47,7 @@ pub trait UserApi { fn update_user(&self, username: &str, user: models::User) -> Pin>>>; } -implUserApi for UserApiClient +implUserApi for UserApiClient where C: Clone + std::marker::Send + Sync { #[allow(unused_mut)] fn create_user(&self, user: models::User) -> Pin>>> { diff --git a/samples/client/petstore/rust/hyper0x/petstore/.gitignore b/samples/client/petstore/rust/hyper0x/petstore/.gitignore new file mode 100644 index 00000000000..6aa106405a4 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator-ignore b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES new file mode 100644 index 00000000000..bcfaf169317 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES @@ -0,0 +1,53 @@ +.gitignore +.travis.yml +Cargo.toml +README.md +docs/ActionContainer.md +docs/ApiResponse.md +docs/ArrayItemRefTest.md +docs/Baz.md +docs/Category.md +docs/EnumArrayTesting.md +docs/FakeApi.md +docs/NullableArray.md +docs/OptionalTesting.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/PropertyTest.md +docs/Ref.md +docs/Return.md +docs/StoreApi.md +docs/Tag.md +docs/TestingApi.md +docs/TypeTesting.md +docs/UniqueItemArrayTesting.md +docs/User.md +docs/UserApi.md +git_push.sh +src/apis/configuration.rs +src/apis/fake_api.rs +src/apis/mod.rs +src/apis/pet_api.rs +src/apis/store_api.rs +src/apis/testing_api.rs +src/apis/user_api.rs +src/lib.rs +src/models/action_container.rs +src/models/api_response.rs +src/models/array_item_ref_test.rs +src/models/baz.rs +src/models/category.rs +src/models/enum_array_testing.rs +src/models/mod.rs +src/models/model_ref.rs +src/models/model_return.rs +src/models/nullable_array.rs +src/models/optional_testing.rs +src/models/order.rs +src/models/pet.rs +src/models/property_test.rs +src/models/tag.rs +src/models/type_testing.rs +src/models/unique_item_array_testing.rs +src/models/user.rs diff --git a/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/client/petstore/rust/hyper0x/petstore/.travis.yml b/samples/client/petstore/rust/hyper0x/petstore/.travis.yml new file mode 100644 index 00000000000..22761ba7ee1 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/hyper0x/petstore/Cargo.toml b/samples/client/petstore/rust/hyper0x/petstore/Cargo.toml new file mode 100644 index 00000000000..1d9fe70961c --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "petstore-hyper0x" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] +description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters." +license = "Apache-2.0" +edition = "2021" + +[dependencies] +serde = { version = "^1.0", features = ["derive"] } +serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] } +serde_json = "^1.0" +url = "^2.5" +uuid = { version = "^1.8", features = ["serde", "v4"] } +hyper = { version = "~0.14", features = ["full"] } +hyper-tls = "~0.5" +http = "~0.2" +base64 = "~0.7.0" +futures = "^0.3" diff --git a/samples/client/petstore/rust/hyper0x/petstore/README.md b/samples/client/petstore/rust/hyper0x/petstore/README.md new file mode 100644 index 00000000000..b7f95f0a85c --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/README.md @@ -0,0 +1,84 @@ +# Rust API client for petstore-hyper0x + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.8.0-SNAPSHOT +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `petstore-hyper0x` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +petstore-hyper0x = { path = "./petstore-hyper0x" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [ActionContainer](docs/ActionContainer.md) + - [ApiResponse](docs/ApiResponse.md) + - [ArrayItemRefTest](docs/ArrayItemRefTest.md) + - [Baz](docs/Baz.md) + - [Category](docs/Category.md) + - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [NullableArray](docs/NullableArray.md) + - [OptionalTesting](docs/OptionalTesting.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [PropertyTest](docs/PropertyTest.md) + - [Ref](docs/Ref.md) + - [Return](docs/Return.md) + - [Tag](docs/Tag.md) + - [TypeTesting](docs/TypeTesting.md) + - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) + - [User](docs/User.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/ActionContainer.md b/samples/client/petstore/rust/hyper0x/petstore/docs/ActionContainer.md new file mode 100644 index 00000000000..4e0a0ba4961 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/ActionContainer.md @@ -0,0 +1,11 @@ +# ActionContainer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**action** | [**models::Baz**](Baz.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/ApiResponse.md b/samples/client/petstore/rust/hyper0x/petstore/docs/ApiResponse.md new file mode 100644 index 00000000000..b5125ba685b --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/ApiResponse.md @@ -0,0 +1,13 @@ +# ApiResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | Option<**i32**> | | [optional] +**r#type** | Option<**String**> | | [optional] +**message** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md new file mode 100644 index 00000000000..616deda7c4b --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md @@ -0,0 +1,12 @@ +# ArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](Vec.md) | | +**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Baz.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Baz.md new file mode 100644 index 00000000000..e9c4c693d89 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Baz.md @@ -0,0 +1,14 @@ +# Baz + +## Enum Variants + +| Name | Value | +|---- | -----| +| A | A | +| B | B | +| Empty | | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Category.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Category.md new file mode 100644 index 00000000000..1cf67347c05 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Category.md @@ -0,0 +1,12 @@ +# Category + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**name** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md new file mode 100644 index 00000000000..fb4c54df47d --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md @@ -0,0 +1,11 @@ +# EnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/FakeApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/FakeApi.md new file mode 100644 index 00000000000..55bf612aa21 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/FakeApi.md @@ -0,0 +1,41 @@ +# \FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{username} | To test nullable required parameters + + + +## test_nullable_required_param + +> test_nullable_required_param(username, dummy_required_nullable_param, uppercase) +To test nullable required parameters + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] | +**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] | +**uppercase** | Option<**String**> | To test parameter names in upper case | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/NullableArray.md b/samples/client/petstore/rust/hyper0x/petstore/docs/NullableArray.md new file mode 100644 index 00000000000..3b4aaa9668f --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/NullableArray.md @@ -0,0 +1,14 @@ +# NullableArray + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_nullable** | Option<**Vec**> | | [optional] +**just_array** | Option<**Vec**> | | [optional] +**nullable_string** | Option<**String**> | | [optional] +**just_string** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/OptionalTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/OptionalTesting.md new file mode 100644 index 00000000000..029e38eb977 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/OptionalTesting.md @@ -0,0 +1,14 @@ +# OptionalTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**optional_nonnull** | Option<**String**> | | [optional] +**required_nonnull** | **String** | | +**optional_nullable** | Option<**String**> | | [optional] +**required_nullable** | Option<**String**> | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md new file mode 100644 index 00000000000..d9a09c39743 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md @@ -0,0 +1,16 @@ +# Order + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**pet_id** | Option<**i64**> | | [optional] +**quantity** | Option<**i32**> | | [optional] +**ship_date** | Option<**String**> | | [optional] +**status** | Option<**String**> | Order Status | [optional] +**complete** | Option<**bool**> | | [optional][default to false] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md new file mode 100644 index 00000000000..e7a72caa16e --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md @@ -0,0 +1,16 @@ +# Pet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**category** | Option<[**models::Category**](Category.md)> | | [optional] +**name** | **String** | | +**photo_urls** | **Vec** | | +**tags** | Option<[**Vec**](Tag.md)> | | [optional] +**status** | Option<**String**> | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md new file mode 100644 index 00000000000..d503facb903 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md @@ -0,0 +1,261 @@ +# \PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +## add_pet + +> models::Pet add_pet(pet) +Add a new pet to the store + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] | + +### Return type + +[**models::Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_pet + +> delete_pet(pet_id, api_key) +Deletes a pet + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | Pet id to delete | [required] | +**api_key** | Option<**String**> | | | + +### Return type + + (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## find_pets_by_status + +> Vec find_pets_by_status(status) +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | [**Vec**](String.md) | Status values that need to be considered for filter | [required] | + +### Return type + +[**Vec**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## find_pets_by_tags + +> Vec find_pets_by_tags(tags) +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**tags** | [**Vec**](String.md) | Tags to filter by | [required] | + +### Return type + +[**Vec**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_pet_by_id + +> models::Pet get_pet_by_id(pet_id) +Find pet by ID + +Returns a single pet + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet to return | [required] | + +### Return type + +[**models::Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_pet + +> models::Pet update_pet(pet) +Update an existing pet + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] | + +### Return type + +[**models::Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_pet_with_form + +> update_pet_with_form(pet_id, name, status) +Updates a pet in the store with form data + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet that needs to be updated | [required] | +**name** | Option<**String**> | Updated name of the pet | | +**status** | Option<**String**> | Updated status of the pet | | + +### Return type + + (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## upload_file + +> models::ApiResponse upload_file(pet_id, additional_metadata, file) +uploads an image + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet to update | [required] | +**additional_metadata** | Option<**String**> | Additional data to pass to server | | +**file** | Option<**std::path::PathBuf**> | file to upload | | + +### Return type + +[**models::ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md b/samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md new file mode 100644 index 00000000000..3f36c163de0 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md @@ -0,0 +1,11 @@ +# PropertyTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Ref.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Ref.md new file mode 100644 index 00000000000..04f9d0aa55a --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Ref.md @@ -0,0 +1,11 @@ +# Ref + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dummy** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Return.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Return.md new file mode 100644 index 00000000000..04710a019db --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Return.md @@ -0,0 +1,13 @@ +# Return + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#match** | Option<**i32**> | | [optional] +**r#async** | Option<**bool**> | | [optional] +**param_super** | Option<**bool**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/StoreApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/StoreApi.md new file mode 100644 index 00000000000..a513dfa1b5f --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/StoreApi.md @@ -0,0 +1,129 @@ +# \StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + + +## delete_order + +> delete_order(order_id) +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **String** | ID of the order that needs to be deleted | [required] | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_inventory + +> std::collections::HashMap get_inventory() +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**std::collections::HashMap** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_order_by_id + +> models::Order get_order_by_id(order_id) +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **i64** | ID of pet that needs to be fetched | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## place_order + +> models::Order place_order(order) +Place an order for a pet + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order** | [**Order**](Order.md) | order placed for purchasing the pet | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Tag.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Tag.md new file mode 100644 index 00000000000..7bf71ab0e9d --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Tag.md @@ -0,0 +1,12 @@ +# Tag + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**name** | Option<**String**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md new file mode 100644 index 00000000000..9c26af24912 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md @@ -0,0 +1,60 @@ +# \TestingApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## tests_type_testing_get + +> models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md new file mode 100644 index 00000000000..4f650eb1aa2 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md @@ -0,0 +1,18 @@ +# TypeTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**int32** | **i32** | | +**int64** | **i64** | | +**float** | **f32** | | +**double** | **f64** | | +**string** | **String** | | +**boolean** | **bool** | | +**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**bytes** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md new file mode 100644 index 00000000000..6e103e2bb28 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md @@ -0,0 +1,11 @@ +# UniqueItemArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**unique_item_array** | **Vec** | Helper object for the unique item array test | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/User.md b/samples/client/petstore/rust/hyper0x/petstore/docs/User.md new file mode 100644 index 00000000000..19d813622ed --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/User.md @@ -0,0 +1,18 @@ +# User + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**username** | **String** | | +**first_name** | Option<**String**> | | [optional] +**last_name** | **String** | | +**email** | Option<**String**> | | [optional] +**password** | Option<**String**> | | [optional] +**phone** | Option<**String**> | | [optional] +**user_status** | Option<**i32**> | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/UserApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/UserApi.md new file mode 100644 index 00000000000..d536057ae15 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/UserApi.md @@ -0,0 +1,255 @@ +# \UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + + +## create_user + +> create_user(user) +Create user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user** | [**User**](User.md) | Created user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_users_with_array_input + +> create_users_with_array_input(user) +Creates list of users with given input array + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user** | [**Vec**](User.md) | List of user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_users_with_list_input + +> create_users_with_list_input(user) +Creates list of users with given input array + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user** | [**Vec**](User.md) | List of user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_user + +> delete_user(username) +Delete user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be deleted | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_user_by_name + +> models::User get_user_by_name(username) +Get user by user name + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] | + +### Return type + +[**models::User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## login_user + +> String login_user(username, password) +Logs user into the system + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The user name for login | [required] | +**password** | **String** | The password for login in clear text | [required] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## logout_user + +> logout_user() +Logs out current logged in user session + + + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_user + +> update_user(username, user) +Updated user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | name that need to be deleted | [required] | +**user** | [**User**](User.md) | Updated user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/hyper0x/petstore/git_push.sh b/samples/client/petstore/rust/hyper0x/petstore/git_push.sh new file mode 100644 index 00000000000..f53a75d4fab --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/configuration.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/configuration.rs new file mode 100644 index 00000000000..ae41a752976 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/configuration.rs @@ -0,0 +1,43 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use hyper; + +pub struct Configuration + where C: Clone + std::marker::Send + Sync + 'static { + pub base_path: String, + pub user_agent: Option, + pub client: hyper::client::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +impl Configuration + where C: Clone + std::marker::Send + Sync { + pub fn new(client: hyper::client::Client) -> Configuration { + Configuration { + base_path: "http://petstore.swagger.io/v2".to_owned(), + user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), + client, + basic_auth: None, + oauth_access_token: None, + api_key: None, + } + } +} diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs new file mode 100644 index 00000000000..685b7262fff --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use std::rc::Rc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct FakeApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Rc>, +} + +impl FakeApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Rc>) -> FakeApiClient { + FakeApiClient { + configuration, + } + } +} + +pub trait FakeApi { + fn test_nullable_required_param(&self, username: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>) -> Pin>>>; +} + +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>>> { + 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()); + match dummy_required_nullable_param { + Some(param_value) => { req = req.with_header_param("dummy_required_nullable_param".to_string(), param_value.to_string()); }, + None => { req = req.with_header_param("dummy_required_nullable_param".to_string(), "".to_string()); }, + } + if let Some(param_value) = uppercase { + req = req.with_header_param("UPPERCASE".to_string(), param_value.to_string()); + } + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + +} diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/mod.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/mod.rs new file mode 100644 index 00000000000..df848ad3c6b --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/mod.rs @@ -0,0 +1,62 @@ +use http; +use hyper; +use serde_json; + +#[derive(Debug)] +pub enum Error { + Api(ApiError), + Header(hyper::http::header::InvalidHeaderValue), + Http(http::Error), + Hyper(hyper::Error), + Serde(serde_json::Error), + UriError(http::uri::InvalidUri), +} + +#[derive(Debug)] +pub struct ApiError { + pub code: hyper::StatusCode, + pub body: hyper::body::Body, +} + +impl From<(hyper::StatusCode, hyper::body::Body)> for Error { + fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self { + Error::Api(ApiError { + code: e.0, + body: e.1, + }) + } +} + +impl From for Error { + fn from(e: http::Error) -> Self { + Error::Http(e) + } +} + +impl From for Error { + fn from(e: hyper::Error) -> Self { + Error::Hyper(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +mod request; + +mod fake_api; +pub use self::fake_api::{ FakeApi, FakeApiClient }; +mod pet_api; +pub use self::pet_api::{ PetApi, PetApiClient }; +mod store_api; +pub use self::store_api::{ StoreApi, StoreApiClient }; +mod testing_api; +pub use self::testing_api::{ TestingApi, TestingApiClient }; +mod user_api; +pub use self::user_api::{ UserApi, UserApiClient }; + +pub mod configuration; +pub mod client; diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs new file mode 100644 index 00000000000..a81f1291681 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs @@ -0,0 +1,152 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use std::rc::Rc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct PetApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Rc>, +} + +impl PetApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Rc>) -> 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>>>; +} + +implPetApi for PetApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn add_pet(&self, pet: models::Pet) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/pet".to_string()) + .with_auth(__internal_request::Auth::Oauth) + ; + req = req.with_body_param(pet); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::DELETE, "/pet/{petId}".to_string()) + .with_auth(__internal_request::Auth::Oauth) + ; + req = req.with_path_param("petId".to_string(), pet_id.to_string()); + if let Some(param_value) = api_key { + req = req.with_header_param("api_key".to_string(), param_value.to_string()); + } + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn find_pets_by_status(&self, status: Vec) -> Pin, Error>>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/pet/findByStatus".to_string()) + .with_auth(__internal_request::Auth::Oauth) + ; + req = req.with_query_param("status".to_string(), status.join(",").to_string()); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn find_pets_by_tags(&self, tags: Vec) -> Pin, Error>>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/pet/findByTags".to_string()) + .with_auth(__internal_request::Auth::Oauth) + ; + req = req.with_query_param("tags".to_string(), tags.join(",").to_string()); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn get_pet_by_id(&self, pet_id: i64) -> Pin>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + req = req.with_path_param("petId".to_string(), pet_id.to_string()); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn update_pet(&self, pet: models::Pet) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::PUT, "/pet".to_string()) + .with_auth(__internal_request::Auth::Oauth) + ; + req = req.with_body_param(pet); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn update_pet_with_form(&self, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/pet/{petId}".to_string()) + .with_auth(__internal_request::Auth::Oauth) + ; + req = req.with_path_param("petId".to_string(), pet_id.to_string()); + if let Some(param_value) = name { + req = req.with_form_param("name".to_string(), param_value.to_string()); + } + if let Some(param_value) = status { + req = req.with_form_param("status".to_string(), param_value.to_string()); + } + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn upload_file(&self, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/pet/{petId}/uploadImage".to_string()) + .with_auth(__internal_request::Auth::Oauth) + ; + req = req.with_path_param("petId".to_string(), pet_id.to_string()); + if let Some(param_value) = additional_metadata { + req = req.with_form_param("additionalMetadata".to_string(), param_value.to_string()); + } + if let Some(param_value) = file { + req = req.with_form_param("file".to_string(), unimplemented!()); + } + + req.execute(self.configuration.borrow()) + } + +} diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/store_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/store_api.rs new file mode 100644 index 00000000000..d1984b9e698 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/store_api.rs @@ -0,0 +1,88 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use std::rc::Rc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct StoreApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Rc>, +} + +impl StoreApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Rc>) -> 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>>>; +} + +implStoreApi for StoreApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn delete_order(&self, order_id: &str) -> Pin>>> { + 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()); + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn get_inventory(&self, ) -> Pin, Error>>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn get_order_by_id(&self, order_id: i64) -> Pin>>> { + 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()); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn place_order(&self, order: models::Order) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/store/order".to_string()) + ; + req = req.with_body_param(order); + + req.execute(self.configuration.borrow()) + } + +} diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs new file mode 100644 index 00000000000..a7df972d733 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use std::rc::Rc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct TestingApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Rc>, +} + +impl TestingApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Rc>) -> TestingApiClient { + TestingApiClient { + configuration, + } + } +} + +pub trait TestingApi { + fn tests_file_response_get(&self, ) -> Pin>>>; + fn tests_type_testing_get(&self, ) -> Pin>>>; +} + +implTestingApi for TestingApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn tests_file_response_get(&self, ) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/fileResponse".to_string()) + ; + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn tests_type_testing_get(&self, ) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/typeTesting".to_string()) + ; + + req.execute(self.configuration.borrow()) + } + +} diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/user_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/user_api.rs new file mode 100644 index 00000000000..3511933ac8b --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/user_api.rs @@ -0,0 +1,160 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use std::rc::Rc; +use std::borrow::Borrow; +use std::pin::Pin; +#[allow(unused_imports)] +use std::option::Option; + +use hyper; +use futures::Future; + +use crate::models; +use super::{Error, configuration}; +use super::request as __internal_request; + +pub struct UserApiClient + where C: Clone + std::marker::Send + Sync + 'static { + configuration: Rc>, +} + +impl UserApiClient + where C: Clone + std::marker::Send + Sync { + pub fn new(configuration: Rc>) -> 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>>>; +} + +implUserApi for UserApiClient + where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn create_user(&self, user: models::User) -> Pin>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + req = req.with_body_param(user); + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn create_users_with_array_input(&self, user: Vec) -> Pin>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + req = req.with_body_param(user); + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn create_users_with_list_input(&self, user: Vec) -> Pin>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + req = req.with_body_param(user); + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn delete_user(&self, username: &str) -> Pin>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + req = req.with_path_param("username".to_string(), username.to_string()); + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn get_user_by_name(&self, username: &str) -> Pin>>> { + 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()); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn login_user(&self, username: &str, password: &str) -> Pin>>> { + 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()); + req = req.with_query_param("password".to_string(), password.to_string()); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn logout_user(&self, ) -> Pin>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn update_user(&self, username: &str, user: models::User) -> Pin>>> { + 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, + in_query: false, + param_name: "api_key".to_owned(), + })) + ; + req = req.with_path_param("username".to_string(), username.to_string()); + req = req.with_body_param(user); + req = req.returns_nothing(); + + req.execute(self.configuration.borrow()) + } + +} diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/lib.rs b/samples/client/petstore/rust/hyper0x/petstore/src/lib.rs new file mode 100644 index 00000000000..1de74d07cff --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate hyper; +extern crate futures; + +pub mod apis; +pub mod models; diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/action_container.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/action_container.rs new file mode 100644 index 00000000000..11d2f0b8712 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/action_container.rs @@ -0,0 +1,27 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ActionContainer { + #[serde(rename = "action")] + pub action: Box, +} + +impl ActionContainer { + pub fn new(action: models::Baz) -> ActionContainer { + ActionContainer { + action: Box::new(action), + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/api_response.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/api_response.rs new file mode 100644 index 00000000000..0a60da0f477 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/api_response.rs @@ -0,0 +1,35 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ApiResponse : Describes the result of uploading an image resource +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ApiResponse { + #[serde(rename = "code", skip_serializing_if = "Option::is_none")] + pub code: Option, + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl ApiResponse { + /// Describes the result of uploading an image resource + pub fn new() -> ApiResponse { + ApiResponse { + code: None, + r#type: None, + message: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/array_item_ref_test.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/array_item_ref_test.rs new file mode 100644 index 00000000000..4ac1e8a2fe9 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/array_item_ref_test.rs @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ArrayItemRefTest : Test handling of object reference in arrays +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ArrayItemRefTest { + #[serde(rename = "list_with_array_ref")] + pub list_with_array_ref: Vec>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec>, +} + +impl ArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec>) -> ArrayItemRefTest { + ArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/baz.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/baz.rs new file mode 100644 index 00000000000..17b42c0bd4f --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/baz.rs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Baz : Test handling of empty variants +/// Test handling of empty variants +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Baz { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "")] + Empty, + +} + +impl std::fmt::Display for Baz { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::A => write!(f, "A"), + Self::B => write!(f, "B"), + Self::Empty => write!(f, ""), + } + } +} + +impl Default for Baz { + fn default() -> Baz { + Self::A + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/category.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/category.rs new file mode 100644 index 00000000000..9ecf89d354d --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/category.rs @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Category : A category for a pet +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Category { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl Category { + /// A category for a pet + pub fn new() -> Category { + Category { + id: None, + name: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/enum_array_testing.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/enum_array_testing.rs new file mode 100644 index 00000000000..2ac40c30775 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/enum_array_testing.rs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// EnumArrayTesting : Test of enum array +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct EnumArrayTesting { + #[serde(rename = "required_enums")] + pub required_enums: Vec, +} + +impl EnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> EnumArrayTesting { + EnumArrayTesting { + required_enums, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RequiredEnums { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "C")] + C, +} + +impl Default for RequiredEnums { + fn default() -> RequiredEnums { + Self::A + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs new file mode 100644 index 00000000000..884357e8604 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs @@ -0,0 +1,34 @@ +pub mod action_container; +pub use self::action_container::ActionContainer; +pub mod api_response; +pub use self::api_response::ApiResponse; +pub mod array_item_ref_test; +pub use self::array_item_ref_test::ArrayItemRefTest; +pub mod baz; +pub use self::baz::Baz; +pub mod category; +pub use self::category::Category; +pub mod enum_array_testing; +pub use self::enum_array_testing::EnumArrayTesting; +pub mod nullable_array; +pub use self::nullable_array::NullableArray; +pub mod optional_testing; +pub use self::optional_testing::OptionalTesting; +pub mod order; +pub use self::order::Order; +pub mod pet; +pub use self::pet::Pet; +pub mod property_test; +pub use self::property_test::PropertyTest; +pub mod model_ref; +pub use self::model_ref::Ref; +pub mod model_return; +pub use self::model_return::Return; +pub mod tag; +pub use self::tag::Tag; +pub mod type_testing; +pub use self::type_testing::TypeTesting; +pub mod unique_item_array_testing; +pub use self::unique_item_array_testing::UniqueItemArrayTesting; +pub mod user; +pub use self::user::User; diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/model_ref.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_ref.rs new file mode 100644 index 00000000000..9862cb1a48e --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_ref.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Ref : using reserved word as model name +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Ref { + #[serde(rename = "dummy", skip_serializing_if = "Option::is_none")] + pub dummy: Option, +} + +impl Ref { + /// using reserved word as model name + pub fn new() -> Ref { + Ref { + dummy: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/model_return.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_return.rs new file mode 100644 index 00000000000..07d9268e6e6 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_return.rs @@ -0,0 +1,35 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Return : Test using keywords +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Return { + #[serde(rename = "match", skip_serializing_if = "Option::is_none")] + pub r#match: Option, + #[serde(rename = "async", skip_serializing_if = "Option::is_none")] + pub r#async: Option, + #[serde(rename = "super", skip_serializing_if = "Option::is_none")] + pub param_super: Option, +} + +impl Return { + /// Test using keywords + pub fn new() -> Return { + Return { + r#match: None, + r#async: None, + param_super: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/nullable_array.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/nullable_array.rs new file mode 100644 index 00000000000..a155ea1176a --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/nullable_array.rs @@ -0,0 +1,36 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct NullableArray { + #[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub array_nullable: Option>>, + #[serde(rename = "just_array", skip_serializing_if = "Option::is_none")] + pub just_array: Option>, + #[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub nullable_string: Option>, + #[serde(rename = "just_string", skip_serializing_if = "Option::is_none")] + pub just_string: Option, +} + +impl NullableArray { + pub fn new() -> NullableArray { + NullableArray { + array_nullable: None, + just_array: None, + nullable_string: None, + just_string: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/optional_testing.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/optional_testing.rs new file mode 100644 index 00000000000..72e5a009a62 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/optional_testing.rs @@ -0,0 +1,38 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// OptionalTesting : Test handling of optional and nullable fields +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OptionalTesting { + #[serde(rename = "optional_nonnull", skip_serializing_if = "Option::is_none")] + pub optional_nonnull: Option, + #[serde(rename = "required_nonnull")] + pub required_nonnull: String, + #[serde(rename = "optional_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub optional_nullable: Option>, + #[serde(rename = "required_nullable", deserialize_with = "Option::deserialize")] + pub required_nullable: Option, +} + +impl OptionalTesting { + /// Test handling of optional and nullable fields + pub fn new(required_nonnull: String, required_nullable: Option) -> OptionalTesting { + OptionalTesting { + optional_nonnull: None, + required_nonnull, + optional_nullable: None, + required_nullable, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs new file mode 100644 index 00000000000..e81f64a2980 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Order : An order for a pets from the pet store +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Order { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "petId", skip_serializing_if = "Option::is_none")] + pub pet_id: Option, + #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] + pub quantity: Option, + #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] + pub ship_date: Option, + /// Order Status + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "complete", skip_serializing_if = "Option::is_none")] + pub complete: Option, +} + +impl Order { + /// An order for a pets from the pet store + pub fn new() -> Order { + Order { + id: None, + pet_id: None, + quantity: None, + ship_date: None, + status: None, + complete: None, + } + } +} +/// Order Status +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "placed")] + Placed, + #[serde(rename = "approved")] + Approved, + #[serde(rename = "delivered")] + Delivered, +} + +impl Default for Status { + fn default() -> Status { + Self::Placed + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/pet.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/pet.rs new file mode 100644 index 00000000000..785fb5390be --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/pet.rs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Pet : A pet for sale in the pet store +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Pet { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option>, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "photoUrls")] + pub photo_urls: Vec, + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, + /// pet status in the store + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl Pet { + /// A pet for sale in the pet store + pub fn new(name: String, photo_urls: Vec) -> Pet { + Pet { + id: None, + category: None, + name, + photo_urls, + tags: None, + status: None, + } + } +} +/// pet status in the store +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "available")] + Available, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "sold")] + Sold, +} + +impl Default for Status { + fn default() -> Status { + Self::Available + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/property_test.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/property_test.rs new file mode 100644 index 00000000000..c98e7c762b5 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/property_test.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PropertyTest : A model to test various formats, e.g. UUID +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PropertyTest { + #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] + pub uuid: Option, +} + +impl PropertyTest { + /// A model to test various formats, e.g. UUID + pub fn new() -> PropertyTest { + PropertyTest { + uuid: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/tag.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/tag.rs new file mode 100644 index 00000000000..8fe4eebd723 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/tag.rs @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Tag : A tag for a pet +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Tag { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl Tag { + /// A tag for a pet + pub fn new() -> Tag { + Tag { + id: None, + name: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs new file mode 100644 index 00000000000..dba87bdb3cf --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs @@ -0,0 +1,54 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use serde_with::serde_as; + +/// TypeTesting : Test handling of different field data types +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TypeTesting { + #[serde(rename = "int32")] + pub int32: i32, + #[serde(rename = "int64")] + pub int64: i64, + #[serde(rename = "float")] + pub float: f32, + #[serde(rename = "double")] + pub double: f64, + #[serde(rename = "string")] + pub string: String, + #[serde(rename = "boolean")] + pub boolean: bool, + #[serde(rename = "uuid")] + pub uuid: uuid::Uuid, + #[serde_as(as = "serde_with::base64::Base64")] + #[serde(rename = "bytes")] + pub bytes: Vec, +} + +impl TypeTesting { + /// Test handling of different field data types + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + TypeTesting { + int32, + int64, + float, + double, + string, + boolean, + uuid, + bytes, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs new file mode 100644 index 00000000000..2a1f18ca9ce --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/unique_item_array_testing.rs @@ -0,0 +1,46 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// UniqueItemArrayTesting : Test handling of enum array with unique items +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UniqueItemArrayTesting { + /// Helper object for the unique item array test + #[serde(rename = "unique_item_array")] + pub unique_item_array: std::collections::HashSet, +} + +impl UniqueItemArrayTesting { + /// Test handling of enum array with unique items + pub fn new(unique_item_array: std::collections::HashSet) -> UniqueItemArrayTesting { + UniqueItemArrayTesting { + unique_item_array, + } + } +} +/// Helper object for the unique item array test +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum UniqueItemArray { + #[serde(rename = "unique_item_1")] + Variant1, + #[serde(rename = "unique_item_2")] + Variant2, + #[serde(rename = "unique_item_3")] + Variant3, +} + +impl Default for UniqueItemArray { + fn default() -> UniqueItemArray { + Self::Variant1 + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/user.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/user.rs new file mode 100644 index 00000000000..c88c469a4eb --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/user.rs @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// User : A User who is purchasing from the pet store +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "username")] + pub username: String, + #[serde(rename = "firstName", skip_serializing_if = "Option::is_none")] + pub first_name: Option, + #[serde(rename = "lastName")] + pub last_name: String, + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, + #[serde(rename = "password", skip_serializing_if = "Option::is_none")] + pub password: Option, + #[serde(rename = "phone", skip_serializing_if = "Option::is_none")] + pub phone: Option, + /// User Status + #[serde(rename = "userStatus", skip_serializing_if = "Option::is_none")] + pub user_status: Option, +} + +impl User { + /// A User who is purchasing from the pet store + pub fn new(username: String, last_name: String) -> User { + User { + id: None, + username, + first_name: None, + last_name, + email: None, + password: None, + phone: None, + user_status: None, + } + } +} +