forked from loafle/openapi-generator-original
[BUGFIX][Rust] Array with unique enum items no longer causes mismatched types error (#17197)
* check args to fn new for uniqueItems * Added model with unique items for template testing * build the project and update samples * Removed testcase from fake petstore spec
This commit is contained in:
@@ -79,7 +79,7 @@ impl {{{classname}}} {
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
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}}} {
|
||||
pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||
{{{classname}}} {
|
||||
{{#vars}}
|
||||
{{{name}}}{{^required}}{{#isContainer}}{{#isArray}}: None{{/isArray}}{{#isMap}}: None{{/isMap}}{{^isArray}}{{^isMap}}{{#isNullable}}: None{{/isNullable}}{{/isMap}}{{/isArray}}{{/isContainer}}{{^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}},
|
||||
|
||||
@@ -898,6 +898,22 @@ components:
|
||||
items:
|
||||
type: string
|
||||
enum: ["A", "B", "C"]
|
||||
UniqueItemArrayTesting:
|
||||
description: Test handling of enum array with unique items
|
||||
type: object
|
||||
required:
|
||||
- unique_item_array
|
||||
properties:
|
||||
unique_item_array:
|
||||
type: array
|
||||
description: Helper object for the unique item array test
|
||||
uniqueItems: true
|
||||
items:
|
||||
type: string
|
||||
enum:
|
||||
- unique_item_1
|
||||
- unique_item_2
|
||||
- unique_item_3
|
||||
ArrayRefItem:
|
||||
description: Helper object for the array item ref test
|
||||
type: array
|
||||
|
||||
@@ -20,6 +20,7 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/TestingApi.md
|
||||
docs/TypeTesting.md
|
||||
docs/UniqueItemArrayTesting.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
git_push.sh
|
||||
@@ -48,4 +49,5 @@ src/models/pet.rs
|
||||
src/models/property_test.rs
|
||||
src/models/tag.rs
|
||||
src/models/type_testing.rs
|
||||
src/models/unique_item_array_testing.rs
|
||||
src/models/user.rs
|
||||
|
||||
@@ -66,6 +66,7 @@ Class | Method | HTTP request | Description
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
- [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# UniqueItemArrayTesting
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**unique_item_array** | **Vec<String>** | Helper object for the unique item array test |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -26,5 +26,7 @@ pub mod tag;
|
||||
pub use self::tag::Tag;
|
||||
pub mod type_testing;
|
||||
pub use self::type_testing::TypeTesting;
|
||||
pub mod unique_item_array_testing;
|
||||
pub use self::unique_item_array_testing::UniqueItemArrayTesting;
|
||||
pub mod user;
|
||||
pub use self::user::User;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// UniqueItemArrayTesting : Test handling of enum array with unique items
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UniqueItemArrayTesting {
|
||||
/// Helper object for the unique item array test
|
||||
#[serde(rename = "unique_item_array")]
|
||||
pub unique_item_array: std::collections::HashSet<UniqueItemArray>,
|
||||
}
|
||||
|
||||
impl UniqueItemArrayTesting {
|
||||
/// Test handling of enum array with unique items
|
||||
pub fn new(unique_item_array: std::collections::HashSet<UniqueItemArray>) -> UniqueItemArrayTesting {
|
||||
UniqueItemArrayTesting {
|
||||
unique_item_array,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper object for the unique item array test
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum UniqueItemArray {
|
||||
#[serde(rename = "unique_item_1")]
|
||||
Variant1,
|
||||
#[serde(rename = "unique_item_2")]
|
||||
Variant2,
|
||||
#[serde(rename = "unique_item_3")]
|
||||
Variant3,
|
||||
}
|
||||
|
||||
impl Default for UniqueItemArray {
|
||||
fn default() -> UniqueItemArray {
|
||||
Self::Variant1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/TestingApi.md
|
||||
docs/TypeTesting.md
|
||||
docs/UniqueItemArrayTesting.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
git_push.sh
|
||||
@@ -46,4 +47,5 @@ src/models/pet.rs
|
||||
src/models/property_test.rs
|
||||
src/models/tag.rs
|
||||
src/models/type_testing.rs
|
||||
src/models/unique_item_array_testing.rs
|
||||
src/models/user.rs
|
||||
|
||||
@@ -66,6 +66,7 @@ Class | Method | HTTP request | Description
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
- [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# UniqueItemArrayTesting
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**unique_item_array** | **Vec<String>** | Helper object for the unique item array test |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -26,5 +26,7 @@ pub mod tag;
|
||||
pub use self::tag::Tag;
|
||||
pub mod type_testing;
|
||||
pub use self::type_testing::TypeTesting;
|
||||
pub mod unique_item_array_testing;
|
||||
pub use self::unique_item_array_testing::UniqueItemArrayTesting;
|
||||
pub mod user;
|
||||
pub use self::user::User;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// UniqueItemArrayTesting : Test handling of enum array with unique items
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UniqueItemArrayTesting {
|
||||
/// Helper object for the unique item array test
|
||||
#[serde(rename = "unique_item_array")]
|
||||
pub unique_item_array: std::collections::HashSet<UniqueItemArray>,
|
||||
}
|
||||
|
||||
impl UniqueItemArrayTesting {
|
||||
/// Test handling of enum array with unique items
|
||||
pub fn new(unique_item_array: std::collections::HashSet<UniqueItemArray>) -> UniqueItemArrayTesting {
|
||||
UniqueItemArrayTesting {
|
||||
unique_item_array,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper object for the unique item array test
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum UniqueItemArray {
|
||||
#[serde(rename = "unique_item_1")]
|
||||
Variant1,
|
||||
#[serde(rename = "unique_item_2")]
|
||||
Variant2,
|
||||
#[serde(rename = "unique_item_3")]
|
||||
Variant3,
|
||||
}
|
||||
|
||||
impl Default for UniqueItemArray {
|
||||
fn default() -> UniqueItemArray {
|
||||
Self::Variant1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/TestingApi.md
|
||||
docs/TypeTesting.md
|
||||
docs/UniqueItemArrayTesting.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
git_push.sh
|
||||
@@ -46,4 +47,5 @@ src/models/pet.rs
|
||||
src/models/property_test.rs
|
||||
src/models/tag.rs
|
||||
src/models/type_testing.rs
|
||||
src/models/unique_item_array_testing.rs
|
||||
src/models/user.rs
|
||||
|
||||
@@ -66,6 +66,7 @@ Class | Method | HTTP request | Description
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
- [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# UniqueItemArrayTesting
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**unique_item_array** | **Vec<String>** | Helper object for the unique item array test |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -26,5 +26,7 @@ pub mod tag;
|
||||
pub use self::tag::Tag;
|
||||
pub mod type_testing;
|
||||
pub use self::type_testing::TypeTesting;
|
||||
pub mod unique_item_array_testing;
|
||||
pub use self::unique_item_array_testing::UniqueItemArrayTesting;
|
||||
pub mod user;
|
||||
pub use self::user::User;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// UniqueItemArrayTesting : Test handling of enum array with unique items
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UniqueItemArrayTesting {
|
||||
/// Helper object for the unique item array test
|
||||
#[serde(rename = "unique_item_array")]
|
||||
pub unique_item_array: std::collections::HashSet<UniqueItemArray>,
|
||||
}
|
||||
|
||||
impl UniqueItemArrayTesting {
|
||||
/// Test handling of enum array with unique items
|
||||
pub fn new(unique_item_array: std::collections::HashSet<UniqueItemArray>) -> UniqueItemArrayTesting {
|
||||
UniqueItemArrayTesting {
|
||||
unique_item_array,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper object for the unique item array test
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum UniqueItemArray {
|
||||
#[serde(rename = "unique_item_1")]
|
||||
Variant1,
|
||||
#[serde(rename = "unique_item_2")]
|
||||
Variant2,
|
||||
#[serde(rename = "unique_item_3")]
|
||||
Variant3,
|
||||
}
|
||||
|
||||
impl Default for UniqueItemArray {
|
||||
fn default() -> UniqueItemArray {
|
||||
Self::Variant1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/TestingApi.md
|
||||
docs/TypeTesting.md
|
||||
docs/UniqueItemArrayTesting.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
git_push.sh
|
||||
@@ -46,4 +47,5 @@ src/models/pet.rs
|
||||
src/models/property_test.rs
|
||||
src/models/tag.rs
|
||||
src/models/type_testing.rs
|
||||
src/models/unique_item_array_testing.rs
|
||||
src/models/user.rs
|
||||
|
||||
@@ -66,6 +66,7 @@ Class | Method | HTTP request | Description
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
- [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# UniqueItemArrayTesting
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**unique_item_array** | **Vec<String>** | Helper object for the unique item array test |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -26,5 +26,7 @@ pub mod tag;
|
||||
pub use self::tag::Tag;
|
||||
pub mod type_testing;
|
||||
pub use self::type_testing::TypeTesting;
|
||||
pub mod unique_item_array_testing;
|
||||
pub use self::unique_item_array_testing::UniqueItemArrayTesting;
|
||||
pub mod user;
|
||||
pub use self::user::User;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// UniqueItemArrayTesting : Test handling of enum array with unique items
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UniqueItemArrayTesting {
|
||||
/// Helper object for the unique item array test
|
||||
#[serde(rename = "unique_item_array")]
|
||||
pub unique_item_array: std::collections::HashSet<UniqueItemArray>,
|
||||
}
|
||||
|
||||
impl UniqueItemArrayTesting {
|
||||
/// Test handling of enum array with unique items
|
||||
pub fn new(unique_item_array: std::collections::HashSet<UniqueItemArray>) -> UniqueItemArrayTesting {
|
||||
UniqueItemArrayTesting {
|
||||
unique_item_array,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper object for the unique item array test
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum UniqueItemArray {
|
||||
#[serde(rename = "unique_item_1")]
|
||||
Variant1,
|
||||
#[serde(rename = "unique_item_2")]
|
||||
Variant2,
|
||||
#[serde(rename = "unique_item_3")]
|
||||
Variant3,
|
||||
}
|
||||
|
||||
impl Default for UniqueItemArray {
|
||||
fn default() -> UniqueItemArray {
|
||||
Self::Variant1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/TestingApi.md
|
||||
docs/TypeTesting.md
|
||||
docs/UniqueItemArrayTesting.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
git_push.sh
|
||||
@@ -46,4 +47,5 @@ src/models/pet.rs
|
||||
src/models/property_test.rs
|
||||
src/models/tag.rs
|
||||
src/models/type_testing.rs
|
||||
src/models/unique_item_array_testing.rs
|
||||
src/models/user.rs
|
||||
|
||||
@@ -66,6 +66,7 @@ Class | Method | HTTP request | Description
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
- [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# UniqueItemArrayTesting
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**unique_item_array** | **Vec<String>** | Helper object for the unique item array test |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -26,5 +26,7 @@ pub mod tag;
|
||||
pub use self::tag::Tag;
|
||||
pub mod type_testing;
|
||||
pub use self::type_testing::TypeTesting;
|
||||
pub mod unique_item_array_testing;
|
||||
pub use self::unique_item_array_testing::UniqueItemArrayTesting;
|
||||
pub mod user;
|
||||
pub use self::user::User;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/// UniqueItemArrayTesting : Test handling of enum array with unique items
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UniqueItemArrayTesting {
|
||||
/// Helper object for the unique item array test
|
||||
#[serde(rename = "unique_item_array")]
|
||||
pub unique_item_array: std::collections::HashSet<UniqueItemArray>,
|
||||
}
|
||||
|
||||
impl UniqueItemArrayTesting {
|
||||
/// Test handling of enum array with unique items
|
||||
pub fn new(unique_item_array: std::collections::HashSet<UniqueItemArray>) -> UniqueItemArrayTesting {
|
||||
UniqueItemArrayTesting {
|
||||
unique_item_array,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper object for the unique item array test
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum UniqueItemArray {
|
||||
#[serde(rename = "unique_item_1")]
|
||||
Variant1,
|
||||
#[serde(rename = "unique_item_2")]
|
||||
Variant2,
|
||||
#[serde(rename = "unique_item_3")]
|
||||
Variant3,
|
||||
}
|
||||
|
||||
impl Default for UniqueItemArray {
|
||||
fn default() -> UniqueItemArray {
|
||||
Self::Variant1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user