[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<RequiredEnums>`.
This commit is contained in:
Thomas von Rosenberg
2022-12-27 16:25:01 +01:00
committed by GitHub
parent 444d411b5e
commit 63f6569e6f
27 changed files with 323 additions and 2 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -0,0 +1,11 @@
# EnumArrayTesting
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**required_enums** | **Vec<String>** | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -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<RequiredEnums>,
}
impl EnumArrayTesting {
/// Test of enum array
pub fn new(required_enums: Vec<RequiredEnums>) -> 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
}
}

View File

@@ -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;