mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 00:43:46 +00:00
Support nullable fields in the Rust generator (#2353)
* Use Option for nullable fields in Rust (closes #2337) * Update Rust's petstore
This commit is contained in:
committed by
William Cheng
parent
d2ce584a3a
commit
a0d907cf27
32
samples/client/petstore/rust/src/models/inline_object.rs
Normal file
32
samples/client/petstore/rust/src/models/inline_object.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct InlineObject {
|
||||
/// Updated name of the pet
|
||||
#[serde(rename = "name")]
|
||||
pub name: Option<String>,
|
||||
/// Updated status of the pet
|
||||
#[serde(rename = "status")]
|
||||
pub status: Option<String>,
|
||||
}
|
||||
|
||||
impl InlineObject {
|
||||
pub fn new() -> InlineObject {
|
||||
InlineObject {
|
||||
name: None,
|
||||
status: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
32
samples/client/petstore/rust/src/models/inline_object_1.rs
Normal file
32
samples/client/petstore/rust/src/models/inline_object_1.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct InlineObject1 {
|
||||
/// Additional data to pass to server
|
||||
#[serde(rename = "additionalMetadata")]
|
||||
pub additional_metadata: Option<String>,
|
||||
/// file to upload
|
||||
#[serde(rename = "file")]
|
||||
pub file: Option<&std::path::Path>,
|
||||
}
|
||||
|
||||
impl InlineObject1 {
|
||||
pub fn new() -> InlineObject1 {
|
||||
InlineObject1 {
|
||||
additional_metadata: None,
|
||||
file: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user