mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
[Rust] Implement minimal auth support (#7338)
* [Rust] Implement minimal auth support This is pretty much the bare minimum needed to get v2 auth working. This is partly based on the Go implementation. * [Rust] properly format query string * [Rust] Improve auth formatting * [Rust] Regenerate petstore sample
This commit is contained in:
parent
6c7813e79c
commit
b443573945
@ -2,6 +2,7 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use hyper;
|
use hyper;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
@ -39,26 +40,71 @@ impl<C: hyper::client::Connect>{{classname}} for {{classname}}Client<C> {
|
|||||||
fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error = Error<serde_json::Value>>> {
|
fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
{{#hasAuthMethods}}
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
{{#authMethods}}
|
||||||
|
{{#isApiKey}}
|
||||||
|
if let Some(ref apikey) = configuration.api_key {
|
||||||
|
let key = apikey.key.clone();
|
||||||
|
let val = match apikey.prefix {
|
||||||
|
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||||
|
None => key,
|
||||||
|
};
|
||||||
|
{{#isKeyInHeader}}
|
||||||
|
auth_headers.insert("{{keyParamName}}".to_owned(), val);
|
||||||
|
{{/isKeyInHeader}}
|
||||||
|
{{#isKeyInQuery}}
|
||||||
|
auth_query.insert("{{keyParamName}}".to_owned(), val);
|
||||||
|
{{/isKeyInQuery}}
|
||||||
|
};
|
||||||
|
{{/isApiKey}}
|
||||||
|
{{#isBasic}}
|
||||||
|
if let Some(ref auth_conf) = configuration.basic_auth {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Basic {
|
||||||
|
username: auth_conf.0.to_owned(),
|
||||||
|
password: auth_conf.1.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
|
{{/isBasic}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
{{/hasAuthMethods}}
|
||||||
let method = hyper::Method::{{httpMethod}};
|
let method = hyper::Method::{{httpMethod}};
|
||||||
|
|
||||||
{{^hasQueryParams}}
|
let query_string = {
|
||||||
let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{baseName}}={{paramName}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{/pathParams}});
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
{{/hasQueryParams}}
|
{{#queryParams}}
|
||||||
{{#hasQueryParams}}
|
query.append_pair("{{baseName}}", &{{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
|
||||||
let query = ::url::form_urlencoded::Serializer::new(String::new())
|
{{/queryParams}}
|
||||||
{{#queryParams}}
|
{{#hasAuthMethods}}
|
||||||
.append_pair("{{baseName}}", &{{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
|
for (key, val) in &auth_query {
|
||||||
{{/queryParams}}
|
query.append_pair(key, val);
|
||||||
.finish();
|
}
|
||||||
let uri_str = format!("{}{{{path}}}{}", configuration.base_path, query{{#pathParams}}, {{baseName}}={{paramName}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{/pathParams}});
|
{{/hasAuthMethods}}
|
||||||
{{/hasQueryParams}}
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}{{{path}}}?{}", configuration.base_path, query_string{{#pathParams}}, {{baseName}}={{paramName}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{/pathParams}});
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -73,6 +119,12 @@ impl<C: hyper::client::Connect>{{classname}} for {{classname}}Client<C> {
|
|||||||
}
|
}
|
||||||
{{/hasHeaderParams}}
|
{{/hasHeaderParams}}
|
||||||
|
|
||||||
|
{{#hasAuthMethods}}
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
{{#hasBodyParam}}
|
{{#hasBodyParam}}
|
||||||
{{#bodyParams}}
|
{{#bodyParams}}
|
||||||
let serialized = serde_json::to_string(&{{paramName}}).unwrap();
|
let serialized = serde_json::to_string(&{{paramName}}).unwrap();
|
||||||
|
@ -1,10 +1,22 @@
|
|||||||
{{>partial_header}}
|
{{>partial_header}}
|
||||||
use hyper;
|
use hyper;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct Configuration<C: hyper::client::Connect> {
|
pub struct Configuration<C: hyper::client::Connect> {
|
||||||
pub base_path: String,
|
pub base_path: String,
|
||||||
pub user_agent: Option<String>,
|
pub user_agent: Option<String>,
|
||||||
pub client: hyper::client::Client<C>,
|
pub client: hyper::client::Client<C>,
|
||||||
|
pub basic_auth: Option<BasicAuth>,
|
||||||
|
pub oauth_access_token: Option<String>,
|
||||||
|
pub api_key: Option<ApiKey>,
|
||||||
|
// TODO: take an oauth2 token source, similar to the go one
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type BasicAuth = (String, Option<String>);
|
||||||
|
|
||||||
|
pub struct ApiKey {
|
||||||
|
pub prefix: Option<String>,
|
||||||
|
pub key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: hyper::client::Connect> Configuration<C> {
|
impl<C: hyper::client::Connect> Configuration<C> {
|
||||||
@ -13,6 +25,9 @@ impl<C: hyper::client::Connect> Configuration<C> {
|
|||||||
base_path: "{{{basePath}}}".to_owned(),
|
base_path: "{{{basePath}}}".to_owned(),
|
||||||
user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("Swagger-Codegen/{{version}}/rust".to_owned()){{/httpUserAgent}},
|
user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("Swagger-Codegen/{{version}}/rust".to_owned()){{/httpUserAgent}},
|
||||||
client: client,
|
client: client,
|
||||||
|
basic_auth: None,
|
||||||
|
oauth_access_token: None,
|
||||||
|
api_key: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ Get user by user name
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
|
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -9,11 +9,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use hyper;
|
use hyper;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct Configuration<C: hyper::client::Connect> {
|
pub struct Configuration<C: hyper::client::Connect> {
|
||||||
pub base_path: String,
|
pub base_path: String,
|
||||||
pub user_agent: Option<String>,
|
pub user_agent: Option<String>,
|
||||||
pub client: hyper::client::Client<C>,
|
pub client: hyper::client::Client<C>,
|
||||||
|
pub basic_auth: Option<BasicAuth>,
|
||||||
|
pub oauth_access_token: Option<String>,
|
||||||
|
pub api_key: Option<ApiKey>,
|
||||||
|
// TODO: take an oauth2 token source, similar to the go one
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type BasicAuth = (String, Option<String>);
|
||||||
|
|
||||||
|
pub struct ApiKey {
|
||||||
|
pub prefix: Option<String>,
|
||||||
|
pub key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: hyper::client::Connect> Configuration<C> {
|
impl<C: hyper::client::Connect> Configuration<C> {
|
||||||
@ -22,6 +34,9 @@ impl<C: hyper::client::Connect> Configuration<C> {
|
|||||||
base_path: "http://petstore.swagger.io/v2".to_owned(),
|
base_path: "http://petstore.swagger.io/v2".to_owned(),
|
||||||
user_agent: Some("Swagger-Codegen/1.0.0/rust".to_owned()),
|
user_agent: Some("Swagger-Codegen/1.0.0/rust".to_owned()),
|
||||||
client: client,
|
client: client,
|
||||||
|
basic_auth: None,
|
||||||
|
oauth_access_token: None,
|
||||||
|
api_key: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use hyper;
|
use hyper;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
@ -49,22 +50,44 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn add_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
fn add_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
let method = hyper::Method::Post;
|
let method = hyper::Method::Post;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&body).unwrap();
|
let serialized = serde_json::to_string(&body).unwrap();
|
||||||
req.headers_mut().set(hyper::header::ContentType::json());
|
req.headers_mut().set(hyper::header::ContentType::json());
|
||||||
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
||||||
@ -94,16 +117,34 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
let method = hyper::Method::Delete;
|
let method = hyper::Method::Delete;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -114,6 +155,10 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
headers.set_raw("api_key", api_key);
|
headers.set_raw("api_key", api_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
@ -139,25 +184,45 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn find_pets_by_status(&self, status: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>> {
|
fn find_pets_by_status(&self, status: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let query = ::url::form_urlencoded::Serializer::new(String::new())
|
let query_string = {
|
||||||
.append_pair("status", &status.join(",").to_string())
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
.finish();
|
query.append_pair("status", &status.join(",").to_string());
|
||||||
let uri_str = format!("{}/pet/findByStatus{}", configuration.base_path, query);
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/findByStatus?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
@ -186,25 +251,45 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn find_pets_by_tags(&self, tags: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>> {
|
fn find_pets_by_tags(&self, tags: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let query = ::url::form_urlencoded::Serializer::new(String::new())
|
let query_string = {
|
||||||
.append_pair("tags", &tags.join(",").to_string())
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
.finish();
|
query.append_pair("tags", &tags.join(",").to_string());
|
||||||
let uri_str = format!("{}/pet/findByTags{}", configuration.base_path, query);
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/findByTags?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
@ -233,22 +318,44 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn get_pet_by_id(&self, pet_id: i64) -> Box<Future<Item = ::models::Pet, Error = Error<serde_json::Value>>> {
|
fn get_pet_by_id(&self, pet_id: i64) -> Box<Future<Item = ::models::Pet, Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref apikey) = configuration.api_key {
|
||||||
|
let key = apikey.key.clone();
|
||||||
|
let val = match apikey.prefix {
|
||||||
|
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||||
|
None => key,
|
||||||
|
};
|
||||||
|
auth_headers.insert("api_key".to_owned(), val);
|
||||||
|
};
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
@ -277,22 +384,44 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn update_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
fn update_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
let method = hyper::Method::Put;
|
let method = hyper::Method::Put;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&body).unwrap();
|
let serialized = serde_json::to_string(&body).unwrap();
|
||||||
req.headers_mut().set(hyper::header::ContentType::json());
|
req.headers_mut().set(hyper::header::ContentType::json());
|
||||||
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
||||||
@ -322,22 +451,44 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
let method = hyper::Method::Post;
|
let method = hyper::Method::Post;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
@ -363,22 +514,44 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
|
|||||||
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Box<Future<Item = ::models::ApiResponse, Error = Error<serde_json::Value>>> {
|
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Box<Future<Item = ::models::ApiResponse, Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref token) = configuration.oauth_access_token {
|
||||||
|
let auth = hyper::header::Authorization(
|
||||||
|
hyper::header::Bearer {
|
||||||
|
token: token.to_owned(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
auth_headers.insert("Authorization".to_owned(), auth.to_string());
|
||||||
|
};
|
||||||
let method = hyper::Method::Post;
|
let method = hyper::Method::Post;
|
||||||
|
|
||||||
let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/pet/{petId}/uploadImage?{}", configuration.base_path, query_string, petId=pet_id);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use hyper;
|
use hyper;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
@ -47,14 +48,19 @@ impl<C: hyper::client::Connect>StoreApi for StoreApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Delete;
|
let method = hyper::Method::Delete;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -62,6 +68,7 @@ impl<C: hyper::client::Connect>StoreApi for StoreApiClient<C> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
configuration.client.request(req)
|
configuration.client.request(req)
|
||||||
@ -86,22 +93,44 @@ impl<C: hyper::client::Connect>StoreApi for StoreApiClient<C> {
|
|||||||
fn get_inventory(&self, ) -> Box<Future<Item = ::std::collections::HashMap<String, i32>, Error = Error<serde_json::Value>>> {
|
fn get_inventory(&self, ) -> Box<Future<Item = ::std::collections::HashMap<String, i32>, Error = Error<serde_json::Value>>> {
|
||||||
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
let configuration: &configuration::Configuration<C> = self.configuration.borrow();
|
||||||
|
|
||||||
|
let mut auth_headers = HashMap::<String, String>::new();
|
||||||
|
let mut auth_query = HashMap::<String, String>::new();
|
||||||
|
if let Some(ref apikey) = configuration.api_key {
|
||||||
|
let key = apikey.key.clone();
|
||||||
|
let val = match apikey.prefix {
|
||||||
|
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||||
|
None => key,
|
||||||
|
};
|
||||||
|
auth_headers.insert("api_key".to_owned(), val);
|
||||||
|
};
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/inventory", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
for (key, val) in &auth_query {
|
||||||
|
query.append_pair(key, val);
|
||||||
|
}
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/inventory?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (key, val) in auth_headers {
|
||||||
|
req.headers_mut().set_raw(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
@ -132,14 +161,19 @@ impl<C: hyper::client::Connect>StoreApi for StoreApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -147,6 +181,7 @@ impl<C: hyper::client::Connect>StoreApi for StoreApiClient<C> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
configuration.client.request(req)
|
configuration.client.request(req)
|
||||||
@ -176,20 +211,26 @@ impl<C: hyper::client::Connect>StoreApi for StoreApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Post;
|
let method = hyper::Method::Post;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/order", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/store/order?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&body).unwrap();
|
let serialized = serde_json::to_string(&body).unwrap();
|
||||||
req.headers_mut().set(hyper::header::ContentType::json());
|
req.headers_mut().set(hyper::header::ContentType::json());
|
||||||
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use hyper;
|
use hyper;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
@ -51,20 +52,26 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Post;
|
let method = hyper::Method::Post;
|
||||||
|
|
||||||
let uri_str = format!("{}/user", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&body).unwrap();
|
let serialized = serde_json::to_string(&body).unwrap();
|
||||||
req.headers_mut().set(hyper::header::ContentType::json());
|
req.headers_mut().set(hyper::header::ContentType::json());
|
||||||
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
||||||
@ -96,20 +103,26 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Post;
|
let method = hyper::Method::Post;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/createWithArray", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/createWithArray?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&body).unwrap();
|
let serialized = serde_json::to_string(&body).unwrap();
|
||||||
req.headers_mut().set(hyper::header::ContentType::json());
|
req.headers_mut().set(hyper::header::ContentType::json());
|
||||||
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
||||||
@ -141,20 +154,26 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Post;
|
let method = hyper::Method::Post;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/createWithList", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/createWithList?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&body).unwrap();
|
let serialized = serde_json::to_string(&body).unwrap();
|
||||||
req.headers_mut().set(hyper::header::ContentType::json());
|
req.headers_mut().set(hyper::header::ContentType::json());
|
||||||
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
||||||
@ -186,14 +205,19 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Delete;
|
let method = hyper::Method::Delete;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=username);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -201,6 +225,7 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
configuration.client.request(req)
|
configuration.client.request(req)
|
||||||
@ -227,14 +252,19 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=username);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -242,6 +272,7 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
configuration.client.request(req)
|
configuration.client.request(req)
|
||||||
@ -271,18 +302,21 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let query = ::url::form_urlencoded::Serializer::new(String::new())
|
let query_string = {
|
||||||
.append_pair("username", &username.to_string())
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
.append_pair("password", &password.to_string())
|
query.append_pair("username", &username.to_string());
|
||||||
.finish();
|
query.append_pair("password", &password.to_string());
|
||||||
let uri_str = format!("{}/user/login{}", configuration.base_path, query);
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/login?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -290,6 +324,7 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
configuration.client.request(req)
|
configuration.client.request(req)
|
||||||
@ -319,14 +354,19 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Get;
|
let method = hyper::Method::Get;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/logout", configuration.base_path);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/logout?{}", configuration.base_path, query_string);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
@ -334,6 +374,7 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
Box::new(
|
Box::new(
|
||||||
configuration.client.request(req)
|
configuration.client.request(req)
|
||||||
@ -360,20 +401,26 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
|
|||||||
|
|
||||||
let method = hyper::Method::Put;
|
let method = hyper::Method::Put;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=username);
|
let query_string = {
|
||||||
|
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
|
||||||
|
query.finish()
|
||||||
|
};
|
||||||
|
let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username);
|
||||||
|
|
||||||
let uri = uri_str.parse();
|
|
||||||
// TODO(farcaller): handle error
|
// TODO(farcaller): handle error
|
||||||
// if let Err(e) = uri {
|
// if let Err(e) = uri {
|
||||||
// return Box::new(futures::future::err(e));
|
// return Box::new(futures::future::err(e));
|
||||||
// }
|
// }
|
||||||
let mut req = hyper::Request::new(method, uri.unwrap());
|
let mut uri: hyper::Uri = uri_str.parse().unwrap();
|
||||||
|
|
||||||
|
let mut req = hyper::Request::new(method, uri);
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
req.headers_mut().set(UserAgent::new(Cow::Owned(user_agent.clone())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&body).unwrap();
|
let serialized = serde_json::to_string(&body).unwrap();
|
||||||
req.headers_mut().set(hyper::header::ContentType::json());
|
req.headers_mut().set(hyper::header::ContentType::json());
|
||||||
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
req.headers_mut().set(hyper::header::ContentLength(serialized.len() as u64));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user