forked from loafle/openapi-generator-original
[rust] fix nullable array (#16473)
* add tests for nullable array in rust * fix nullable array in rust * minor fix
This commit is contained in:
@@ -82,7 +82,7 @@ impl {{{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}}{{#isNullable}}: None{{/isNullable}}{{/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}},
|
||||
{{{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}},
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -922,3 +922,20 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/ObjectRefItem'
|
||||
NullableArray:
|
||||
type: object
|
||||
properties:
|
||||
array_nullable:
|
||||
type: array
|
||||
nullable: true
|
||||
items:
|
||||
type: string
|
||||
just_array:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable_string:
|
||||
type: string
|
||||
nullable: true
|
||||
just_string:
|
||||
type: string
|
||||
|
||||
@@ -9,6 +9,7 @@ docs/Baz.md
|
||||
docs/Category.md
|
||||
docs/EnumArrayTesting.md
|
||||
docs/FakeApi.md
|
||||
docs/NullableArray.md
|
||||
docs/OptionalTesting.md
|
||||
docs/Order.md
|
||||
docs/Pet.md
|
||||
@@ -40,6 +41,7 @@ src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
src/models/order.rs
|
||||
src/models/pet.rs
|
||||
|
||||
@@ -58,6 +58,7 @@ Class | Method | HTTP request | Description
|
||||
- [Baz](docs/Baz.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [EnumArrayTesting](docs/EnumArrayTesting.md)
|
||||
- [NullableArray](docs/NullableArray.md)
|
||||
- [OptionalTesting](docs/OptionalTesting.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# NullableArray
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_nullable** | Option<**Vec<String>**> | | [optional]
|
||||
**just_array** | Option<**Vec<String>**> | | [optional]
|
||||
**nullable_string** | Option<**String**> | | [optional]
|
||||
**just_string** | Option<**String**> | | [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)
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ pub mod category;
|
||||
pub use self::category::Category;
|
||||
pub mod enum_array_testing;
|
||||
pub use self::enum_array_testing::EnumArrayTesting;
|
||||
pub mod nullable_array;
|
||||
pub use self::nullable_array::NullableArray;
|
||||
pub mod optional_testing;
|
||||
pub use self::optional_testing::OptionalTesting;
|
||||
pub mod order;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct NullableArray {
|
||||
#[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub array_nullable: Option<Option<Vec<String>>>,
|
||||
#[serde(rename = "just_array", skip_serializing_if = "Option::is_none")]
|
||||
pub just_array: Option<Vec<String>>,
|
||||
#[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub nullable_string: Option<Option<String>>,
|
||||
#[serde(rename = "just_string", skip_serializing_if = "Option::is_none")]
|
||||
pub just_string: Option<String>,
|
||||
}
|
||||
|
||||
impl NullableArray {
|
||||
pub fn new() -> NullableArray {
|
||||
NullableArray {
|
||||
array_nullable: None,
|
||||
just_array: None,
|
||||
nullable_string: None,
|
||||
just_string: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ docs/Baz.md
|
||||
docs/Category.md
|
||||
docs/EnumArrayTesting.md
|
||||
docs/FakeApi.md
|
||||
docs/NullableArray.md
|
||||
docs/OptionalTesting.md
|
||||
docs/Order.md
|
||||
docs/Pet.md
|
||||
@@ -38,6 +39,7 @@ src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
src/models/order.rs
|
||||
src/models/pet.rs
|
||||
|
||||
@@ -58,6 +58,7 @@ Class | Method | HTTP request | Description
|
||||
- [Baz](docs/Baz.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [EnumArrayTesting](docs/EnumArrayTesting.md)
|
||||
- [NullableArray](docs/NullableArray.md)
|
||||
- [OptionalTesting](docs/OptionalTesting.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# NullableArray
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_nullable** | Option<**Vec<String>**> | | [optional]
|
||||
**just_array** | Option<**Vec<String>**> | | [optional]
|
||||
**nullable_string** | Option<**String**> | | [optional]
|
||||
**just_string** | Option<**String**> | | [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)
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ pub mod category;
|
||||
pub use self::category::Category;
|
||||
pub mod enum_array_testing;
|
||||
pub use self::enum_array_testing::EnumArrayTesting;
|
||||
pub mod nullable_array;
|
||||
pub use self::nullable_array::NullableArray;
|
||||
pub mod optional_testing;
|
||||
pub use self::optional_testing::OptionalTesting;
|
||||
pub mod order;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct NullableArray {
|
||||
#[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub array_nullable: Option<Option<Vec<String>>>,
|
||||
#[serde(rename = "just_array", skip_serializing_if = "Option::is_none")]
|
||||
pub just_array: Option<Vec<String>>,
|
||||
#[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub nullable_string: Option<Option<String>>,
|
||||
#[serde(rename = "just_string", skip_serializing_if = "Option::is_none")]
|
||||
pub just_string: Option<String>,
|
||||
}
|
||||
|
||||
impl NullableArray {
|
||||
pub fn new() -> NullableArray {
|
||||
NullableArray {
|
||||
array_nullable: None,
|
||||
just_array: None,
|
||||
nullable_string: None,
|
||||
just_string: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ docs/Baz.md
|
||||
docs/Category.md
|
||||
docs/EnumArrayTesting.md
|
||||
docs/FakeApi.md
|
||||
docs/NullableArray.md
|
||||
docs/OptionalTesting.md
|
||||
docs/Order.md
|
||||
docs/Pet.md
|
||||
@@ -38,6 +39,7 @@ src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
src/models/order.rs
|
||||
src/models/pet.rs
|
||||
|
||||
@@ -58,6 +58,7 @@ Class | Method | HTTP request | Description
|
||||
- [Baz](docs/Baz.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [EnumArrayTesting](docs/EnumArrayTesting.md)
|
||||
- [NullableArray](docs/NullableArray.md)
|
||||
- [OptionalTesting](docs/OptionalTesting.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# NullableArray
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_nullable** | Option<**Vec<String>**> | | [optional]
|
||||
**just_array** | Option<**Vec<String>**> | | [optional]
|
||||
**nullable_string** | Option<**String**> | | [optional]
|
||||
**just_string** | Option<**String**> | | [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)
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ pub mod category;
|
||||
pub use self::category::Category;
|
||||
pub mod enum_array_testing;
|
||||
pub use self::enum_array_testing::EnumArrayTesting;
|
||||
pub mod nullable_array;
|
||||
pub use self::nullable_array::NullableArray;
|
||||
pub mod optional_testing;
|
||||
pub use self::optional_testing::OptionalTesting;
|
||||
pub mod order;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct NullableArray {
|
||||
#[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub array_nullable: Option<Option<Vec<String>>>,
|
||||
#[serde(rename = "just_array", skip_serializing_if = "Option::is_none")]
|
||||
pub just_array: Option<Vec<String>>,
|
||||
#[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub nullable_string: Option<Option<String>>,
|
||||
#[serde(rename = "just_string", skip_serializing_if = "Option::is_none")]
|
||||
pub just_string: Option<String>,
|
||||
}
|
||||
|
||||
impl NullableArray {
|
||||
pub fn new() -> NullableArray {
|
||||
NullableArray {
|
||||
array_nullable: None,
|
||||
just_array: None,
|
||||
nullable_string: None,
|
||||
just_string: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ docs/Baz.md
|
||||
docs/Category.md
|
||||
docs/EnumArrayTesting.md
|
||||
docs/FakeApi.md
|
||||
docs/NullableArray.md
|
||||
docs/OptionalTesting.md
|
||||
docs/Order.md
|
||||
docs/Pet.md
|
||||
@@ -38,6 +39,7 @@ src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
src/models/order.rs
|
||||
src/models/pet.rs
|
||||
|
||||
@@ -58,6 +58,7 @@ Class | Method | HTTP request | Description
|
||||
- [Baz](docs/Baz.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [EnumArrayTesting](docs/EnumArrayTesting.md)
|
||||
- [NullableArray](docs/NullableArray.md)
|
||||
- [OptionalTesting](docs/OptionalTesting.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# NullableArray
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_nullable** | Option<**Vec<String>**> | | [optional]
|
||||
**just_array** | Option<**Vec<String>**> | | [optional]
|
||||
**nullable_string** | Option<**String**> | | [optional]
|
||||
**just_string** | Option<**String**> | | [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)
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ pub mod category;
|
||||
pub use self::category::Category;
|
||||
pub mod enum_array_testing;
|
||||
pub use self::enum_array_testing::EnumArrayTesting;
|
||||
pub mod nullable_array;
|
||||
pub use self::nullable_array::NullableArray;
|
||||
pub mod optional_testing;
|
||||
pub use self::optional_testing::OptionalTesting;
|
||||
pub mod order;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct NullableArray {
|
||||
#[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub array_nullable: Option<Option<Vec<String>>>,
|
||||
#[serde(rename = "just_array", skip_serializing_if = "Option::is_none")]
|
||||
pub just_array: Option<Vec<String>>,
|
||||
#[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub nullable_string: Option<Option<String>>,
|
||||
#[serde(rename = "just_string", skip_serializing_if = "Option::is_none")]
|
||||
pub just_string: Option<String>,
|
||||
}
|
||||
|
||||
impl NullableArray {
|
||||
pub fn new() -> NullableArray {
|
||||
NullableArray {
|
||||
array_nullable: None,
|
||||
just_array: None,
|
||||
nullable_string: None,
|
||||
just_string: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ docs/Baz.md
|
||||
docs/Category.md
|
||||
docs/EnumArrayTesting.md
|
||||
docs/FakeApi.md
|
||||
docs/NullableArray.md
|
||||
docs/OptionalTesting.md
|
||||
docs/Order.md
|
||||
docs/Pet.md
|
||||
@@ -38,6 +39,7 @@ src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
src/models/order.rs
|
||||
src/models/pet.rs
|
||||
|
||||
@@ -58,6 +58,7 @@ Class | Method | HTTP request | Description
|
||||
- [Baz](docs/Baz.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [EnumArrayTesting](docs/EnumArrayTesting.md)
|
||||
- [NullableArray](docs/NullableArray.md)
|
||||
- [OptionalTesting](docs/OptionalTesting.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# NullableArray
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_nullable** | Option<**Vec<String>**> | | [optional]
|
||||
**just_array** | Option<**Vec<String>**> | | [optional]
|
||||
**nullable_string** | Option<**String**> | | [optional]
|
||||
**just_string** | Option<**String**> | | [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)
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ pub mod category;
|
||||
pub use self::category::Category;
|
||||
pub mod enum_array_testing;
|
||||
pub use self::enum_array_testing::EnumArrayTesting;
|
||||
pub mod nullable_array;
|
||||
pub use self::nullable_array::NullableArray;
|
||||
pub mod optional_testing;
|
||||
pub use self::optional_testing::OptionalTesting;
|
||||
pub mod order;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct NullableArray {
|
||||
#[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub array_nullable: Option<Option<Vec<String>>>,
|
||||
#[serde(rename = "just_array", skip_serializing_if = "Option::is_none")]
|
||||
pub just_array: Option<Vec<String>>,
|
||||
#[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
|
||||
pub nullable_string: Option<Option<String>>,
|
||||
#[serde(rename = "just_string", skip_serializing_if = "Option::is_none")]
|
||||
pub just_string: Option<String>,
|
||||
}
|
||||
|
||||
impl NullableArray {
|
||||
pub fn new() -> NullableArray {
|
||||
NullableArray {
|
||||
array_nullable: None,
|
||||
just_array: None,
|
||||
nullable_string: None,
|
||||
just_string: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user