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
@ -21,4 +21,4 @@ reqwest = "~0.9"
|
||||
[dev-dependencies]
|
||||
{{#hyper}}
|
||||
tokio-core = "*"
|
||||
{{/hyper}}
|
||||
{{/hyper}}
|
||||
|
@ -4,14 +4,14 @@ use hyper;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient<C: hyper::client::Connect> {
|
||||
configuration: Rc<Configuration<C>>,
|
||||
configuration: Rc<Configuration<C>>,
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
|
||||
{{/-last}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
@ -19,38 +19,37 @@ pub struct APIClient<C: hyper::client::Connect> {
|
||||
}
|
||||
|
||||
impl<C: hyper::client::Connect> APIClient<C> {
|
||||
pub fn new(configuration: Configuration<C>) -> APIClient<C> {
|
||||
let rc = Rc::new(configuration);
|
||||
pub fn new(configuration: Configuration<C>) -> APIClient<C> {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
|
||||
{{/-last}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
|
||||
self.{{{classFilename}}}.as_ref()
|
||||
}
|
||||
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
|
||||
self.{{{classFilename}}}.as_ref()
|
||||
}
|
||||
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
}
|
||||
|
@ -3,31 +3,31 @@ use hyper;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct Configuration<C: hyper::client::Connect> {
|
||||
pub base_path: String,
|
||||
pub user_agent: Option<String>,
|
||||
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 base_path: String,
|
||||
pub user_agent: Option<String>,
|
||||
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,
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::Connect> Configuration<C> {
|
||||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
||||
Configuration {
|
||||
base_path: "{{{basePath}}}".to_owned(),
|
||||
user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}},
|
||||
client: client,
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
api_key: None,
|
||||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
||||
Configuration {
|
||||
base_path: "{{{basePath}}}".to_owned(),
|
||||
user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}},
|
||||
client: client,
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
api_key: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,61 +11,36 @@ use serde_json::Value;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct {{{classname}}} {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{description}}}
|
||||
{{/description}}
|
||||
#[serde(rename = "{{{baseName}}}")]
|
||||
{{{name}}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{#description}}
|
||||
/// {{{description}}}
|
||||
{{/description}}
|
||||
#[serde(rename = "{{{baseName}}}")]
|
||||
pub {{{name}}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
impl {{{classname}}} {
|
||||
{{#description}}
|
||||
/// {{{description}}}
|
||||
{{/description}}
|
||||
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}}
|
||||
{{/vars}}
|
||||
{{#description}}
|
||||
/// {{{description}}}
|
||||
{{/description}}
|
||||
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}},
|
||||
{{/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
|
||||
// TODO enum
|
||||
// List of {{{name}}}
|
||||
//const (
|
||||
// {{#allowableValues}}
|
||||
// {{#enumVars}}
|
||||
// {{{name}}} {{{classname}}} = "{{{value}}}"
|
||||
// {{/enumVars}}
|
||||
// {{/allowableValues}}
|
||||
// {{#allowableValues}}
|
||||
// {{#enumVars}}
|
||||
// {{{name}}} {{{classname}}} = "{{{value}}}"
|
||||
// {{/enumVars}}
|
||||
// {{/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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
{{#appName}}
|
||||
* {{{appName}}}
|
||||
*
|
||||
|
@ -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()?;
|
||||
|
@ -3,14 +3,14 @@ use std::rc::Rc;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient {
|
||||
configuration: Rc<Configuration>,
|
||||
configuration: Rc<Configuration>,
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
|
||||
{{/-last}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
@ -18,38 +18,37 @@ pub struct APIClient {
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
pub fn new(configuration: Configuration) -> APIClient {
|
||||
let rc = Rc::new(configuration);
|
||||
pub fn new(configuration: Configuration) -> APIClient {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
|
||||
{{/-last}}
|
||||
{{#-last}}
|
||||
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-last}}
|
||||
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
|
||||
self.{{{classFilename}}}.as_ref()
|
||||
}
|
||||
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
|
||||
self.{{{classFilename}}}.as_ref()
|
||||
}
|
||||
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ pub struct Configuration {
|
||||
pub type BasicAuth = (String, Option<String>);
|
||||
|
||||
pub struct ApiKey {
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
impl Configuration {
|
||||
|
@ -3,35 +3,34 @@ use std::rc::Rc;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient {
|
||||
configuration: Rc<Configuration>,
|
||||
pet_api: Box<::apis::PetApi>,
|
||||
store_api: Box<::apis::StoreApi>,
|
||||
user_api: Box<::apis::UserApi>,
|
||||
configuration: Rc<Configuration>,
|
||||
pet_api: Box<::apis::PetApi>,
|
||||
store_api: Box<::apis::StoreApi>,
|
||||
user_api: Box<::apis::UserApi>,
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
pub fn new(configuration: Configuration) -> APIClient {
|
||||
let rc = Rc::new(configuration);
|
||||
pub fn new(configuration: Configuration) -> APIClient {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
pet_api: Box::new(::apis::PetApiClient::new(rc.clone())),
|
||||
store_api: Box::new(::apis::StoreApiClient::new(rc.clone())),
|
||||
user_api: Box::new(::apis::UserApiClient::new(rc.clone())),
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
pet_api: Box::new(::apis::PetApiClient::new(rc.clone())),
|
||||
store_api: Box::new(::apis::StoreApiClient::new(rc.clone())),
|
||||
user_api: Box::new(::apis::UserApiClient::new(rc.clone())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pet_api(&self) -> &::apis::PetApi{
|
||||
self.pet_api.as_ref()
|
||||
}
|
||||
pub fn pet_api(&self) -> &::apis::PetApi{
|
||||
self.pet_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn store_api(&self) -> &::apis::StoreApi{
|
||||
self.store_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn user_api(&self) -> &::apis::UserApi{
|
||||
self.user_api.as_ref()
|
||||
}
|
||||
pub fn store_api(&self) -> &::apis::StoreApi{
|
||||
self.store_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn user_api(&self) -> &::apis::UserApi{
|
||||
self.user_api.as_ref()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -24,8 +24,8 @@ pub struct Configuration {
|
||||
pub type BasicAuth = (String, Option<String>);
|
||||
|
||||
pub struct ApiKey {
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
impl Configuration {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -46,22 +46,13 @@ 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,22 +68,13 @@ 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,20 +91,12 @@ 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,20 +112,12 @@ 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 {
|
||||
@ -181,11 +143,6 @@ impl PetApi for PetApiClient {
|
||||
};
|
||||
req_builder = req_builder.header("api_key", val);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
@ -200,22 +157,13 @@ 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,25 +179,16 @@ 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,25 +204,16 @@ 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()?;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -42,15 +42,9 @@ 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 {
|
||||
@ -81,11 +71,6 @@ impl StoreApi for StoreApiClient {
|
||||
};
|
||||
req_builder = req_builder.header("api_key", val);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// send request
|
||||
let req = req_builder.build()?;
|
||||
@ -100,15 +85,9 @@ 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,17 +102,10 @@ 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()?;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -46,17 +46,10 @@ 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,17 +65,10 @@ 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,17 +84,10 @@ 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,15 +103,9 @@ 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,15 +121,9 @@ 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,15 +140,9 @@ 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,15 +157,9 @@ 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,17 +175,10 @@ 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()?;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,76 +15,21 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ApiResponse {
|
||||
#[serde(rename = "code")]
|
||||
code: Option<i32>,
|
||||
#[serde(rename = "type")]
|
||||
_type: Option<String>,
|
||||
#[serde(rename = "message")]
|
||||
message: Option<String>
|
||||
#[serde(rename = "code")]
|
||||
pub code: Option<i32>,
|
||||
#[serde(rename = "type")]
|
||||
pub _type: Option<String>,
|
||||
#[serde(rename = "message")]
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
impl ApiResponse {
|
||||
/// Describes the result of uploading an image resource
|
||||
pub fn new() -> ApiResponse {
|
||||
ApiResponse {
|
||||
code: None,
|
||||
_type: None,
|
||||
message: None
|
||||
/// Describes the result of uploading an image resource
|
||||
pub fn new() -> ApiResponse {
|
||||
ApiResponse {
|
||||
code: None,
|
||||
_type: 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,56 +15,18 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Category {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Category {
|
||||
/// A category for a pet
|
||||
pub fn new() -> Category {
|
||||
Category {
|
||||
id: None,
|
||||
name: None
|
||||
/// A category for a pet
|
||||
pub fn new() -> Category {
|
||||
Category {
|
||||
id: 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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,137 +15,31 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Order {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "petId")]
|
||||
pet_id: Option<i64>,
|
||||
#[serde(rename = "quantity")]
|
||||
quantity: Option<i32>,
|
||||
#[serde(rename = "shipDate")]
|
||||
ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>,
|
||||
#[serde(rename = "complete")]
|
||||
complete: Option<bool>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "petId")]
|
||||
pub pet_id: Option<i64>,
|
||||
#[serde(rename = "quantity")]
|
||||
pub quantity: Option<i32>,
|
||||
#[serde(rename = "shipDate")]
|
||||
pub ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status")]
|
||||
pub status: Option<String>,
|
||||
#[serde(rename = "complete")]
|
||||
pub complete: Option<bool>,
|
||||
}
|
||||
|
||||
impl Order {
|
||||
/// An order for a pets from the pet store
|
||||
pub fn new() -> Order {
|
||||
Order {
|
||||
id: None,
|
||||
pet_id: None,
|
||||
quantity: None,
|
||||
ship_date: None,
|
||||
status: None,
|
||||
complete: None
|
||||
/// An order for a pets from the pet store
|
||||
pub fn new() -> Order {
|
||||
Order {
|
||||
id: None,
|
||||
pet_id: None,
|
||||
quantity: None,
|
||||
ship_date: None,
|
||||
status: None,
|
||||
complete: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,131 +15,31 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Pet {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "category")]
|
||||
category: Option<::models::Category>,
|
||||
#[serde(rename = "name")]
|
||||
name: String,
|
||||
#[serde(rename = "photoUrls")]
|
||||
photo_urls: Vec<String>,
|
||||
#[serde(rename = "tags")]
|
||||
tags: Option<Vec<::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "category")]
|
||||
pub category: Option<::models::Category>,
|
||||
#[serde(rename = "name")]
|
||||
pub name: String,
|
||||
#[serde(rename = "photoUrls")]
|
||||
pub photo_urls: Vec<String>,
|
||||
#[serde(rename = "tags")]
|
||||
pub tags: Option<Vec<::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status")]
|
||||
pub status: Option<String>,
|
||||
}
|
||||
|
||||
impl Pet {
|
||||
/// A pet for sale in the pet store
|
||||
pub fn new(name: String, photo_urls: Vec<String>) -> Pet {
|
||||
Pet {
|
||||
id: None,
|
||||
category: None,
|
||||
name: name,
|
||||
photo_urls: photo_urls,
|
||||
tags: None,
|
||||
status: None
|
||||
/// A pet for sale in the pet store
|
||||
pub fn new(name: String, photo_urls: Vec<String>) -> Pet {
|
||||
Pet {
|
||||
id: None,
|
||||
category: None,
|
||||
name: name,
|
||||
photo_urls: photo_urls,
|
||||
tags: 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,56 +15,18 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Tag {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Tag {
|
||||
/// A tag for a pet
|
||||
pub fn new() -> Tag {
|
||||
Tag {
|
||||
id: None,
|
||||
name: None
|
||||
/// A tag for a pet
|
||||
pub fn new() -> Tag {
|
||||
Tag {
|
||||
id: 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,177 +15,37 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "username")]
|
||||
username: Option<String>,
|
||||
#[serde(rename = "firstName")]
|
||||
first_name: Option<String>,
|
||||
#[serde(rename = "lastName")]
|
||||
last_name: Option<String>,
|
||||
#[serde(rename = "email")]
|
||||
email: Option<String>,
|
||||
#[serde(rename = "password")]
|
||||
password: Option<String>,
|
||||
#[serde(rename = "phone")]
|
||||
phone: Option<String>,
|
||||
/// User Status
|
||||
#[serde(rename = "userStatus")]
|
||||
user_status: Option<i32>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "username")]
|
||||
pub username: Option<String>,
|
||||
#[serde(rename = "firstName")]
|
||||
pub first_name: Option<String>,
|
||||
#[serde(rename = "lastName")]
|
||||
pub last_name: Option<String>,
|
||||
#[serde(rename = "email")]
|
||||
pub email: Option<String>,
|
||||
#[serde(rename = "password")]
|
||||
pub password: Option<String>,
|
||||
#[serde(rename = "phone")]
|
||||
pub phone: Option<String>,
|
||||
/// User Status
|
||||
#[serde(rename = "userStatus")]
|
||||
pub user_status: Option<i32>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
/// A User who is purchasing from the pet store
|
||||
pub fn new() -> User {
|
||||
User {
|
||||
id: None,
|
||||
username: None,
|
||||
first_name: None,
|
||||
last_name: None,
|
||||
email: None,
|
||||
password: None,
|
||||
phone: None,
|
||||
user_status: None
|
||||
/// A User who is purchasing from the pet store
|
||||
pub fn new() -> User {
|
||||
User {
|
||||
id: None,
|
||||
username: None,
|
||||
first_name: None,
|
||||
last_name: None,
|
||||
email: None,
|
||||
password: None,
|
||||
phone: 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -4,35 +4,34 @@ use hyper;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient<C: hyper::client::Connect> {
|
||||
configuration: Rc<Configuration<C>>,
|
||||
pet_api: Box<::apis::PetApi>,
|
||||
store_api: Box<::apis::StoreApi>,
|
||||
user_api: Box<::apis::UserApi>,
|
||||
configuration: Rc<Configuration<C>>,
|
||||
pet_api: Box<::apis::PetApi>,
|
||||
store_api: Box<::apis::StoreApi>,
|
||||
user_api: Box<::apis::UserApi>,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::Connect> APIClient<C> {
|
||||
pub fn new(configuration: Configuration<C>) -> APIClient<C> {
|
||||
let rc = Rc::new(configuration);
|
||||
pub fn new(configuration: Configuration<C>) -> APIClient<C> {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
pet_api: Box::new(::apis::PetApiClient::new(rc.clone())),
|
||||
store_api: Box::new(::apis::StoreApiClient::new(rc.clone())),
|
||||
user_api: Box::new(::apis::UserApiClient::new(rc.clone())),
|
||||
APIClient {
|
||||
configuration: rc.clone(),
|
||||
pet_api: Box::new(::apis::PetApiClient::new(rc.clone())),
|
||||
store_api: Box::new(::apis::StoreApiClient::new(rc.clone())),
|
||||
user_api: Box::new(::apis::UserApiClient::new(rc.clone())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pet_api(&self) -> &::apis::PetApi{
|
||||
self.pet_api.as_ref()
|
||||
}
|
||||
pub fn pet_api(&self) -> &::apis::PetApi{
|
||||
self.pet_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn store_api(&self) -> &::apis::StoreApi{
|
||||
self.store_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn user_api(&self) -> &::apis::UserApi{
|
||||
self.user_api.as_ref()
|
||||
}
|
||||
pub fn store_api(&self) -> &::apis::StoreApi{
|
||||
self.store_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn user_api(&self) -> &::apis::UserApi{
|
||||
self.user_api.as_ref()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -12,31 +12,31 @@ use hyper;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct Configuration<C: hyper::client::Connect> {
|
||||
pub base_path: String,
|
||||
pub user_agent: Option<String>,
|
||||
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 base_path: String,
|
||||
pub user_agent: Option<String>,
|
||||
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,
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::Connect> Configuration<C> {
|
||||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
||||
Configuration {
|
||||
base_path: "http://petstore.swagger.io/v2".to_owned(),
|
||||
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
|
||||
client: client,
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
api_key: None,
|
||||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
||||
Configuration {
|
||||
base_path: "http://petstore.swagger.io/v2".to_owned(),
|
||||
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
|
||||
client: client,
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
api_key: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,76 +15,21 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ApiResponse {
|
||||
#[serde(rename = "code")]
|
||||
code: Option<i32>,
|
||||
#[serde(rename = "type")]
|
||||
_type: Option<String>,
|
||||
#[serde(rename = "message")]
|
||||
message: Option<String>
|
||||
#[serde(rename = "code")]
|
||||
pub code: Option<i32>,
|
||||
#[serde(rename = "type")]
|
||||
pub _type: Option<String>,
|
||||
#[serde(rename = "message")]
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
impl ApiResponse {
|
||||
/// Describes the result of uploading an image resource
|
||||
pub fn new() -> ApiResponse {
|
||||
ApiResponse {
|
||||
code: None,
|
||||
_type: None,
|
||||
message: None
|
||||
/// Describes the result of uploading an image resource
|
||||
pub fn new() -> ApiResponse {
|
||||
ApiResponse {
|
||||
code: None,
|
||||
_type: 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,56 +15,18 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Category {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Category {
|
||||
/// A category for a pet
|
||||
pub fn new() -> Category {
|
||||
Category {
|
||||
id: None,
|
||||
name: None
|
||||
/// A category for a pet
|
||||
pub fn new() -> Category {
|
||||
Category {
|
||||
id: 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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,137 +15,31 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Order {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "petId")]
|
||||
pet_id: Option<i64>,
|
||||
#[serde(rename = "quantity")]
|
||||
quantity: Option<i32>,
|
||||
#[serde(rename = "shipDate")]
|
||||
ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>,
|
||||
#[serde(rename = "complete")]
|
||||
complete: Option<bool>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "petId")]
|
||||
pub pet_id: Option<i64>,
|
||||
#[serde(rename = "quantity")]
|
||||
pub quantity: Option<i32>,
|
||||
#[serde(rename = "shipDate")]
|
||||
pub ship_date: Option<String>,
|
||||
/// Order Status
|
||||
#[serde(rename = "status")]
|
||||
pub status: Option<String>,
|
||||
#[serde(rename = "complete")]
|
||||
pub complete: Option<bool>,
|
||||
}
|
||||
|
||||
impl Order {
|
||||
/// An order for a pets from the pet store
|
||||
pub fn new() -> Order {
|
||||
Order {
|
||||
id: None,
|
||||
pet_id: None,
|
||||
quantity: None,
|
||||
ship_date: None,
|
||||
status: None,
|
||||
complete: None
|
||||
/// An order for a pets from the pet store
|
||||
pub fn new() -> Order {
|
||||
Order {
|
||||
id: None,
|
||||
pet_id: None,
|
||||
quantity: None,
|
||||
ship_date: None,
|
||||
status: None,
|
||||
complete: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,131 +15,31 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Pet {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "category")]
|
||||
category: Option<::models::Category>,
|
||||
#[serde(rename = "name")]
|
||||
name: String,
|
||||
#[serde(rename = "photoUrls")]
|
||||
photo_urls: Vec<String>,
|
||||
#[serde(rename = "tags")]
|
||||
tags: Option<Vec<::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status")]
|
||||
status: Option<String>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "category")]
|
||||
pub category: Option<::models::Category>,
|
||||
#[serde(rename = "name")]
|
||||
pub name: String,
|
||||
#[serde(rename = "photoUrls")]
|
||||
pub photo_urls: Vec<String>,
|
||||
#[serde(rename = "tags")]
|
||||
pub tags: Option<Vec<::models::Tag>>,
|
||||
/// pet status in the store
|
||||
#[serde(rename = "status")]
|
||||
pub status: Option<String>,
|
||||
}
|
||||
|
||||
impl Pet {
|
||||
/// A pet for sale in the pet store
|
||||
pub fn new(name: String, photo_urls: Vec<String>) -> Pet {
|
||||
Pet {
|
||||
id: None,
|
||||
category: None,
|
||||
name: name,
|
||||
photo_urls: photo_urls,
|
||||
tags: None,
|
||||
status: None
|
||||
/// A pet for sale in the pet store
|
||||
pub fn new(name: String, photo_urls: Vec<String>) -> Pet {
|
||||
Pet {
|
||||
id: None,
|
||||
category: None,
|
||||
name: name,
|
||||
photo_urls: photo_urls,
|
||||
tags: 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,56 +15,18 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Tag {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
name: Option<String>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "name")]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl Tag {
|
||||
/// A tag for a pet
|
||||
pub fn new() -> Tag {
|
||||
Tag {
|
||||
id: None,
|
||||
name: None
|
||||
/// A tag for a pet
|
||||
pub fn new() -> Tag {
|
||||
Tag {
|
||||
id: 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
@ -15,177 +15,37 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
#[serde(rename = "id")]
|
||||
id: Option<i64>,
|
||||
#[serde(rename = "username")]
|
||||
username: Option<String>,
|
||||
#[serde(rename = "firstName")]
|
||||
first_name: Option<String>,
|
||||
#[serde(rename = "lastName")]
|
||||
last_name: Option<String>,
|
||||
#[serde(rename = "email")]
|
||||
email: Option<String>,
|
||||
#[serde(rename = "password")]
|
||||
password: Option<String>,
|
||||
#[serde(rename = "phone")]
|
||||
phone: Option<String>,
|
||||
/// User Status
|
||||
#[serde(rename = "userStatus")]
|
||||
user_status: Option<i32>
|
||||
#[serde(rename = "id")]
|
||||
pub id: Option<i64>,
|
||||
#[serde(rename = "username")]
|
||||
pub username: Option<String>,
|
||||
#[serde(rename = "firstName")]
|
||||
pub first_name: Option<String>,
|
||||
#[serde(rename = "lastName")]
|
||||
pub last_name: Option<String>,
|
||||
#[serde(rename = "email")]
|
||||
pub email: Option<String>,
|
||||
#[serde(rename = "password")]
|
||||
pub password: Option<String>,
|
||||
#[serde(rename = "phone")]
|
||||
pub phone: Option<String>,
|
||||
/// User Status
|
||||
#[serde(rename = "userStatus")]
|
||||
pub user_status: Option<i32>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
/// A User who is purchasing from the pet store
|
||||
pub fn new() -> User {
|
||||
User {
|
||||
id: None,
|
||||
username: None,
|
||||
first_name: None,
|
||||
last_name: None,
|
||||
email: None,
|
||||
password: None,
|
||||
phone: None,
|
||||
user_status: None
|
||||
/// A User who is purchasing from the pet store
|
||||
pub fn new() -> User {
|
||||
User {
|
||||
id: None,
|
||||
username: None,
|
||||
first_name: None,
|
||||
last_name: None,
|
||||
email: None,
|
||||
password: None,
|
||||
phone: 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