Skip to content

Added support for multiple api keys in rust (reqwest) #19511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,9 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{#authMethods}}
{{#isApiKey}}
{{#isKeyInQuery}}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.query(&[("{{{keyParamName}}}", local_var_value)]);
if let Some(local_var_apikey) = local_var_configuration.api_keys.get("{{{keyParamName}}}") {
let local_var_key = local_var_apikey.clone();
local_var_req_builder = local_var_req_builder.query(&[("{{{keyParamName}}}", local_var_key)]);
}
{{/isKeyInQuery}}
{{/isApiKey}}
Expand Down Expand Up @@ -213,13 +209,9 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{#authMethods}}
{{#isApiKey}}
{{#isKeyInHeader}}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("{{{keyParamName}}}", local_var_value);
if let Some(local_var_apikey) = local_var_configuration.api_keys.get("{{{keyParamName}}}") {
let local_var_key = local_var_apikey.clone();
local_var_req_builder = local_var_req_builder.header("{{{keyParamName}}}", local_var_key);
};
{{/isKeyInHeader}}
{{/isApiKey}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{>partial_header}}

use std::collections::HashMap;
{{#withAWSV4Signature}}
use std::time::SystemTime;
use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest};
Expand All @@ -15,7 +15,7 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
{{#withAWSV4Signature}}
pub aws_v4_key: Option<AWSv4Key>,
{{/withAWSV4Signature}}
Expand All @@ -24,12 +24,6 @@ pub struct Configuration {

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}

{{#withAWSV4Signature}}
#[derive(Debug, Clone)]
pub struct AWSv4Key {
Expand Down Expand Up @@ -84,7 +78,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),
{{#withAWSV4Signature}} aws_v4_key: None,{{/withAWSV4Signature}}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech
*/


use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct Configuration {
Expand All @@ -18,18 +18,12 @@ pub struct Configuration {
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub api_keys: HashMap<String,String>,
// TODO: take an oauth2 token source, similar to the go one
}

pub type BasicAuth = (String, Option<String>);

#[derive(Debug, Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Expand All @@ -46,7 +40,7 @@ impl Default for Configuration {
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
api_keys: HashMap::new(),

}
}
Expand Down
Loading
Loading