mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
[New Generator] Rust API client generator (#6092)
* Added rust client example * Added a proper apiclient / configuration based example
This commit is contained in:
committed by
wing328
parent
faa62ee40c
commit
1f133e8ecd
8
samples/client/petstore/rust/src/models/category.rs
Normal file
8
samples/client/petstore/rust/src/models/category.rs
Normal 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>,
|
||||
}
|
||||
8
samples/client/petstore/rust/src/models/mod.rs
Normal file
8
samples/client/petstore/rust/src/models/mod.rs
Normal 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;
|
||||
34
samples/client/petstore/rust/src/models/pet.rs
Normal file
34
samples/client/petstore/rust/src/models/pet.rs
Normal 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
|
||||
}
|
||||
}
|
||||
8
samples/client/petstore/rust/src/models/tag.rs
Normal file
8
samples/client/petstore/rust/src/models/tag.rs
Normal 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>,
|
||||
}
|
||||
Reference in New Issue
Block a user