forked from loafle/openapi-generator-original
[Rust][Client] Code format (#2042)
Rust clients code format cleanup (with some breaking changes for model structures): * Application of Rust style in client files (4 spaces padding). Remove useless blank lines. * Replace getters/setters in models by public fields. * Add a trailing comma in struct fields. * Sample Rust clients regeneration.
This commit is contained in:
parent
ea08106c80
commit
b6c2266a14
@ -52,5 +52,4 @@ impl<C: hyper::client::Connect> APIClient<C> {
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ pub struct {{{classname}}} {
|
||||
/// {{{description}}}
|
||||
{{/description}}
|
||||
#[serde(rename = "{{{baseName}}}")]
|
||||
{{{name}}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
pub {{{name}}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
@ -26,34 +26,11 @@ impl {{{classname}}} {
|
||||
pub fn new({{#requiredVars}}{{{name}}}: {{{dataType}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||
{{{classname}}} {
|
||||
{{#vars}}
|
||||
{{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
|
||||
{{#vars}}
|
||||
pub fn set_{{{name}}}(&mut self, {{{name}}}: {{{dataType}}}) {
|
||||
self.{{{name}}} = {{^required}}Some({{{name}}}){{/required}}{{#required}}{{{name}}}{{/required}};
|
||||
}
|
||||
|
||||
pub fn with_{{{name}}}(mut self, {{{name}}}: {{{dataType}}}) -> {{{classname}}} {
|
||||
self.{{{name}}} = {{^required}}Some({{{name}}}){{/required}}{{#required}}{{{name}}}{{/required}};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn {{{name}}}(&self) -> {{^required}}Option<{{/required}}&{{{dataType}}}{{^required}}>{{/required}} {
|
||||
{{#required}}&{{/required}}self.{{{name}}}{{^required}}.as_ref(){{/required}}
|
||||
}
|
||||
|
||||
{{^required}}
|
||||
pub fn reset_{{{name}}}(&mut self) {
|
||||
self.{{{name}}} = None;
|
||||
}
|
||||
{{/required}}
|
||||
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
{{#isEnum}}
|
||||
// TODO enum
|
||||
// List of {{{name}}}
|
||||
@ -65,7 +42,5 @@ impl {{{classname}}} {
|
||||
// {{/allowableValues}}
|
||||
//)
|
||||
{{/isEnum}}
|
||||
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
@ -4,6 +4,3 @@ mod {{{classFilename}}};
|
||||
pub use self::{{{classFilename}}}::{{{classname}}};
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
// TODO(farcaller): sort out files
|
||||
pub struct File;
|
||||
|
@ -39,7 +39,10 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
{{#queryParams}}
|
||||
req_builder = req_builder.query(&[("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string())]);
|
||||
{{/queryParams}}
|
||||
{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInQuery}}
|
||||
if let Some(ref apikey) = configuration.api_key {
|
||||
let key = apikey.key.clone();
|
||||
let val = match apikey.prefix {
|
||||
@ -48,15 +51,22 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
};
|
||||
req_builder = req_builder.query(&[("{{{keyParamName}}}", val)]);
|
||||
}
|
||||
{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
{{#hasHeaderParams}}{{#headerParams}}
|
||||
{{#hasHeaderParams}}
|
||||
{{#headerParams}}
|
||||
req_builder = req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
|
||||
{{/headerParams}}{{/hasHeaderParams}}
|
||||
{{#hasAuthMethods}}{{#authMethods}}
|
||||
{{#isApiKey}}{{#isKeyInHeader}}
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
if let Some(ref apikey) = configuration.api_key {
|
||||
let key = apikey.key.clone();
|
||||
let val = match apikey.prefix {
|
||||
@ -65,7 +75,8 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
};
|
||||
req_builder = req_builder.header("{{{keyParamName}}}", val);
|
||||
};
|
||||
{{/isKeyInHeader}}{{/isApiKey}}
|
||||
{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
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());
|
||||
@ -76,8 +87,10 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}{{/hasAuthMethods}}
|
||||
{{#isMultipart}}{{#hasFormParams}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
{{#isMultipart}}
|
||||
{{#hasFormParams}}
|
||||
let form = reqwest::multipart::Form::new()
|
||||
{{#formParams}}
|
||||
{{#isFile}}
|
||||
@ -88,8 +101,10 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
{{/isFile}}
|
||||
{{/formParams}}
|
||||
req_builder = req_builder.multipart(form);
|
||||
{{/hasFormParams}}{{/isMultipart}}
|
||||
{{^isMultipart}}{{#hasFormParams}}
|
||||
{{/hasFormParams}}
|
||||
{{/isMultipart}}
|
||||
{{^isMultipart}}
|
||||
{{#hasFormParams}}
|
||||
let mut form_params = std::collections::HashMap::new();
|
||||
{{#formParams}}
|
||||
{{#isFile}}
|
||||
@ -100,10 +115,13 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
{{/isFile}}
|
||||
{{/formParams}}
|
||||
req_builder = req_builder.form(&form_params);
|
||||
{{/hasFormParams}}{{/isMultipart}}
|
||||
{{#hasBodyParam}}{{#bodyParams}}
|
||||
{{/hasFormParams}}
|
||||
{{/isMultipart}}
|
||||
{{#hasBodyParam}}
|
||||
{{#bodyParams}}
|
||||
req_builder = req_builder.json(&{{{paramName}}});
|
||||
{{/bodyParams}}{{/hasBodyParam}}
|
||||
{{/bodyParams}}
|
||||
{{/hasBodyParam}}
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
@ -51,5 +51,4 @@ impl APIClient {
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
}
|
||||
|
@ -33,5 +33,4 @@ impl APIClient {
|
||||
self.user_api.as_ref()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -46,23 +46,14 @@ impl PetApi for PetApiClient {
|
||||
let uri_str = format!("{}/pet", configuration.base_path);
|
||||
let mut req_builder = client.post(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -77,23 +68,14 @@ impl PetApi for PetApiClient {
|
||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||
let mut req_builder = client.delete(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
req_builder = req_builder.header("api_key", api_key.to_string());
|
||||
|
||||
|
||||
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -109,21 +91,13 @@ impl PetApi for PetApiClient {
|
||||
let mut req_builder = client.get(uri_str.as_str());
|
||||
|
||||
req_builder = req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -138,21 +112,13 @@ impl PetApi for PetApiClient {
|
||||
let mut req_builder = client.get(uri_str.as_str());
|
||||
|
||||
req_builder = req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]);
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -166,13 +132,9 @@ impl PetApi for PetApiClient {
|
||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||
let mut req_builder = client.get(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref apikey) = configuration.api_key {
|
||||
let key = apikey.key.clone();
|
||||
let val = match apikey.prefix {
|
||||
@ -182,11 +144,6 @@ impl PetApi for PetApiClient {
|
||||
req_builder = req_builder.header("api_key", val);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -200,23 +157,14 @@ impl PetApi for PetApiClient {
|
||||
let uri_str = format!("{}/pet", configuration.base_path);
|
||||
let mut req_builder = client.put(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -231,26 +179,17 @@ impl PetApi for PetApiClient {
|
||||
let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id);
|
||||
let mut req_builder = client.post(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
|
||||
|
||||
let mut form_params = std::collections::HashMap::new();
|
||||
form_params.insert("name", name.to_string());
|
||||
form_params.insert("status", status.to_string());
|
||||
req_builder = req_builder.form(&form_params);
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -265,26 +204,17 @@ impl PetApi for PetApiClient {
|
||||
let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id);
|
||||
let mut req_builder = client.post(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
|
||||
|
||||
|
||||
let mut form_params = std::collections::HashMap::new();
|
||||
form_params.insert("additionalMetadata", additional_metadata.to_string());
|
||||
form_params.insert("file", unimplemented!("File form param not supported with x-www-form-urlencoded content"));
|
||||
req_builder = req_builder.form(&form_params);
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
|
@ -42,16 +42,10 @@ impl StoreApi for StoreApiClient {
|
||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=urlencode(order_id));
|
||||
let mut req_builder = client.delete(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -66,13 +60,9 @@ impl StoreApi for StoreApiClient {
|
||||
let uri_str = format!("{}/store/inventory", configuration.base_path);
|
||||
let mut req_builder = client.get(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if let Some(ref apikey) = configuration.api_key {
|
||||
let key = apikey.key.clone();
|
||||
let val = match apikey.prefix {
|
||||
@ -82,11 +72,6 @@ impl StoreApi for StoreApiClient {
|
||||
req_builder = req_builder.header("api_key", val);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -100,16 +85,10 @@ impl StoreApi for StoreApiClient {
|
||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id);
|
||||
let mut req_builder = client.get(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -123,18 +102,11 @@ impl StoreApi for StoreApiClient {
|
||||
let uri_str = format!("{}/store/order", configuration.base_path);
|
||||
let mut req_builder = client.post(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
|
@ -46,18 +46,11 @@ impl UserApi for UserApiClient {
|
||||
let uri_str = format!("{}/user", configuration.base_path);
|
||||
let mut req_builder = client.post(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -72,18 +65,11 @@ impl UserApi for UserApiClient {
|
||||
let uri_str = format!("{}/user/createWithArray", configuration.base_path);
|
||||
let mut req_builder = client.post(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -98,18 +84,11 @@ impl UserApi for UserApiClient {
|
||||
let uri_str = format!("{}/user/createWithList", configuration.base_path);
|
||||
let mut req_builder = client.post(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -124,16 +103,10 @@ impl UserApi for UserApiClient {
|
||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username));
|
||||
let mut req_builder = client.delete(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -148,16 +121,10 @@ impl UserApi for UserApiClient {
|
||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username));
|
||||
let mut req_builder = client.get(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -173,16 +140,10 @@ impl UserApi for UserApiClient {
|
||||
|
||||
req_builder = req_builder.query(&[("username", &username.to_string())]);
|
||||
req_builder = req_builder.query(&[("password", &password.to_string())]);
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -196,16 +157,10 @@ impl UserApi for UserApiClient {
|
||||
let uri_str = format!("{}/user/logout", configuration.base_path);
|
||||
let mut req_builder = client.get(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
@ -220,18 +175,11 @@ impl UserApi for UserApiClient {
|
||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username));
|
||||
let mut req_builder = client.put(uri_str.as_str());
|
||||
|
||||
|
||||
if let Some(ref user_agent) = configuration.user_agent {
|
||||
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
req_builder = req_builder.json(&body);
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
|
||||
|
@ -16,11 +16,11 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ApiResponse {
|
||||
#[serde(rename = "code")]
|
||||
code: Option<i32>,
|
||||
pub code: Option<i32>,
|
||||
#[serde(rename = "type")]
|
||||
_type: Option<String>,
|
||||
pub _type: Option<String>,
|
||||
#[serde(rename = "message")]
|
||||
message: Option<String>
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
impl ApiResponse {
|
||||
@ -29,62 +29,7 @@ impl ApiResponse {
|
||||
ApiResponse {
|
||||
code: None,
|
||||
_type: None,
|
||||
message: None
|
||||
message: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_code(&mut self, code: i32) {
|
||||
self.code = Some(code);
|
||||
}
|
||||
|
||||
pub fn with_code(mut self, code: i32) -> ApiResponse {
|
||||
self.code = Some(code);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn code(&self) -> Option<&i32> {
|
||||
self.code.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_code(&mut self) {
|
||||
self.code = None;
|
||||
}
|
||||
|
||||
pub fn set__type(&mut self, _type: String) {
|
||||
self._type = Some(_type);
|
||||
}
|
||||
|
||||
pub fn with__type(mut self, _type: String) -> ApiResponse {
|
||||
self._type = Some(_type);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn _type(&self) -> Option<&String> {
|
||||
self._type.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset__type(&mut self) {
|
||||
self._type = None;
|
||||
}
|
||||
|
||||
pub fn set_message(&mut self, message: String) {
|
||||
self.message = Some(message);
|
||||
}
|
||||
|
||||
pub fn with_message(mut self, message: String) -> ApiResponse {
|
||||
self.message = Some(message);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn message(&self) -> Option<&String> {
|
||||
self.message.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_message(&mut self) {
|
||||
self.message = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Category {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Category {
|
||||
@ -26,45 +26,7 @@ impl Category {
|
||||
pub fn new() -> Category {
|
||||
Category {
|
||||
id: None,
|
||||
name: None
|
||||
name: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Category {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, name: String) {
|
||||
self.name = Some(name);
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: String) -> Category {
|
||||
self.name = Some(name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<&String> {
|
||||
self.name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_name(&mut self) {
|
||||
self.name = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -10,6 +10,3 @@ mod tag;
|
||||
pub use self::tag::Tag;
|
||||
mod user;
|
||||
pub use self::user::User;
|
||||
|
||||
// TODO(farcaller): sort out files
|
||||
pub struct File;
|
||||
|
@ -16,18 +16,18 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Order {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "petId")]
|
||||
pet_id: Option<i64>,
|
||||
pub pet_id: Option<i64>,
|
||||
#[serde(rename = "quantity")]
|
||||
quantity: Option<i32>,
|
||||
pub quantity: Option<i32>,
|
||||
#[serde(rename = "shipDate")]
|
||||
ship_date: Option<String>,
|
||||
pub ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>,
|
||||
pub status: Option<String>,
|
||||
#[serde(rename = "complete")]
|
||||
complete: Option<bool>
|
||||
pub complete: Option<bool>,
|
||||
}
|
||||
|
||||
impl Order {
|
||||
@ -39,113 +39,7 @@ impl Order {
|
||||
quantity: None,
|
||||
ship_date: None,
|
||||
status: None,
|
||||
complete: None
|
||||
complete: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Order {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_pet_id(&mut self, pet_id: i64) {
|
||||
self.pet_id = Some(pet_id);
|
||||
}
|
||||
|
||||
pub fn with_pet_id(mut self, pet_id: i64) -> Order {
|
||||
self.pet_id = Some(pet_id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pet_id(&self) -> Option<&i64> {
|
||||
self.pet_id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_pet_id(&mut self) {
|
||||
self.pet_id = None;
|
||||
}
|
||||
|
||||
pub fn set_quantity(&mut self, quantity: i32) {
|
||||
self.quantity = Some(quantity);
|
||||
}
|
||||
|
||||
pub fn with_quantity(mut self, quantity: i32) -> Order {
|
||||
self.quantity = Some(quantity);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn quantity(&self) -> Option<&i32> {
|
||||
self.quantity.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_quantity(&mut self) {
|
||||
self.quantity = None;
|
||||
}
|
||||
|
||||
pub fn set_ship_date(&mut self, ship_date: String) {
|
||||
self.ship_date = Some(ship_date);
|
||||
}
|
||||
|
||||
pub fn with_ship_date(mut self, ship_date: String) -> Order {
|
||||
self.ship_date = Some(ship_date);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn ship_date(&self) -> Option<&String> {
|
||||
self.ship_date.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_ship_date(&mut self) {
|
||||
self.ship_date = None;
|
||||
}
|
||||
|
||||
pub fn set_status(&mut self, status: String) {
|
||||
self.status = Some(status);
|
||||
}
|
||||
|
||||
pub fn with_status(mut self, status: String) -> Order {
|
||||
self.status = Some(status);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn status(&self) -> Option<&String> {
|
||||
self.status.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_status(&mut self) {
|
||||
self.status = None;
|
||||
}
|
||||
|
||||
pub fn set_complete(&mut self, complete: bool) {
|
||||
self.complete = Some(complete);
|
||||
}
|
||||
|
||||
pub fn with_complete(mut self, complete: bool) -> Order {
|
||||
self.complete = Some(complete);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn complete(&self) -> Option<&bool> {
|
||||
self.complete.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_complete(&mut self) {
|
||||
self.complete = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,18 +16,18 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Pet {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "category")]
|
||||
category: Option<::models::Category>,
|
||||
pub category: Option<::models::Category>,
|
||||
#[serde(rename = "name")]
|
||||
name: String,
|
||||
pub name: String,
|
||||
#[serde(rename = "photoUrls")]
|
||||
photo_urls: Vec<String>,
|
||||
pub photo_urls: Vec<String>,
|
||||
#[serde(rename = "tags")]
|
||||
tags: Option<Vec<::models::Tag>>,
|
||||
pub tags: Option<Vec<::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>
|
||||
pub status: Option<String>,
|
||||
}
|
||||
|
||||
impl Pet {
|
||||
@ -39,107 +39,7 @@ impl Pet {
|
||||
name: name,
|
||||
photo_urls: photo_urls,
|
||||
tags: None,
|
||||
status: None
|
||||
status: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Pet {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_category(&mut self, category: ::models::Category) {
|
||||
self.category = Some(category);
|
||||
}
|
||||
|
||||
pub fn with_category(mut self, category: ::models::Category) -> Pet {
|
||||
self.category = Some(category);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn category(&self) -> Option<&::models::Category> {
|
||||
self.category.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_category(&mut self) {
|
||||
self.category = None;
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, name: String) {
|
||||
self.name = name;
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: String) -> Pet {
|
||||
self.name = name;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &String {
|
||||
&self.name
|
||||
}
|
||||
|
||||
|
||||
pub fn set_photo_urls(&mut self, photo_urls: Vec<String>) {
|
||||
self.photo_urls = photo_urls;
|
||||
}
|
||||
|
||||
pub fn with_photo_urls(mut self, photo_urls: Vec<String>) -> Pet {
|
||||
self.photo_urls = photo_urls;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn photo_urls(&self) -> &Vec<String> {
|
||||
&self.photo_urls
|
||||
}
|
||||
|
||||
|
||||
pub fn set_tags(&mut self, tags: Vec<::models::Tag>) {
|
||||
self.tags = Some(tags);
|
||||
}
|
||||
|
||||
pub fn with_tags(mut self, tags: Vec<::models::Tag>) -> Pet {
|
||||
self.tags = Some(tags);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn tags(&self) -> Option<&Vec<::models::Tag>> {
|
||||
self.tags.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_tags(&mut self) {
|
||||
self.tags = None;
|
||||
}
|
||||
|
||||
pub fn set_status(&mut self, status: String) {
|
||||
self.status = Some(status);
|
||||
}
|
||||
|
||||
pub fn with_status(mut self, status: String) -> Pet {
|
||||
self.status = Some(status);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn status(&self) -> Option<&String> {
|
||||
self.status.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_status(&mut self) {
|
||||
self.status = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Tag {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Tag {
|
||||
@ -26,45 +26,7 @@ impl Tag {
|
||||
pub fn new() -> Tag {
|
||||
Tag {
|
||||
id: None,
|
||||
name: None
|
||||
name: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Tag {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, name: String) {
|
||||
self.name = Some(name);
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: String) -> Tag {
|
||||
self.name = Some(name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<&String> {
|
||||
self.name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_name(&mut self) {
|
||||
self.name = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,22 +16,22 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "username")]
|
||||
username: Option<String>,
|
||||
pub username: Option<String>,
|
||||
#[serde(rename = "firstName")]
|
||||
first_name: Option<String>,
|
||||
pub first_name: Option<String>,
|
||||
#[serde(rename = "lastName")]
|
||||
last_name: Option<String>,
|
||||
pub last_name: Option<String>,
|
||||
#[serde(rename = "email")]
|
||||
email: Option<String>,
|
||||
pub email: Option<String>,
|
||||
#[serde(rename = "password")]
|
||||
password: Option<String>,
|
||||
pub password: Option<String>,
|
||||
#[serde(rename = "phone")]
|
||||
phone: Option<String>,
|
||||
pub phone: Option<String>,
|
||||
/// User Status
|
||||
#[serde(rename = "userStatus")]
|
||||
user_status: Option<i32>
|
||||
pub user_status: Option<i32>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
@ -45,147 +45,7 @@ impl User {
|
||||
email: None,
|
||||
password: None,
|
||||
phone: None,
|
||||
user_status: None
|
||||
user_status: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> User {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_username(&mut self, username: String) {
|
||||
self.username = Some(username);
|
||||
}
|
||||
|
||||
pub fn with_username(mut self, username: String) -> User {
|
||||
self.username = Some(username);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn username(&self) -> Option<&String> {
|
||||
self.username.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_username(&mut self) {
|
||||
self.username = None;
|
||||
}
|
||||
|
||||
pub fn set_first_name(&mut self, first_name: String) {
|
||||
self.first_name = Some(first_name);
|
||||
}
|
||||
|
||||
pub fn with_first_name(mut self, first_name: String) -> User {
|
||||
self.first_name = Some(first_name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn first_name(&self) -> Option<&String> {
|
||||
self.first_name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_first_name(&mut self) {
|
||||
self.first_name = None;
|
||||
}
|
||||
|
||||
pub fn set_last_name(&mut self, last_name: String) {
|
||||
self.last_name = Some(last_name);
|
||||
}
|
||||
|
||||
pub fn with_last_name(mut self, last_name: String) -> User {
|
||||
self.last_name = Some(last_name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_name(&self) -> Option<&String> {
|
||||
self.last_name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_last_name(&mut self) {
|
||||
self.last_name = None;
|
||||
}
|
||||
|
||||
pub fn set_email(&mut self, email: String) {
|
||||
self.email = Some(email);
|
||||
}
|
||||
|
||||
pub fn with_email(mut self, email: String) -> User {
|
||||
self.email = Some(email);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn email(&self) -> Option<&String> {
|
||||
self.email.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_email(&mut self) {
|
||||
self.email = None;
|
||||
}
|
||||
|
||||
pub fn set_password(&mut self, password: String) {
|
||||
self.password = Some(password);
|
||||
}
|
||||
|
||||
pub fn with_password(mut self, password: String) -> User {
|
||||
self.password = Some(password);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn password(&self) -> Option<&String> {
|
||||
self.password.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_password(&mut self) {
|
||||
self.password = None;
|
||||
}
|
||||
|
||||
pub fn set_phone(&mut self, phone: String) {
|
||||
self.phone = Some(phone);
|
||||
}
|
||||
|
||||
pub fn with_phone(mut self, phone: String) -> User {
|
||||
self.phone = Some(phone);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn phone(&self) -> Option<&String> {
|
||||
self.phone.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_phone(&mut self) {
|
||||
self.phone = None;
|
||||
}
|
||||
|
||||
pub fn set_user_status(&mut self, user_status: i32) {
|
||||
self.user_status = Some(user_status);
|
||||
}
|
||||
|
||||
pub fn with_user_status(mut self, user_status: i32) -> User {
|
||||
self.user_status = Some(user_status);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn user_status(&self) -> Option<&i32> {
|
||||
self.user_status.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_user_status(&mut self) {
|
||||
self.user_status = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -34,5 +34,4 @@ impl<C: hyper::client::Connect> APIClient<C> {
|
||||
self.user_api.as_ref()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ApiResponse {
|
||||
#[serde(rename = "code")]
|
||||
code: Option<i32>,
|
||||
pub code: Option<i32>,
|
||||
#[serde(rename = "type")]
|
||||
_type: Option<String>,
|
||||
pub _type: Option<String>,
|
||||
#[serde(rename = "message")]
|
||||
message: Option<String>
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
impl ApiResponse {
|
||||
@ -29,62 +29,7 @@ impl ApiResponse {
|
||||
ApiResponse {
|
||||
code: None,
|
||||
_type: None,
|
||||
message: None
|
||||
message: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_code(&mut self, code: i32) {
|
||||
self.code = Some(code);
|
||||
}
|
||||
|
||||
pub fn with_code(mut self, code: i32) -> ApiResponse {
|
||||
self.code = Some(code);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn code(&self) -> Option<&i32> {
|
||||
self.code.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_code(&mut self) {
|
||||
self.code = None;
|
||||
}
|
||||
|
||||
pub fn set__type(&mut self, _type: String) {
|
||||
self._type = Some(_type);
|
||||
}
|
||||
|
||||
pub fn with__type(mut self, _type: String) -> ApiResponse {
|
||||
self._type = Some(_type);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn _type(&self) -> Option<&String> {
|
||||
self._type.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset__type(&mut self) {
|
||||
self._type = None;
|
||||
}
|
||||
|
||||
pub fn set_message(&mut self, message: String) {
|
||||
self.message = Some(message);
|
||||
}
|
||||
|
||||
pub fn with_message(mut self, message: String) -> ApiResponse {
|
||||
self.message = Some(message);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn message(&self) -> Option<&String> {
|
||||
self.message.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_message(&mut self) {
|
||||
self.message = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Category {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Category {
|
||||
@ -26,45 +26,7 @@ impl Category {
|
||||
pub fn new() -> Category {
|
||||
Category {
|
||||
id: None,
|
||||
name: None
|
||||
name: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Category {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, name: String) {
|
||||
self.name = Some(name);
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: String) -> Category {
|
||||
self.name = Some(name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<&String> {
|
||||
self.name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_name(&mut self) {
|
||||
self.name = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -10,6 +10,3 @@ mod tag;
|
||||
pub use self::tag::Tag;
|
||||
mod user;
|
||||
pub use self::user::User;
|
||||
|
||||
// TODO(farcaller): sort out files
|
||||
pub struct File;
|
||||
|
@ -16,18 +16,18 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Order {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "petId")]
|
||||
pet_id: Option<i64>,
|
||||
pub pet_id: Option<i64>,
|
||||
#[serde(rename = "quantity")]
|
||||
quantity: Option<i32>,
|
||||
pub quantity: Option<i32>,
|
||||
#[serde(rename = "shipDate")]
|
||||
ship_date: Option<String>,
|
||||
pub ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>,
|
||||
pub status: Option<String>,
|
||||
#[serde(rename = "complete")]
|
||||
complete: Option<bool>
|
||||
pub complete: Option<bool>,
|
||||
}
|
||||
|
||||
impl Order {
|
||||
@ -39,113 +39,7 @@ impl Order {
|
||||
quantity: None,
|
||||
ship_date: None,
|
||||
status: None,
|
||||
complete: None
|
||||
complete: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Order {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_pet_id(&mut self, pet_id: i64) {
|
||||
self.pet_id = Some(pet_id);
|
||||
}
|
||||
|
||||
pub fn with_pet_id(mut self, pet_id: i64) -> Order {
|
||||
self.pet_id = Some(pet_id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pet_id(&self) -> Option<&i64> {
|
||||
self.pet_id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_pet_id(&mut self) {
|
||||
self.pet_id = None;
|
||||
}
|
||||
|
||||
pub fn set_quantity(&mut self, quantity: i32) {
|
||||
self.quantity = Some(quantity);
|
||||
}
|
||||
|
||||
pub fn with_quantity(mut self, quantity: i32) -> Order {
|
||||
self.quantity = Some(quantity);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn quantity(&self) -> Option<&i32> {
|
||||
self.quantity.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_quantity(&mut self) {
|
||||
self.quantity = None;
|
||||
}
|
||||
|
||||
pub fn set_ship_date(&mut self, ship_date: String) {
|
||||
self.ship_date = Some(ship_date);
|
||||
}
|
||||
|
||||
pub fn with_ship_date(mut self, ship_date: String) -> Order {
|
||||
self.ship_date = Some(ship_date);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn ship_date(&self) -> Option<&String> {
|
||||
self.ship_date.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_ship_date(&mut self) {
|
||||
self.ship_date = None;
|
||||
}
|
||||
|
||||
pub fn set_status(&mut self, status: String) {
|
||||
self.status = Some(status);
|
||||
}
|
||||
|
||||
pub fn with_status(mut self, status: String) -> Order {
|
||||
self.status = Some(status);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn status(&self) -> Option<&String> {
|
||||
self.status.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_status(&mut self) {
|
||||
self.status = None;
|
||||
}
|
||||
|
||||
pub fn set_complete(&mut self, complete: bool) {
|
||||
self.complete = Some(complete);
|
||||
}
|
||||
|
||||
pub fn with_complete(mut self, complete: bool) -> Order {
|
||||
self.complete = Some(complete);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn complete(&self) -> Option<&bool> {
|
||||
self.complete.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_complete(&mut self) {
|
||||
self.complete = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,18 +16,18 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Pet {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "category")]
|
||||
category: Option<::models::Category>,
|
||||
pub category: Option<::models::Category>,
|
||||
#[serde(rename = "name")]
|
||||
name: String,
|
||||
pub name: String,
|
||||
#[serde(rename = "photoUrls")]
|
||||
photo_urls: Vec<String>,
|
||||
pub photo_urls: Vec<String>,
|
||||
#[serde(rename = "tags")]
|
||||
tags: Option<Vec<::models::Tag>>,
|
||||
pub tags: Option<Vec<::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>
|
||||
pub status: Option<String>,
|
||||
}
|
||||
|
||||
impl Pet {
|
||||
@ -39,107 +39,7 @@ impl Pet {
|
||||
name: name,
|
||||
photo_urls: photo_urls,
|
||||
tags: None,
|
||||
status: None
|
||||
status: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Pet {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_category(&mut self, category: ::models::Category) {
|
||||
self.category = Some(category);
|
||||
}
|
||||
|
||||
pub fn with_category(mut self, category: ::models::Category) -> Pet {
|
||||
self.category = Some(category);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn category(&self) -> Option<&::models::Category> {
|
||||
self.category.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_category(&mut self) {
|
||||
self.category = None;
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, name: String) {
|
||||
self.name = name;
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: String) -> Pet {
|
||||
self.name = name;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &String {
|
||||
&self.name
|
||||
}
|
||||
|
||||
|
||||
pub fn set_photo_urls(&mut self, photo_urls: Vec<String>) {
|
||||
self.photo_urls = photo_urls;
|
||||
}
|
||||
|
||||
pub fn with_photo_urls(mut self, photo_urls: Vec<String>) -> Pet {
|
||||
self.photo_urls = photo_urls;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn photo_urls(&self) -> &Vec<String> {
|
||||
&self.photo_urls
|
||||
}
|
||||
|
||||
|
||||
pub fn set_tags(&mut self, tags: Vec<::models::Tag>) {
|
||||
self.tags = Some(tags);
|
||||
}
|
||||
|
||||
pub fn with_tags(mut self, tags: Vec<::models::Tag>) -> Pet {
|
||||
self.tags = Some(tags);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn tags(&self) -> Option<&Vec<::models::Tag>> {
|
||||
self.tags.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_tags(&mut self) {
|
||||
self.tags = None;
|
||||
}
|
||||
|
||||
pub fn set_status(&mut self, status: String) {
|
||||
self.status = Some(status);
|
||||
}
|
||||
|
||||
pub fn with_status(mut self, status: String) -> Pet {
|
||||
self.status = Some(status);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn status(&self) -> Option<&String> {
|
||||
self.status.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_status(&mut self) {
|
||||
self.status = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Tag {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Tag {
|
||||
@ -26,45 +26,7 @@ impl Tag {
|
||||
pub fn new() -> Tag {
|
||||
Tag {
|
||||
id: None,
|
||||
name: None
|
||||
name: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> Tag {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_name(&mut self, name: String) {
|
||||
self.name = Some(name);
|
||||
}
|
||||
|
||||
pub fn with_name(mut self, name: String) -> Tag {
|
||||
self.name = Some(name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<&String> {
|
||||
self.name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_name(&mut self) {
|
||||
self.name = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,22 +16,22 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "username")]
|
||||
username: Option<String>,
|
||||
pub username: Option<String>,
|
||||
#[serde(rename = "firstName")]
|
||||
first_name: Option<String>,
|
||||
pub first_name: Option<String>,
|
||||
#[serde(rename = "lastName")]
|
||||
last_name: Option<String>,
|
||||
pub last_name: Option<String>,
|
||||
#[serde(rename = "email")]
|
||||
email: Option<String>,
|
||||
pub email: Option<String>,
|
||||
#[serde(rename = "password")]
|
||||
password: Option<String>,
|
||||
pub password: Option<String>,
|
||||
#[serde(rename = "phone")]
|
||||
phone: Option<String>,
|
||||
pub phone: Option<String>,
|
||||
/// User Status
|
||||
#[serde(rename = "userStatus")]
|
||||
user_status: Option<i32>
|
||||
pub user_status: Option<i32>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
@ -45,147 +45,7 @@ impl User {
|
||||
email: None,
|
||||
password: None,
|
||||
phone: None,
|
||||
user_status: None
|
||||
user_status: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_id(&mut self, id: i64) {
|
||||
self.id = Some(id);
|
||||
}
|
||||
|
||||
pub fn with_id(mut self, id: i64) -> User {
|
||||
self.id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<&i64> {
|
||||
self.id.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_id(&mut self) {
|
||||
self.id = None;
|
||||
}
|
||||
|
||||
pub fn set_username(&mut self, username: String) {
|
||||
self.username = Some(username);
|
||||
}
|
||||
|
||||
pub fn with_username(mut self, username: String) -> User {
|
||||
self.username = Some(username);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn username(&self) -> Option<&String> {
|
||||
self.username.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_username(&mut self) {
|
||||
self.username = None;
|
||||
}
|
||||
|
||||
pub fn set_first_name(&mut self, first_name: String) {
|
||||
self.first_name = Some(first_name);
|
||||
}
|
||||
|
||||
pub fn with_first_name(mut self, first_name: String) -> User {
|
||||
self.first_name = Some(first_name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn first_name(&self) -> Option<&String> {
|
||||
self.first_name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_first_name(&mut self) {
|
||||
self.first_name = None;
|
||||
}
|
||||
|
||||
pub fn set_last_name(&mut self, last_name: String) {
|
||||
self.last_name = Some(last_name);
|
||||
}
|
||||
|
||||
pub fn with_last_name(mut self, last_name: String) -> User {
|
||||
self.last_name = Some(last_name);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_name(&self) -> Option<&String> {
|
||||
self.last_name.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_last_name(&mut self) {
|
||||
self.last_name = None;
|
||||
}
|
||||
|
||||
pub fn set_email(&mut self, email: String) {
|
||||
self.email = Some(email);
|
||||
}
|
||||
|
||||
pub fn with_email(mut self, email: String) -> User {
|
||||
self.email = Some(email);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn email(&self) -> Option<&String> {
|
||||
self.email.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_email(&mut self) {
|
||||
self.email = None;
|
||||
}
|
||||
|
||||
pub fn set_password(&mut self, password: String) {
|
||||
self.password = Some(password);
|
||||
}
|
||||
|
||||
pub fn with_password(mut self, password: String) -> User {
|
||||
self.password = Some(password);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn password(&self) -> Option<&String> {
|
||||
self.password.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_password(&mut self) {
|
||||
self.password = None;
|
||||
}
|
||||
|
||||
pub fn set_phone(&mut self, phone: String) {
|
||||
self.phone = Some(phone);
|
||||
}
|
||||
|
||||
pub fn with_phone(mut self, phone: String) -> User {
|
||||
self.phone = Some(phone);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn phone(&self) -> Option<&String> {
|
||||
self.phone.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_phone(&mut self) {
|
||||
self.phone = None;
|
||||
}
|
||||
|
||||
pub fn set_user_status(&mut self, user_status: i32) {
|
||||
self.user_status = Some(user_status);
|
||||
}
|
||||
|
||||
pub fn with_user_status(mut self, user_status: i32) -> User {
|
||||
self.user_status = Some(user_status);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn user_status(&self) -> Option<&i32> {
|
||||
self.user_status.as_ref()
|
||||
}
|
||||
|
||||
pub fn reset_user_status(&mut self) {
|
||||
self.user_status = None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user