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 e63b2b08ff9..e6706f7afe1 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -78,9 +78,16 @@ impl {{{classname}}} for {{{classname}}}Client { {{/isKeyInHeader}} {{/isApiKey}} {{#isBasic}} + {{^isBasicBearer}} if let Some(ref auth_conf) = configuration.basic_auth { req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned()); }; + {{/isBasicBearer}} + {{#isBasicBearer}} + if let Some(ref token) = configuration.bearer_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + {{/isBasicBearer}} {{/isBasic}} {{#isOAuth}} if let Some(ref token) = configuration.oauth_access_token { 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 5b9c437863a..c12590dfc2a 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache @@ -8,6 +8,7 @@ pub struct Configuration { pub client: reqwest::Client, pub basic_auth: Option, 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 } @@ -33,6 +34,7 @@ impl Default for Configuration { client: reqwest::Client::new(), basic_auth: None, oauth_access_token: None, + bearer_access_token: None, api_key: None, } }