[New Generator] Rust API client generator (#6092)

* Added rust client example

* Added a proper apiclient / configuration based example
This commit is contained in:
Vladimir Pouzanov
2017-07-21 14:58:31 +01:00
committed by wing328
parent faa62ee40c
commit 1f133e8ecd
15 changed files with 339 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/// Pet catehgry
///
/// A category for a pet
#[derive(Debug, Serialize, Deserialize)]
pub struct Category {
id: Option<i64>,
name: Option<String>,
}

View File

@@ -0,0 +1,8 @@
mod pet;
pub use self::pet::Pet;
mod category;
pub use self::category::Category;
mod tag;
pub use self::tag::Tag;

View File

@@ -0,0 +1,34 @@
/// a Pet
///
/// A pet for sale in the pet store
#[derive(Debug, Serialize, Deserialize)]
pub struct Pet {
id: Option<i64>,
category: Option<super::Category>,
name: String,
#[serde(rename = "photoUrls")] photo_urls: Vec<String>,
tags: Vec<super::Tag>,
status: Option<String>,
}
impl Pet {
pub fn new(name: String, photo_urls: Vec<String>) -> Pet {
Pet {
id: None,
category: None,
name: name,
photo_urls: photo_urls,
tags: Vec::new(),
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
}
}

View File

@@ -0,0 +1,8 @@
/// Pet Tag
///
/// A tag for a pet
#[derive(Debug, Serialize, Deserialize)]
pub struct Tag {
id: Option<i64>,
name: Option<String>,
}