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:
tecywiz121
2019-03-11 21:20:54 -04:00
committed by William Cheng
parent d2ce584a3a
commit a0d907cf27
5 changed files with 88 additions and 2 deletions

View 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,
}
}
}

View 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,
}
}
}