forked from loafle/openapi-generator-original
Fix enum types in structs (#3309)
I already contributed proper enum supports a few weeks ago, but somehow missed actually using them when they're used as a property. This PR fixes that. I also took the liberty of fixing a bunch of unused warnings. * Make sure we use the enum types in Rust * Fix unused warnings in Rust and regenerate samples * Use crate:: import path that works both with Rust 2015 and 2018 * Derive PartialEq and Eq in generated Rust structs and enums
This commit is contained in:
parent
a4b1c269d8
commit
2e81e612fc
@ -49,8 +49,6 @@ impl<T> From<serde_json::Error> for Error<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use super::models::*;
|
|
||||||
|
|
||||||
mod request;
|
mod request;
|
||||||
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
|
@ -3,8 +3,7 @@ use std::rc::Rc;
|
|||||||
use hyper;
|
use hyper;
|
||||||
use super::configuration::Configuration;
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
pub struct APIClient<C: hyper::client::Connect> {
|
pub struct APIClient {
|
||||||
configuration: Rc<Configuration<C>>,
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
@ -18,12 +17,11 @@ pub struct APIClient<C: hyper::client::Connect> {
|
|||||||
{{/apiInfo}}
|
{{/apiInfo}}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: hyper::client::Connect> APIClient<C> {
|
impl APIClient {
|
||||||
pub fn new(configuration: Configuration<C>) -> APIClient<C> {
|
pub fn new<C: hyper::client::Connect>(configuration: Configuration<C>) -> APIClient {
|
||||||
let rc = Rc::new(configuration);
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
APIClient {
|
APIClient {
|
||||||
configuration: rc.clone(),
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{{>partial_header}}
|
{{>partial_header}}
|
||||||
use hyper;
|
use hyper;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub struct Configuration<C: hyper::client::Connect> {
|
pub struct Configuration<C: hyper::client::Connect> {
|
||||||
pub base_path: String,
|
pub base_path: String,
|
||||||
|
@ -20,14 +20,14 @@ pub enum {{classname}} {
|
|||||||
|
|
||||||
{{!-- for non-enum schemas --}}
|
{{!-- for non-enum schemas --}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct {{{classname}}} {
|
pub struct {{{classname}}} {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#description}}
|
{{#description}}
|
||||||
/// {{{description}}}
|
/// {{{description}}}
|
||||||
{{/description}}
|
{{/description}}
|
||||||
#[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})]
|
#[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})]
|
||||||
pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{{dataType}}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
|
pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ impl {{{classname}}} {
|
|||||||
{{#description}}
|
{{#description}}
|
||||||
/// {{{description}}}
|
/// {{{description}}}
|
||||||
{{/description}}
|
{{/description}}
|
||||||
pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||||
{{{classname}}} {
|
{{{classname}}} {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}},
|
{{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}},
|
||||||
@ -49,7 +49,7 @@ impl {{{classname}}} {
|
|||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
/// {{{description}}}
|
/// {{{description}}}
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum {{enumName}} {
|
pub enum {{enumName}} {
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}
|
{{#enumVars}}
|
||||||
|
@ -24,6 +24,7 @@ impl ApiKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) enum Auth {
|
pub(crate) enum Auth {
|
||||||
None,
|
None,
|
||||||
ApiKey(ApiKey),
|
ApiKey(ApiKey),
|
||||||
|
@ -4,7 +4,7 @@ use std::borrow::Borrow;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
use super::{Error, configuration, urlencode};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct {{{classname}}}Client {
|
pub struct {{{classname}}}Client {
|
||||||
configuration: Rc<configuration::Configuration>,
|
configuration: Rc<configuration::Configuration>,
|
||||||
@ -33,7 +33,7 @@ impl {{{classname}}} for {{{classname}}}Client {
|
|||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}urlencode({{/isString}}{{{paramName}}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}});
|
let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}});
|
||||||
let mut req_builder = client.{{{httpMethod}}}(uri_str.as_str());
|
let mut req_builder = client.{{{httpMethod}}}(uri_str.as_str());
|
||||||
|
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
|
@ -30,8 +30,6 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
|||||||
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
use super::models::*;
|
|
||||||
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
mod {{{classFilename}}};
|
mod {{{classFilename}}};
|
||||||
|
@ -3,7 +3,6 @@ use std::rc::Rc;
|
|||||||
use super::configuration::Configuration;
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
pub struct APIClient {
|
pub struct APIClient {
|
||||||
configuration: Rc<Configuration>,
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
@ -22,7 +21,6 @@ impl APIClient {
|
|||||||
let rc = Rc::new(configuration);
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
APIClient {
|
APIClient {
|
||||||
configuration: rc.clone(),
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
4.0.3-SNAPSHOT
|
@ -3,7 +3,6 @@ use std::rc::Rc;
|
|||||||
use super::configuration::Configuration;
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
pub struct APIClient {
|
pub struct APIClient {
|
||||||
configuration: Rc<Configuration>,
|
|
||||||
pet_api: Box<crate::apis::PetApi>,
|
pet_api: Box<crate::apis::PetApi>,
|
||||||
store_api: Box<crate::apis::StoreApi>,
|
store_api: Box<crate::apis::StoreApi>,
|
||||||
user_api: Box<crate::apis::UserApi>,
|
user_api: Box<crate::apis::UserApi>,
|
||||||
@ -14,7 +13,6 @@ impl APIClient {
|
|||||||
let rc = Rc::new(configuration);
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
APIClient {
|
APIClient {
|
||||||
configuration: rc.clone(),
|
|
||||||
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
||||||
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
||||||
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
||||||
|
34
samples/client/petstore/rust-reqwest/src/apis/client.rs.orig
Normal file
34
samples/client/petstore/rust-reqwest/src/apis/client.rs.orig
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
|
pub struct APIClient {
|
||||||
|
pet_api: Box<crate::apis::PetApi>,
|
||||||
|
store_api: Box<crate::apis::StoreApi>,
|
||||||
|
user_api: Box<crate::apis::UserApi>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl APIClient {
|
||||||
|
pub fn new(configuration: Configuration) -> APIClient {
|
||||||
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
|
APIClient {
|
||||||
|
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
||||||
|
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
||||||
|
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pet_api(&self) -> &crate::apis::PetApi{
|
||||||
|
self.pet_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn store_api(&self) -> &crate::apis::StoreApi{
|
||||||
|
self.store_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn user_api(&self) -> &crate::apis::UserApi{
|
||||||
|
self.user_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -30,8 +30,6 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
|
|||||||
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
use super::models::*;
|
|
||||||
|
|
||||||
mod pet_api;
|
mod pet_api;
|
||||||
pub use self::pet_api::{ PetApi, PetApiClient };
|
pub use self::pet_api::{ PetApi, PetApiClient };
|
||||||
mod store_api;
|
mod store_api;
|
||||||
|
@ -13,7 +13,7 @@ use std::borrow::Borrow;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
use super::{Error, configuration, urlencode};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct PetApiClient {
|
pub struct PetApiClient {
|
||||||
configuration: Rc<configuration::Configuration>,
|
configuration: Rc<configuration::Configuration>,
|
||||||
|
@ -13,7 +13,7 @@ use std::borrow::Borrow;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
use super::{Error, configuration, urlencode};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct StoreApiClient {
|
pub struct StoreApiClient {
|
||||||
configuration: Rc<configuration::Configuration>,
|
configuration: Rc<configuration::Configuration>,
|
||||||
@ -39,7 +39,7 @@ impl StoreApi for StoreApiClient {
|
|||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=urlencode(order_id));
|
let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(order_id));
|
||||||
let mut req_builder = client.delete(uri_str.as_str());
|
let mut req_builder = client.delete(uri_str.as_str());
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
@ -13,7 +13,7 @@ use std::borrow::Borrow;
|
|||||||
|
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
|
||||||
use super::{Error, configuration, urlencode};
|
use super::{Error, configuration};
|
||||||
|
|
||||||
pub struct UserApiClient {
|
pub struct UserApiClient {
|
||||||
configuration: Rc<configuration::Configuration>,
|
configuration: Rc<configuration::Configuration>,
|
||||||
@ -100,7 +100,7 @@ impl UserApi for UserApiClient {
|
|||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username));
|
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||||
let mut req_builder = client.delete(uri_str.as_str());
|
let mut req_builder = client.delete(uri_str.as_str());
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
@ -118,7 +118,7 @@ impl UserApi for UserApiClient {
|
|||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username));
|
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||||
let mut req_builder = client.get(uri_str.as_str());
|
let mut req_builder = client.get(uri_str.as_str());
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
@ -172,7 +172,7 @@ impl UserApi for UserApiClient {
|
|||||||
let configuration: &configuration::Configuration = self.configuration.borrow();
|
let configuration: &configuration::Configuration = self.configuration.borrow();
|
||||||
let client = &configuration.client;
|
let client = &configuration.client;
|
||||||
|
|
||||||
let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username));
|
let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(username));
|
||||||
let mut req_builder = client.put(uri_str.as_str());
|
let mut req_builder = client.put(uri_str.as_str());
|
||||||
|
|
||||||
if let Some(ref user_agent) = configuration.user_agent {
|
if let Some(ref user_agent) = configuration.user_agent {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// ApiResponse : Describes the result of uploading an image resource
|
/// ApiResponse : Describes the result of uploading an image resource
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ApiResponse {
|
pub struct ApiResponse {
|
||||||
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
|
||||||
pub code: Option<i32>,
|
pub code: Option<i32>,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Category : A category for a pet
|
/// Category : A category for a pet
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Category {
|
pub struct Category {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Order : An order for a pets from the pet store
|
/// Order : An order for a pets from the pet store
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Order {
|
pub struct Order {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
@ -23,7 +23,7 @@ pub struct Order {
|
|||||||
pub ship_date: Option<String>,
|
pub ship_date: Option<String>,
|
||||||
/// Order Status
|
/// Order Status
|
||||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||||
pub status: Option<String>,
|
pub status: Option<Status>,
|
||||||
#[serde(rename = "complete", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "complete", skip_serializing_if = "Option::is_none")]
|
||||||
pub complete: Option<bool>,
|
pub complete: Option<bool>,
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ impl Order {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Order Status
|
/// Order Status
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
#[serde(rename = "placed")]
|
#[serde(rename = "placed")]
|
||||||
Placed,
|
Placed,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Pet : A pet for sale in the pet store
|
/// Pet : A pet for sale in the pet store
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Pet {
|
pub struct Pet {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
@ -25,7 +25,7 @@ pub struct Pet {
|
|||||||
pub tags: Option<Vec<crate::models::Tag>>,
|
pub tags: Option<Vec<crate::models::Tag>>,
|
||||||
/// pet status in the store
|
/// pet status in the store
|
||||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||||
pub status: Option<String>,
|
pub status: Option<Status>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pet {
|
impl Pet {
|
||||||
@ -43,7 +43,7 @@ impl Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// pet status in the store
|
/// pet status in the store
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
#[serde(rename = "available")]
|
#[serde(rename = "available")]
|
||||||
Available,
|
Available,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Tag : A tag for a pet
|
/// Tag : A tag for a pet
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Tag {
|
pub struct Tag {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// User : A User who is purchasing from the pet store
|
/// User : A User who is purchasing from the pet store
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
4.0.3-SNAPSHOT
|
@ -3,19 +3,17 @@ use std::rc::Rc;
|
|||||||
use hyper;
|
use hyper;
|
||||||
use super::configuration::Configuration;
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
pub struct APIClient<C: hyper::client::Connect> {
|
pub struct APIClient {
|
||||||
configuration: Rc<Configuration<C>>,
|
|
||||||
pet_api: Box<crate::apis::PetApi>,
|
pet_api: Box<crate::apis::PetApi>,
|
||||||
store_api: Box<crate::apis::StoreApi>,
|
store_api: Box<crate::apis::StoreApi>,
|
||||||
user_api: Box<crate::apis::UserApi>,
|
user_api: Box<crate::apis::UserApi>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: hyper::client::Connect> APIClient<C> {
|
impl APIClient {
|
||||||
pub fn new(configuration: Configuration<C>) -> APIClient<C> {
|
pub fn new<C: hyper::client::Connect>(configuration: Configuration<C>) -> APIClient {
|
||||||
let rc = Rc::new(configuration);
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
APIClient {
|
APIClient {
|
||||||
configuration: rc.clone(),
|
|
||||||
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
||||||
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
||||||
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
||||||
|
35
samples/client/petstore/rust/src/apis/client.rs.orig
Normal file
35
samples/client/petstore/rust/src/apis/client.rs.orig
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use hyper;
|
||||||
|
use super::configuration::Configuration;
|
||||||
|
|
||||||
|
pub struct APIClient {
|
||||||
|
pet_api: Box<crate::apis::PetApi>,
|
||||||
|
store_api: Box<crate::apis::StoreApi>,
|
||||||
|
user_api: Box<crate::apis::UserApi>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl APIClient {
|
||||||
|
pub fn new<C: hyper::client::Connect>(configuration: Configuration<C>) -> APIClient {
|
||||||
|
let rc = Rc::new(configuration);
|
||||||
|
|
||||||
|
APIClient {
|
||||||
|
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
|
||||||
|
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
|
||||||
|
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pet_api(&self) -> &crate::apis::PetApi{
|
||||||
|
self.pet_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn store_api(&self) -> &crate::apis::StoreApi{
|
||||||
|
self.store_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn user_api(&self) -> &crate::apis::UserApi{
|
||||||
|
self.user_api.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use hyper;
|
use hyper;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub struct Configuration<C: hyper::client::Connect> {
|
pub struct Configuration<C: hyper::client::Connect> {
|
||||||
pub base_path: String,
|
pub base_path: String,
|
||||||
|
@ -49,8 +49,6 @@ impl<T> From<serde_json::Error> for Error<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use super::models::*;
|
|
||||||
|
|
||||||
mod request;
|
mod request;
|
||||||
|
|
||||||
mod pet_api;
|
mod pet_api;
|
||||||
|
@ -24,6 +24,7 @@ impl ApiKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub(crate) enum Auth {
|
pub(crate) enum Auth {
|
||||||
None,
|
None,
|
||||||
ApiKey(ApiKey),
|
ApiKey(ApiKey),
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// ApiResponse : Describes the result of uploading an image resource
|
/// ApiResponse : Describes the result of uploading an image resource
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ApiResponse {
|
pub struct ApiResponse {
|
||||||
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
|
||||||
pub code: Option<i32>,
|
pub code: Option<i32>,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Category : A category for a pet
|
/// Category : A category for a pet
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Category {
|
pub struct Category {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Order : An order for a pets from the pet store
|
/// Order : An order for a pets from the pet store
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Order {
|
pub struct Order {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
@ -23,7 +23,7 @@ pub struct Order {
|
|||||||
pub ship_date: Option<String>,
|
pub ship_date: Option<String>,
|
||||||
/// Order Status
|
/// Order Status
|
||||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||||
pub status: Option<String>,
|
pub status: Option<Status>,
|
||||||
#[serde(rename = "complete", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "complete", skip_serializing_if = "Option::is_none")]
|
||||||
pub complete: Option<bool>,
|
pub complete: Option<bool>,
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ impl Order {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Order Status
|
/// Order Status
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
#[serde(rename = "placed")]
|
#[serde(rename = "placed")]
|
||||||
Placed,
|
Placed,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Pet : A pet for sale in the pet store
|
/// Pet : A pet for sale in the pet store
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Pet {
|
pub struct Pet {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
@ -25,7 +25,7 @@ pub struct Pet {
|
|||||||
pub tags: Option<Vec<crate::models::Tag>>,
|
pub tags: Option<Vec<crate::models::Tag>>,
|
||||||
/// pet status in the store
|
/// pet status in the store
|
||||||
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
|
||||||
pub status: Option<String>,
|
pub status: Option<Status>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pet {
|
impl Pet {
|
||||||
@ -43,7 +43,7 @@ impl Pet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// pet status in the store
|
/// pet status in the store
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
#[serde(rename = "available")]
|
#[serde(rename = "available")]
|
||||||
Available,
|
Available,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// Tag : A tag for a pet
|
/// Tag : A tag for a pet
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Tag {
|
pub struct Tag {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/// User : A User who is purchasing from the pet store
|
/// User : A User who is purchasing from the pet store
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||||
pub id: Option<i64>,
|
pub id: Option<i64>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user