forked from loafle/openapi-generator-original
[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:
parent
444d411b5e
commit
63f6569e6f
@ -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}},
|
||||
|
@ -877,4 +877,15 @@ components:
|
||||
nullable: true
|
||||
required_nullable:
|
||||
type: string
|
||||
nullable: true
|
||||
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"]
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user