diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index f18dc2f1408..ba7d821a117 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -15,7 +15,7 @@ pub struct {{{classname}}} { /// {{{description}}} {{/description}} #[serde(rename = "{{{baseName}}}")] - pub {{{name}}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}, + pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{{dataType}}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}}, {{/vars}} } @@ -23,7 +23,7 @@ impl {{{classname}}} { {{#description}} /// {{{description}}} {{/description}} - pub fn new({{#requiredVars}}{{{name}}}: {{{dataType}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} { + pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} { {{{classname}}} { {{#vars}} {{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}, diff --git a/samples/client/petstore/rust/docs/InlineObject.md b/samples/client/petstore/rust/docs/InlineObject.md new file mode 100644 index 00000000000..ae2c737efca --- /dev/null +++ b/samples/client/petstore/rust/docs/InlineObject.md @@ -0,0 +1,11 @@ +# InlineObject + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | Updated name of the pet | [optional] +**status** | **String** | Updated status of the pet | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/docs/InlineObject1.md b/samples/client/petstore/rust/docs/InlineObject1.md new file mode 100644 index 00000000000..02ca4d03484 --- /dev/null +++ b/samples/client/petstore/rust/docs/InlineObject1.md @@ -0,0 +1,11 @@ +# InlineObject1 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additional_metadata** | **String** | Additional data to pass to server | [optional] +**file** | [***&std::path::Path**](&std::path::Path.md) | file to upload | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/src/models/inline_object.rs b/samples/client/petstore/rust/src/models/inline_object.rs new file mode 100644 index 00000000000..2fa0cfa4f63 --- /dev/null +++ b/samples/client/petstore/rust/src/models/inline_object.rs @@ -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, + /// Updated status of the pet + #[serde(rename = "status")] + pub status: Option, +} + +impl InlineObject { + pub fn new() -> InlineObject { + InlineObject { + name: None, + status: None, + } + } +} diff --git a/samples/client/petstore/rust/src/models/inline_object_1.rs b/samples/client/petstore/rust/src/models/inline_object_1.rs new file mode 100644 index 00000000000..a7e3b098fe7 --- /dev/null +++ b/samples/client/petstore/rust/src/models/inline_object_1.rs @@ -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, + /// file to upload + #[serde(rename = "file")] + pub file: Option<&std::path::Path>, +} + +impl InlineObject1 { + pub fn new() -> InlineObject1 { + InlineObject1 { + additional_metadata: None, + file: None, + } + } +}