From 63f6569e6f8a06cea2d9e5b6539848ce6df7d42c Mon Sep 17 00:00:00 2001 From: Thomas von Rosenberg <39494325+tvrg@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:25:01 +0100 Subject: [PATCH] [rust] Fix model constructor for required enum array (#14196) For a required enum array property the generated model constructor used the type `RequiredEnums` instead of `Vec`. --- .../src/main/resources/rust/model.mustache | 2 +- .../src/test/resources/3_0/rust/petstore.yaml | 13 +++++- .../hyper/petstore/.openapi-generator/FILES | 2 + .../petstore/rust/hyper/petstore/README.md | 1 + .../hyper/petstore/docs/EnumArrayTesting.md | 11 +++++ .../petstore/src/models/enum_array_testing.rs | 46 +++++++++++++++++++ .../rust/hyper/petstore/src/models/mod.rs | 2 + .../.openapi-generator/FILES | 2 + .../petstore-async-middleware/README.md | 1 + .../docs/EnumArrayTesting.md | 11 +++++ .../src/models/enum_array_testing.rs | 46 +++++++++++++++++++ .../src/models/mod.rs | 2 + .../petstore-async/.openapi-generator/FILES | 2 + .../rust/reqwest/petstore-async/README.md | 1 + .../petstore-async/docs/EnumArrayTesting.md | 11 +++++ .../src/models/enum_array_testing.rs | 46 +++++++++++++++++++ .../reqwest/petstore-async/src/models/mod.rs | 2 + .../.openapi-generator/FILES | 2 + .../reqwest/petstore-awsv4signature/README.md | 1 + .../docs/EnumArrayTesting.md | 11 +++++ .../src/models/enum_array_testing.rs | 46 +++++++++++++++++++ .../petstore-awsv4signature/src/models/mod.rs | 2 + .../reqwest/petstore/.openapi-generator/FILES | 2 + .../petstore/rust/reqwest/petstore/README.md | 1 + .../reqwest/petstore/docs/EnumArrayTesting.md | 11 +++++ .../petstore/src/models/enum_array_testing.rs | 46 +++++++++++++++++++ .../rust/reqwest/petstore/src/models/mod.rs | 2 + 27 files changed, 323 insertions(+), 2 deletions(-) create mode 100644 samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md create mode 100644 samples/client/petstore/rust/hyper/petstore/src/models/enum_array_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/enum_array_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-async/src/models/enum_array_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/enum_array_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore/src/models/enum_array_testing.rs diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index 2fcad1fbf367..ffb29f1dd429 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -79,7 +79,7 @@ impl {{{classname}}} { {{#description}} /// {{{.}}} {{/description}} - pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} { + pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{#isArray}}Vec<{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} { {{{classname}}} { {{#vars}} {{{name}}}{{^required}}{{#isArray}}: None{{/isArray}}{{#isMap}}: None{{/isMap}}{{^isContainer}}: None{{/isContainer}}{{/required}}{{#required}}{{#isModel}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/isModel}}{{/required}}, diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml index e72f1e21e95b..8d1679467c7b 100644 --- a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml @@ -877,4 +877,15 @@ components: nullable: true required_nullable: type: string - nullable: true \ No newline at end of file + nullable: true + EnumArrayTesting: + description: Test of enum array + type: object + required: + - required_enums + properties: + required_enums: + type: array + items: + type: string + enum: ["A", "B", "C"] diff --git a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES index eeea90f1b1c7..867a49a5fc29 100644 --- a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES @@ -6,6 +6,7 @@ docs/ActionContainer.md docs/ApiResponse.md docs/Baz.md docs/Category.md +docs/EnumArrayTesting.md docs/FakeApi.md docs/OptionalTesting.md docs/Order.md @@ -34,6 +35,7 @@ src/models/action_container.rs src/models/api_response.rs src/models/baz.rs src/models/category.rs +src/models/enum_array_testing.rs src/models/mod.rs src/models/model_return.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/hyper/petstore/README.md b/samples/client/petstore/rust/hyper/petstore/README.md index f92feb9d9f6f..e8fdb7278e1c 100644 --- a/samples/client/petstore/rust/hyper/petstore/README.md +++ b/samples/client/petstore/rust/hyper/petstore/README.md @@ -56,6 +56,7 @@ Class | Method | HTTP request | Description - [ApiResponse](docs/ApiResponse.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) + - [EnumArrayTesting](docs/EnumArrayTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md b/samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md new file mode 100644 index 000000000000..fb4c54df47d5 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md @@ -0,0 +1,11 @@ +# EnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | | + +[[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/hyper/petstore/src/models/enum_array_testing.rs b/samples/client/petstore/rust/hyper/petstore/src/models/enum_array_testing.rs new file mode 100644 index 000000000000..815ebbac72f5 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/enum_array_testing.rs @@ -0,0 +1,46 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// EnumArrayTesting : Test of enum array + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct EnumArrayTesting { + #[serde(rename = "required_enums")] + pub required_enums: Vec, +} + +impl EnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> EnumArrayTesting { + EnumArrayTesting { + required_enums, + } + } +} + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RequiredEnums { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "C")] + C, +} + +impl Default for RequiredEnums { + fn default() -> RequiredEnums { + Self::A + } +} + diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs index c528fd499bd6..b92cce18b275 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs @@ -6,6 +6,8 @@ pub mod baz; pub use self::baz::Baz; pub mod category; pub use self::category::Category; +pub mod enum_array_testing; +pub use self::enum_array_testing::EnumArrayTesting; pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES index 4b2347f5e64c..3a11dc47e550 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES @@ -6,6 +6,7 @@ docs/ActionContainer.md docs/ApiResponse.md docs/Baz.md docs/Category.md +docs/EnumArrayTesting.md docs/FakeApi.md docs/OptionalTesting.md docs/Order.md @@ -32,6 +33,7 @@ src/models/action_container.rs src/models/api_response.rs src/models/baz.rs src/models/category.rs +src/models/enum_array_testing.rs src/models/mod.rs src/models/model_return.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md index 1509c190bfe6..6b569b157784 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md @@ -56,6 +56,7 @@ Class | Method | HTTP request | Description - [ApiResponse](docs/ApiResponse.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) + - [EnumArrayTesting](docs/EnumArrayTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md new file mode 100644 index 000000000000..fb4c54df47d5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md @@ -0,0 +1,11 @@ +# EnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | | + +[[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/reqwest/petstore-async-middleware/src/models/enum_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/enum_array_testing.rs new file mode 100644 index 000000000000..815ebbac72f5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/enum_array_testing.rs @@ -0,0 +1,46 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// EnumArrayTesting : Test of enum array + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct EnumArrayTesting { + #[serde(rename = "required_enums")] + pub required_enums: Vec, +} + +impl EnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> EnumArrayTesting { + EnumArrayTesting { + required_enums, + } + } +} + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RequiredEnums { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "C")] + C, +} + +impl Default for RequiredEnums { + fn default() -> RequiredEnums { + Self::A + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs index c528fd499bd6..b92cce18b275 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs @@ -6,6 +6,8 @@ pub mod baz; pub use self::baz::Baz; pub mod category; pub use self::category::Category; +pub mod enum_array_testing; +pub use self::enum_array_testing::EnumArrayTesting; pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES index 4b2347f5e64c..3a11dc47e550 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES @@ -6,6 +6,7 @@ docs/ActionContainer.md docs/ApiResponse.md docs/Baz.md docs/Category.md +docs/EnumArrayTesting.md docs/FakeApi.md docs/OptionalTesting.md docs/Order.md @@ -32,6 +33,7 @@ src/models/action_container.rs src/models/api_response.rs src/models/baz.rs src/models/category.rs +src/models/enum_array_testing.rs src/models/mod.rs src/models/model_return.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async/README.md b/samples/client/petstore/rust/reqwest/petstore-async/README.md index 0d2259c258cd..0de8d36614af 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/README.md @@ -56,6 +56,7 @@ Class | Method | HTTP request | Description - [ApiResponse](docs/ApiResponse.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) + - [EnumArrayTesting](docs/EnumArrayTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md new file mode 100644 index 000000000000..fb4c54df47d5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md @@ -0,0 +1,11 @@ +# EnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | | + +[[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/reqwest/petstore-async/src/models/enum_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/enum_array_testing.rs new file mode 100644 index 000000000000..815ebbac72f5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/enum_array_testing.rs @@ -0,0 +1,46 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// EnumArrayTesting : Test of enum array + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct EnumArrayTesting { + #[serde(rename = "required_enums")] + pub required_enums: Vec, +} + +impl EnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> EnumArrayTesting { + EnumArrayTesting { + required_enums, + } + } +} + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RequiredEnums { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "C")] + C, +} + +impl Default for RequiredEnums { + fn default() -> RequiredEnums { + Self::A + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs index c528fd499bd6..b92cce18b275 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs @@ -6,6 +6,8 @@ pub mod baz; pub use self::baz::Baz; pub mod category; pub use self::category::Category; +pub mod enum_array_testing; +pub use self::enum_array_testing::EnumArrayTesting; pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES index 4b2347f5e64c..3a11dc47e550 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES @@ -6,6 +6,7 @@ docs/ActionContainer.md docs/ApiResponse.md docs/Baz.md docs/Category.md +docs/EnumArrayTesting.md docs/FakeApi.md docs/OptionalTesting.md docs/Order.md @@ -32,6 +33,7 @@ src/models/action_container.rs src/models/api_response.rs src/models/baz.rs src/models/category.rs +src/models/enum_array_testing.rs src/models/mod.rs src/models/model_return.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md index 6aa08b5fdf6a..ce9b8c08e276 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md @@ -56,6 +56,7 @@ Class | Method | HTTP request | Description - [ApiResponse](docs/ApiResponse.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) + - [EnumArrayTesting](docs/EnumArrayTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md new file mode 100644 index 000000000000..fb4c54df47d5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md @@ -0,0 +1,11 @@ +# EnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | | + +[[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/reqwest/petstore-awsv4signature/src/models/enum_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/enum_array_testing.rs new file mode 100644 index 000000000000..815ebbac72f5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/enum_array_testing.rs @@ -0,0 +1,46 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// EnumArrayTesting : Test of enum array + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct EnumArrayTesting { + #[serde(rename = "required_enums")] + pub required_enums: Vec, +} + +impl EnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> EnumArrayTesting { + EnumArrayTesting { + required_enums, + } + } +} + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RequiredEnums { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "C")] + C, +} + +impl Default for RequiredEnums { + fn default() -> RequiredEnums { + Self::A + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs index c528fd499bd6..b92cce18b275 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs @@ -6,6 +6,8 @@ pub mod baz; pub use self::baz::Baz; pub mod category; pub use self::category::Category; +pub mod enum_array_testing; +pub use self::enum_array_testing::EnumArrayTesting; pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES index 4b2347f5e64c..3a11dc47e550 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES @@ -6,6 +6,7 @@ docs/ActionContainer.md docs/ApiResponse.md docs/Baz.md docs/Category.md +docs/EnumArrayTesting.md docs/FakeApi.md docs/OptionalTesting.md docs/Order.md @@ -32,6 +33,7 @@ src/models/action_container.rs src/models/api_response.rs src/models/baz.rs src/models/category.rs +src/models/enum_array_testing.rs src/models/mod.rs src/models/model_return.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore/README.md b/samples/client/petstore/rust/reqwest/petstore/README.md index 8f11cb347dcf..939d946cc1bd 100644 --- a/samples/client/petstore/rust/reqwest/petstore/README.md +++ b/samples/client/petstore/rust/reqwest/petstore/README.md @@ -56,6 +56,7 @@ Class | Method | HTTP request | Description - [ApiResponse](docs/ApiResponse.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) + - [EnumArrayTesting](docs/EnumArrayTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md new file mode 100644 index 000000000000..fb4c54df47d5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md @@ -0,0 +1,11 @@ +# EnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | | + +[[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/reqwest/petstore/src/models/enum_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/enum_array_testing.rs new file mode 100644 index 000000000000..815ebbac72f5 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/enum_array_testing.rs @@ -0,0 +1,46 @@ +/* + * 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. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +/// EnumArrayTesting : Test of enum array + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct EnumArrayTesting { + #[serde(rename = "required_enums")] + pub required_enums: Vec, +} + +impl EnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> EnumArrayTesting { + EnumArrayTesting { + required_enums, + } + } +} + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RequiredEnums { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "C")] + C, +} + +impl Default for RequiredEnums { + fn default() -> RequiredEnums { + Self::A + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs index c528fd499bd6..b92cce18b275 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs @@ -6,6 +6,8 @@ pub mod baz; pub use self::baz::Baz; pub mod category; pub use self::category::Category; +pub mod enum_array_testing; +pub use self::enum_array_testing::EnumArrayTesting; pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order;