diff --git a/bin/configs/rust-reqwest-petstore-async-tokensource.yaml b/bin/configs/rust-reqwest-petstore-async-tokensource.yaml new file mode 100644 index 00000000000..3c4ef661caf --- /dev/null +++ b/bin/configs/rust-reqwest-petstore-async-tokensource.yaml @@ -0,0 +1,11 @@ +generatorName: rust +outputDir: samples/client/petstore/rust/reqwest/petstore-async-tokensource +library: reqwest +inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/rust +additionalProperties: + supportAsync: true + supportTokenSource: true + supportMultipleResponses: true + packageName: petstore-reqwest-async-tokensource + useSingleRequestParameter: true diff --git a/docs/generators/rust.md b/docs/generators/rust.md index 1b4ff6f400d..ccd1e9ce413 100644 --- a/docs/generators/rust.md +++ b/docs/generators/rust.md @@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |supportAsync|If set, generate async function call instead. This option is for 'reqwest' library only| |true| |supportMiddleware|If set, add support for reqwest-middleware. This option is for 'reqwest' library only| |false| |supportMultipleResponses|If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only| |false| +|supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' library only and requires the 'supportAsync' option| |false| |useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false| |withAWSV4Signature|whether to include AWS v4 signature support| |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 0b712e34a92..9fb5b8f3ef5 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 @@ -48,6 +48,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon @Setter(AccessLevel.PRIVATE) private boolean useSingleRequestParameter = false; @Setter(AccessLevel.PRIVATE) private boolean supportAsync = true; @Setter(AccessLevel.PRIVATE) private boolean supportMiddleware = false; + @Setter(AccessLevel.PRIVATE) private boolean supportTokenSource = false; private boolean supportMultipleResponses = false; private boolean withAWSV4Signature = false; @Setter private boolean preferUnsignedInt = false; @@ -62,6 +63,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon public static final String REQWEST_LIBRARY = "reqwest"; public static final String SUPPORT_ASYNC = "supportAsync"; public static final String SUPPORT_MIDDLEWARE = "supportMiddleware"; + public static final String SUPPORT_TOKEN_SOURCE = "supportTokenSource"; public static final String SUPPORT_MULTIPLE_RESPONSES = "supportMultipleResponses"; public static final String PREFER_UNSIGNED_INT = "preferUnsignedInt"; public static final String BEST_FIT_INT = "bestFitInt"; @@ -192,6 +194,8 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(SUPPORT_MIDDLEWARE, "If set, add support for reqwest-middleware. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); + cliOptions.add(new CliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE) + .defaultValue(Boolean.FALSE.toString())); cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix)); @@ -346,6 +350,11 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon } writePropertyBack(SUPPORT_MIDDLEWARE, getSupportMiddleware()); + if (additionalProperties.containsKey(SUPPORT_TOKEN_SOURCE)) { + this.setSupportTokenSource(convertPropertyToBoolean(SUPPORT_TOKEN_SOURCE)); + } + writePropertyBack(SUPPORT_TOKEN_SOURCE, getSupportTokenSource()); + if (additionalProperties.containsKey(SUPPORT_MULTIPLE_RESPONSES)) { this.setSupportMultipleReturns(convertPropertyToBoolean(SUPPORT_MULTIPLE_RESPONSES)); } @@ -437,6 +446,10 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon private boolean getSupportMiddleware() { return supportMiddleware; } + + private boolean getSupportTokenSource() { + return supportTokenSource; + } public boolean getSupportMultipleReturns() { return supportMultipleResponses; diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache index 7be71a10b82..1bac4f8128d 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -71,5 +71,10 @@ reqwest = { version = "^0.12", features = ["json", "multipart"] } {{#supportMiddleware}} reqwest-middleware = { version = "^0.3", features = ["json", "multipart"] } {{/supportMiddleware}} +{{#supportTokenSource}} +async-trait = "^0.1" +# TODO: propose to Yoshidan to externalize this as non google related crate, so that it can easily be extended for other cloud providers. +google-cloud-token = "^0.1" +{{/supportTokenSource}} {{/supportAsync}} {{/reqwest}} diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index f9e6e9db599..dc0cf75205c 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -211,6 +211,14 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{/hasHeaderParams}} {{#hasAuthMethods}} {{#authMethods}} + {{#supportTokenSource}} + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + {{/supportTokenSource}} + {{^supportTokenSource}} {{#isApiKey}} {{#isKeyInHeader}} if let Some(ref local_var_apikey) = local_var_configuration.api_key { @@ -240,6 +248,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); }; {{/isOAuth}} + {{/supportTokenSource}} {{/authMethods}} {{/hasAuthMethods}} {{#isMultipart}} diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache index 347f3337986..bc5f68f4407 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache @@ -23,6 +23,11 @@ pub enum Error { {{#withAWSV4Signature}} AWSV4SignatureError(aws_sigv4::http_request::Error), {{/withAWSV4Signature}} + {{#supportAsync}} + {{#supportTokenSource}} + TokenSource(Box), + {{/supportTokenSource}} + {{/supportAsync}} } impl fmt::Display for Error { @@ -38,6 +43,11 @@ impl fmt::Display for Error { {{#withAWSV4Signature}} Error::AWSV4SignatureError(e) => ("aws v4 signature", e.to_string()), {{/withAWSV4Signature}} + {{#supportAsync}} + {{#supportTokenSource}} + Error::TokenSource(e) => ("token source failure", e.to_string()), + {{/supportTokenSource}} + {{/supportAsync}} }; write!(f, "error in {}: {}", module, e) } @@ -56,6 +66,11 @@ impl error::Error for Error { {{#withAWSV4Signature}} Error::AWSV4SignatureError(_) => return None, {{/withAWSV4Signature}} + {{#supportAsync}} + {{#supportTokenSource}} + Error::TokenSource(e) => &**e, + {{/supportTokenSource}} + {{/supportAsync}} }) } } diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache index fd6f7d052d9..e29c73b17f6 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache @@ -6,21 +6,33 @@ use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequ use http; use secrecy::{SecretString, ExposeSecret}; {{/withAWSV4Signature}} +{{#supportTokenSource}} +use std::sync::Arc; +use google_cloud_token::TokenSource; +use async_trait::async_trait; +{{/supportTokenSource}} #[derive(Debug, Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, pub client: {{#supportMiddleware}}reqwest_middleware::ClientWithMiddleware{{/supportMiddleware}}{{^supportMiddleware}}reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client{{/supportMiddleware}}, + {{^supportTokenSource}} pub basic_auth: Option, pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, + {{/supportTokenSource}} {{#withAWSV4Signature}} pub aws_v4_key: Option, {{/withAWSV4Signature}} - // TODO: take an oauth2 token source, similar to the go one + {{#supportAsync}} + {{#supportTokenSource}} + pub token_source: Arc, + {{/supportTokenSource}} + {{/supportAsync}} } +{{^supportTokenSource}} pub type BasicAuth = (String, Option); @@ -29,6 +41,7 @@ pub struct ApiKey { pub prefix: Option, pub key: String, } +{{/supportTokenSource}} {{#withAWSV4Signature}} #[derive(Debug, Clone)] @@ -81,11 +94,29 @@ impl Default for Configuration { base_path: "{{{basePath}}}".to_owned(), user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, client: {{#supportMiddleware}}reqwest_middleware::ClientBuilder::new(reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client::new()).build(){{/supportMiddleware}}{{^supportMiddleware}}reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client::new(){{/supportMiddleware}}, + {{^supportTokenSource}} basic_auth: None, oauth_access_token: None, bearer_access_token: None, api_key: None, -{{#withAWSV4Signature}} aws_v4_key: None,{{/withAWSV4Signature}} + {{/supportTokenSource}} + {{#withAWSV4Signature}} + aws_v4_key: None, + {{/withAWSV4Signature}} + {{#supportTokenSource}} + token_source: Arc::new(NoopTokenSource{}), + {{/supportTokenSource}} } } } +{{#supportTokenSource}} +#[derive(Debug)] +struct NoopTokenSource{} + +#[async_trait] +impl TokenSource for NoopTokenSource { + async fn token(&self) -> Result> { + panic!("This is dummy token source. You can use TokenSourceProvider from 'google_cloud_auth' crate, or any other compatible crate.") + } +} +{{/supportTokenSource}} diff --git a/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs b/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs index d1b488dc8b8..3a5e9794965 100644 --- a/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs b/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs index 244f8e0b326..217eb726c45 100644 --- a/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs b/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs index 0cd1c7b22cd..62472d005be 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs b/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs index cd823ba99a0..f34d87a2523 100644 --- a/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs b/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs index affdc7fd52d..434e434f365 100644 --- a/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs b/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs index 4dc1cd54751..e162c5629d0 100644 --- a/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs b/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs index cfdd5f470ea..c1711e789c2 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs index c2176e57ad0..0eec5406b15 100644 --- a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs index 5c15632ff7c..2d931ea0b6f 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.gitignore b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.gitignore new file mode 100644 index 00000000000..6aa106405a4 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.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/reqwest/petstore-async-tokensource/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES new file mode 100644 index 00000000000..6d5eacd5c07 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES @@ -0,0 +1,55 @@ +.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/NumericEnumTesting.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/numeric_enum_testing.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/reqwest/petstore-async-tokensource/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/VERSION new file mode 100644 index 00000000000..17f2442ff3b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.9.0-SNAPSHOT diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.travis.yml b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.travis.yml new file mode 100644 index 00000000000..22761ba7ee1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml new file mode 100644 index 00000000000..811475c96e1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "petstore-reqwest-async-tokensource" +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" +serde_repr = "^0.1" +url = "^2.5" +uuid = { version = "^1.8", features = ["serde", "v4"] } +reqwest = { version = "^0.12", features = ["json", "multipart"] } +async-trait = "^0.1" +# TODO: propose to Yoshidan to externalize this as non google related crate, so that it can easily be extended for other cloud providers. +google-cloud-token = "^0.1" diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md new file mode 100644 index 00000000000..1bccda33742 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md @@ -0,0 +1,85 @@ +# Rust API client for petstore-reqwest-async-tokensource + +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.9.0-SNAPSHOT +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `petstore-reqwest-async-tokensource` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +petstore-reqwest-async-tokensource = { path = "./petstore-reqwest-async-tokensource" } +``` + +## 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) + - [NumericEnumTesting](docs/NumericEnumTesting.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/reqwest/petstore-async-tokensource/docs/ActionContainer.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ActionContainer.md new file mode 100644 index 00000000000..4e0a0ba4961 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/ApiResponse.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ApiResponse.md new file mode 100644 index 00000000000..b5125ba685b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ArrayItemRefTest.md new file mode 100644 index 00000000000..616deda7c4b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/Baz.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Baz.md new file mode 100644 index 00000000000..e9c4c693d89 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/Category.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Category.md new file mode 100644 index 00000000000..1cf67347c05 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/EnumArrayTesting.md new file mode 100644 index 00000000000..fb4c54df47d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/FakeApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/FakeApi.md new file mode 100644 index 00000000000..55bf612aa21 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/NullableArray.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/NullableArray.md new file mode 100644 index 00000000000..3b4aaa9668f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/NumericEnumTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/NumericEnumTesting.md new file mode 100644 index 00000000000..6e99038d397 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/NumericEnumTesting.md @@ -0,0 +1,15 @@ +# NumericEnumTesting + +## Enum Variants + +| Name | Value | +|---- | -----| +| Variant0 | 0 | +| Variant1 | 1 | +| Variant2 | 2 | +| Variant3 | 3 | + + +[[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/reqwest/petstore-async-tokensource/docs/OptionalTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/OptionalTesting.md new file mode 100644 index 00000000000..029e38eb977 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md new file mode 100644 index 00000000000..d9a09c39743 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Pet.md new file mode 100644 index 00000000000..e7a72caa16e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PetApi.md new file mode 100644 index 00000000000..d503facb903 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PropertyTest.md new file mode 100644 index 00000000000..3f36c163de0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/Ref.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Ref.md new file mode 100644 index 00000000000..04f9d0aa55a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/Return.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Return.md new file mode 100644 index 00000000000..04710a019db --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/StoreApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/StoreApi.md new file mode 100644 index 00000000000..a513dfa1b5f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/Tag.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Tag.md new file mode 100644 index 00000000000..7bf71ab0e9d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md new file mode 100644 index 00000000000..9c26af24912 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md new file mode 100644 index 00000000000..4f650eb1aa2 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/UniqueItemArrayTesting.md new file mode 100644 index 00000000000..6e103e2bb28 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/User.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/User.md new file mode 100644 index 00000000000..19d813622ed --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/docs/UserApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/UserApi.md new file mode 100644 index 00000000000..d536057ae15 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/git_push.sh b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/git_push.sh new file mode 100644 index 00000000000..f53a75d4fab --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/configuration.rs new file mode 100644 index 00000000000..a380aed4ec7 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/configuration.rs @@ -0,0 +1,49 @@ +/* + * 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::sync::Arc; +use google_cloud_token::TokenSource; +use async_trait::async_trait; + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub token_source: Arc, +} + + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "http://petstore.swagger.io/v2".to_owned(), + user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), + client: reqwest::Client::new(), + token_source: Arc::new(NoopTokenSource{}), + } + } +} +#[derive(Debug)] +struct NoopTokenSource{} + +#[async_trait] +impl TokenSource for NoopTokenSource { + async fn token(&self) -> Result> { + panic!("This is dummy token source. You can use TokenSourceProvider from 'google_cloud_auth' crate, or any other compatible crate.") + } +} diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/fake_api.rs new file mode 100644 index 00000000000..3f10b5b6c2a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/fake_api.rs @@ -0,0 +1,89 @@ +/* + * 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 reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + +/// struct for passing parameters to the method [`test_nullable_required_param`] +#[derive(Clone, Debug)] +pub struct TestNullableRequiredParamParams { + /// The name that needs to be fetched. Use user1 for testing. + pub username: String, + /// To test nullable required parameters + pub dummy_required_nullable_param: Option, + /// To test parameter names in upper case + pub uppercase: Option +} + + +/// struct for typed successes of method [`test_nullable_required_param`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestNullableRequiredParamSuccess { + Status200(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`test_nullable_required_param`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestNullableRequiredParamError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + + +/// +pub async fn test_nullable_required_param(configuration: &configuration::Configuration, params: TestNullableRequiredParamParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let username = params.username; + let dummy_required_nullable_param = params.dummy_required_nullable_param; + let uppercase = params.uppercase; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/fake/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + match dummy_required_nullable_param { + Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", local_var_param_value.to_string()); }, + None => { local_var_req_builder = local_var_req_builder.header("dummy_required_nullable_param", ""); }, + } + if let Some(local_var_param_value) = uppercase { + local_var_req_builder = local_var_req_builder.header("UPPERCASE", local_var_param_value.to_string()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/mod.rs new file mode 100644 index 00000000000..3f68c684126 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/mod.rs @@ -0,0 +1,102 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), + TokenSource(Box), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + Error::TokenSource(e) => ("token source failure", e.to_string()), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + Error::TokenSource(e) => &**e, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + }, + serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +pub mod fake_api; +pub mod pet_api; +pub mod store_api; +pub mod testing_api; +pub mod user_api; + +pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs new file mode 100644 index 00000000000..7901fb0c40d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs @@ -0,0 +1,555 @@ +/* + * 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 reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + +/// struct for passing parameters to the method [`add_pet`] +#[derive(Clone, Debug)] +pub struct AddPetParams { + /// Pet object that needs to be added to the store + pub pet: models::Pet +} + +/// struct for passing parameters to the method [`delete_pet`] +#[derive(Clone, Debug)] +pub struct DeletePetParams { + /// Pet id to delete + pub pet_id: i64, + pub api_key: Option +} + +/// struct for passing parameters to the method [`find_pets_by_status`] +#[derive(Clone, Debug)] +pub struct FindPetsByStatusParams { + /// Status values that need to be considered for filter + pub status: Vec +} + +/// struct for passing parameters to the method [`find_pets_by_tags`] +#[derive(Clone, Debug)] +pub struct FindPetsByTagsParams { + /// Tags to filter by + pub tags: Vec +} + +/// struct for passing parameters to the method [`get_pet_by_id`] +#[derive(Clone, Debug)] +pub struct GetPetByIdParams { + /// ID of pet to return + pub pet_id: i64 +} + +/// struct for passing parameters to the method [`update_pet`] +#[derive(Clone, Debug)] +pub struct UpdatePetParams { + /// Pet object that needs to be added to the store + pub pet: models::Pet +} + +/// struct for passing parameters to the method [`update_pet_with_form`] +#[derive(Clone, Debug)] +pub struct UpdatePetWithFormParams { + /// ID of pet that needs to be updated + pub pet_id: i64, + /// Updated name of the pet + pub name: Option, + /// Updated status of the pet + pub status: Option +} + +/// struct for passing parameters to the method [`upload_file`] +#[derive(Clone, Debug)] +pub struct UploadFileParams { + /// ID of pet to update + pub pet_id: i64, + /// Additional data to pass to server + pub additional_metadata: Option, + /// file to upload + pub file: Option +} + + +/// struct for typed successes of method [`add_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddPetSuccess { + Status200(models::Pet), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeletePetSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`find_pets_by_status`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByStatusSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`find_pets_by_tags`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByTagsSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_pet_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPetByIdSuccess { + Status200(models::Pet), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`update_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetSuccess { + Status200(models::Pet), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`update_pet_with_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetWithFormSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`upload_file`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadFileSuccess { + Status200(models::ApiResponse), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`add_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddPetError { + Status405(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeletePetError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`find_pets_by_status`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByStatusError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`find_pets_by_tags`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByTagsError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_pet_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPetByIdError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetError { + Status400(), + Status404(), + Status405(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_pet_with_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetWithFormError { + Status405(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`upload_file`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadFileError { + UnknownValue(serde_json::Value), +} + + +/// +pub async fn add_pet(configuration: &configuration::Configuration, params: AddPetParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let pet = params.pet; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + local_var_req_builder = local_var_req_builder.json(&pet); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn delete_pet(configuration: &configuration::Configuration, params: DeletePetParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let pet_id = params.pet_id; + let api_key = params.api_key; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(local_var_param_value) = api_key { + local_var_req_builder = local_var_req_builder.header("api_key", local_var_param_value.to_string()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Multiple status values can be provided with comma separated strings +pub async fn find_pets_by_status(configuration: &configuration::Configuration, params: FindPetsByStatusParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let status = params.status; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet/findByStatus", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = match "csv" { + "multi" => local_var_req_builder.query(&status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => local_var_req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + }; + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. +pub async fn find_pets_by_tags(configuration: &configuration::Configuration, params: FindPetsByTagsParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let tags = params.tags; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet/findByTags", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = match "csv" { + "multi" => local_var_req_builder.query(&tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => local_var_req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + }; + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a single pet +pub async fn get_pet_by_id(configuration: &configuration::Configuration, params: GetPetByIdParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let pet_id = params.pet_id; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn update_pet(configuration: &configuration::Configuration, params: UpdatePetParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let pet = params.pet; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + local_var_req_builder = local_var_req_builder.json(&pet); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn update_pet_with_form(configuration: &configuration::Configuration, params: UpdatePetWithFormParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let pet_id = params.pet_id; + let name = params.name; + let status = params.status; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet/{petId}", local_var_configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + let mut local_var_form_params = std::collections::HashMap::new(); + if let Some(local_var_param_value) = name { + local_var_form_params.insert("name", local_var_param_value.to_string()); + } + if let Some(local_var_param_value) = status { + local_var_form_params.insert("status", local_var_param_value.to_string()); + } + local_var_req_builder = local_var_req_builder.form(&local_var_form_params); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn upload_file(configuration: &configuration::Configuration, params: UploadFileParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let pet_id = params.pet_id; + let additional_metadata = params.additional_metadata; + let file = params.file; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/pet/{petId}/uploadImage", local_var_configuration.base_path, petId=pet_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + let mut local_var_form = reqwest::multipart::Form::new(); + if let Some(local_var_param_value) = additional_metadata { + local_var_form = local_var_form.text("additionalMetadata", local_var_param_value.to_string()); + } + // TODO: support file upload for 'file' parameter + local_var_req_builder = local_var_req_builder.multipart(local_var_form); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/store_api.rs new file mode 100644 index 00000000000..2531e630675 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/store_api.rs @@ -0,0 +1,244 @@ +/* + * 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 reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + +/// struct for passing parameters to the method [`delete_order`] +#[derive(Clone, Debug)] +pub struct DeleteOrderParams { + /// ID of the order that needs to be deleted + pub order_id: String +} + +/// struct for passing parameters to the method [`get_order_by_id`] +#[derive(Clone, Debug)] +pub struct GetOrderByIdParams { + /// ID of pet that needs to be fetched + pub order_id: i64 +} + +/// struct for passing parameters to the method [`place_order`] +#[derive(Clone, Debug)] +pub struct PlaceOrderParams { + /// order placed for purchasing the pet + pub order: models::Order +} + + +/// struct for typed successes of method [`delete_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_inventory`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInventorySuccess { + Status200(std::collections::HashMap), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_order_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderByIdSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`place_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlaceOrderSuccess { + Status200(models::Order), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_inventory`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInventoryError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_order_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderByIdError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`place_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlaceOrderError { + Status400(), + UnknownValue(serde_json::Value), +} + + +/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +pub async fn delete_order(configuration: &configuration::Configuration, params: DeleteOrderParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let order_id = params.order_id; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=crate::apis::urlencode(order_id)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Returns a map of status codes to quantities +pub async fn get_inventory(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/store/inventory", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions +pub async fn get_order_by_id(configuration: &configuration::Configuration, params: GetOrderByIdParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let order_id = params.order_id; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/store/order/{orderId}", local_var_configuration.base_path, orderId=order_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn place_order(configuration: &configuration::Configuration, params: PlaceOrderParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let order = params.order; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/store/order", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(&order); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs new file mode 100644 index 00000000000..83d1a00fb4c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs @@ -0,0 +1,112 @@ +/* + * 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 reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + + +/// struct for typed successes of method [`tests_file_response_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsFileResponseGetSuccess { + Status200(std::path::PathBuf), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`tests_type_testing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsTypeTestingGetSuccess { + Status200(models::TypeTesting), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_file_response_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsFileResponseGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_type_testing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsTypeTestingGetError { + UnknownValue(serde_json::Value), +} + + +pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/fileResponse", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/typeTesting", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/user_api.rs new file mode 100644 index 00000000000..0c62352279d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/user_api.rs @@ -0,0 +1,505 @@ +/* + * 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 reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + +/// struct for passing parameters to the method [`create_user`] +#[derive(Clone, Debug)] +pub struct CreateUserParams { + /// Created user object + pub user: models::User +} + +/// struct for passing parameters to the method [`create_users_with_array_input`] +#[derive(Clone, Debug)] +pub struct CreateUsersWithArrayInputParams { + /// List of user object + pub user: Vec +} + +/// struct for passing parameters to the method [`create_users_with_list_input`] +#[derive(Clone, Debug)] +pub struct CreateUsersWithListInputParams { + /// List of user object + pub user: Vec +} + +/// struct for passing parameters to the method [`delete_user`] +#[derive(Clone, Debug)] +pub struct DeleteUserParams { + /// The name that needs to be deleted + pub username: String +} + +/// struct for passing parameters to the method [`get_user_by_name`] +#[derive(Clone, Debug)] +pub struct GetUserByNameParams { + /// The name that needs to be fetched. Use user1 for testing. + pub username: String +} + +/// struct for passing parameters to the method [`login_user`] +#[derive(Clone, Debug)] +pub struct LoginUserParams { + /// The user name for login + pub username: String, + /// The password for login in clear text + pub password: String +} + +/// struct for passing parameters to the method [`update_user`] +#[derive(Clone, Debug)] +pub struct UpdateUserParams { + /// name that need to be deleted + pub username: String, + /// Updated user object + pub user: models::User +} + + +/// struct for typed successes of method [`create_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUserSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_users_with_array_input`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithArrayInputSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`create_users_with_list_input`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithListInputSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`delete_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteUserSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`get_user_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserByNameSuccess { + Status200(models::User), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`login_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LoginUserSuccess { + Status200(String), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`logout_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LogoutUserSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`update_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateUserSuccess { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUserError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_users_with_array_input`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithArrayInputError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_users_with_list_input`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithListInputError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteUserError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_user_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserByNameError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`login_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LoginUserError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`logout_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LogoutUserError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateUserError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + + +/// This can only be done by the logged in user. +pub async fn create_user(configuration: &configuration::Configuration, params: CreateUserParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let user = params.user; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + local_var_req_builder = local_var_req_builder.json(&user); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn create_users_with_array_input(configuration: &configuration::Configuration, params: CreateUsersWithArrayInputParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let user = params.user; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user/createWithArray", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + local_var_req_builder = local_var_req_builder.json(&user); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn create_users_with_list_input(configuration: &configuration::Configuration, params: CreateUsersWithListInputParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let user = params.user; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user/createWithList", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + local_var_req_builder = local_var_req_builder.json(&user); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// This can only be done by the logged in user. +pub async fn delete_user(configuration: &configuration::Configuration, params: DeleteUserParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let username = params.username; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn get_user_by_name(configuration: &configuration::Configuration, params: GetUserByNameParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let username = params.username; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn login_user(configuration: &configuration::Configuration, params: LoginUserParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let username = params.username; + let password = params.password; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user/login", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("username", &username.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("password", &password.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// +pub async fn logout_user(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user/logout", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// This can only be done by the logged in user. +pub async fn update_user(configuration: &configuration::Configuration, params: UpdateUserParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let username = params.username; + let user = params.user; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/user/{username}", local_var_configuration.base_path, username=crate::apis::urlencode(username)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + // Obtain a token from source provider. + // Tokens can be Id or access tokens depending on the provider type and configuration. + let token = local_var_configuration.token_source.token().await.map_err(Error::TokenSource)?; + // The token format is the responsibility of the provider, thus we just set the authorization header with whatever is given. + local_var_req_builder = local_var_req_builder.header(reqwest::header::AUTHORIZATION, token); + local_var_req_builder = local_var_req_builder.json(&user); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Ok(local_var_result) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/lib.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/lib.rs new file mode 100644 index 00000000000..e1520628d76 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde_repr; +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/action_container.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/action_container.rs new file mode 100644 index 00000000000..11d2f0b8712 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/api_response.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/api_response.rs new file mode 100644 index 00000000000..0a60da0f477 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/array_item_ref_test.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/array_item_ref_test.rs new file mode 100644 index 00000000000..4ac1e8a2fe9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/baz.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/baz.rs new file mode 100644 index 00000000000..17b42c0bd4f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/category.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/category.rs new file mode 100644 index 00000000000..9ecf89d354d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/enum_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/enum_array_testing.rs new file mode 100644 index 00000000000..2ac40c30775 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs new file mode 100644 index 00000000000..b7e684d8071 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs @@ -0,0 +1,36 @@ +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 numeric_enum_testing; +pub use self::numeric_enum_testing::NumericEnumTesting; +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/reqwest/petstore-async-tokensource/src/models/model_ref.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_ref.rs new file mode 100644 index 00000000000..9862cb1a48e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/model_return.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_return.rs new file mode 100644 index 00000000000..07d9268e6e6 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/nullable_array.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/nullable_array.rs new file mode 100644 index 00000000000..a155ea1176a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/numeric_enum_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/numeric_enum_testing.rs new file mode 100644 index 00000000000..9b8f0cb0465 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/numeric_enum_testing.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}; + +use serde_repr::{Serialize_repr,Deserialize_repr}; +/// NumericEnumTesting : testing that numeric enums are converted correctly +/// testing that numeric enums are converted correctly +#[repr(i64)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr)] +pub enum NumericEnumTesting { + Variant0 = 0, + Variant1 = 1, + Variant2 = 2, + Variant3 = 3, + +} + +impl ToString for NumericEnumTesting { + fn to_string(&self) -> String { + match self { + Self::Variant0 => String::from("0"), + Self::Variant1 => String::from("1"), + Self::Variant2 => String::from("2"), + Self::Variant3 => String::from("3"), + } + } +} +impl Default for NumericEnumTesting { + fn default() -> NumericEnumTesting { + Self::Variant0 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/optional_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/optional_testing.rs new file mode 100644 index 00000000000..72e5a009a62 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs new file mode 100644 index 00000000000..e81f64a2980 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/pet.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/pet.rs new file mode 100644 index 00000000000..785fb5390be --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/property_test.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/property_test.rs new file mode 100644 index 00000000000..c98e7c762b5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/tag.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/tag.rs new file mode 100644 index 00000000000..8fe4eebd723 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/type_testing.rs new file mode 100644 index 00000000000..dba87bdb3cf --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/unique_item_array_testing.rs new file mode 100644 index 00000000000..2a1f18ca9ce --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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/reqwest/petstore-async-tokensource/src/models/user.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/user.rs new file mode 100644 index 00000000000..c88c469a4eb --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/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, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs index ba335d974cc..761172249ba 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs index ba335d974cc..761172249ba 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs index f401dc38637..2efc39d68fe 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs @@ -24,7 +24,6 @@ pub struct Configuration { pub bearer_access_token: Option, pub api_key: Option, pub aws_v4_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs index 8a43283dd43..b1787d23b6e 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs @@ -19,7 +19,6 @@ pub struct Configuration { pub oauth_access_token: Option, pub bearer_access_token: Option, pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one } pub type BasicAuth = (String, Option); @@ -47,7 +46,6 @@ impl Default for Configuration { oauth_access_token: None, bearer_access_token: None, api_key: None, - } } }