From 36bd8e7e15e094d5408a44021896ce0d1b2c4957 Mon Sep 17 00:00:00 2001 From: Thomas von Rosenberg Date: Wed, 7 Dec 2022 10:53:54 +0100 Subject: [PATCH 1/2] [rust] Fix declaration for arrays with object and array references For arrays with an item defined by reference to an array or an object, the generated type declaration was `Vec` or `Vec` without defining a `Array` or `Map` so that the code didn't compile. --- .../codegen/languages/RustClientCodegen.java | 13 ++++---- .../src/test/resources/3_0/rust/petstore.yaml | 24 ++++++++++++++ .../hyper/petstore/.openapi-generator/FILES | 2 ++ .../petstore/rust/hyper/petstore/README.md | 1 + .../hyper/petstore/docs/ArrayItemRefTest.md | 12 +++++++ .../src/models/array_item_ref_test.rs | 33 +++++++++++++++++++ .../rust/hyper/petstore/src/models/mod.rs | 2 ++ .../.openapi-generator/FILES | 2 ++ .../petstore-async-middleware/README.md | 1 + .../docs/ArrayItemRefTest.md | 12 +++++++ .../src/models/array_item_ref_test.rs | 33 +++++++++++++++++++ .../src/models/mod.rs | 2 ++ .../petstore-async/.openapi-generator/FILES | 2 ++ .../rust/reqwest/petstore-async/README.md | 1 + .../petstore-async/docs/ArrayItemRefTest.md | 12 +++++++ .../src/models/array_item_ref_test.rs | 33 +++++++++++++++++++ .../reqwest/petstore-async/src/models/mod.rs | 2 ++ .../.openapi-generator/FILES | 2 ++ .../reqwest/petstore-awsv4signature/README.md | 1 + .../docs/ArrayItemRefTest.md | 12 +++++++ .../src/models/array_item_ref_test.rs | 33 +++++++++++++++++++ .../petstore-awsv4signature/src/models/mod.rs | 2 ++ .../reqwest/petstore/.openapi-generator/FILES | 2 ++ .../petstore/rust/reqwest/petstore/README.md | 1 + .../reqwest/petstore/docs/ArrayItemRefTest.md | 12 +++++++ .../src/models/array_item_ref_test.rs | 33 +++++++++++++++++++ .../rust/reqwest/petstore/src/models/mod.rs | 2 ++ 27 files changed, 281 insertions(+), 6 deletions(-) create mode 100644 samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md create mode 100644 samples/client/petstore/rust/hyper/petstore/src/models/array_item_ref_test.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/array_item_ref_test.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-async/src/models/array_item_ref_test.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/array_item_ref_test.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md create mode 100644 samples/client/petstore/rust/reqwest/petstore/src/models/array_item_ref_test.rs diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index cac8dc933ee2..2aeefdbac00c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -424,8 +424,9 @@ public String modelDocFileFolder() { @Override public String getTypeDeclaration(Schema p) { - if (ModelUtils.isArraySchema(p)) { - ArraySchema ap = (ArraySchema) p; + Schema unaliasSchema = unaliasSchema(p); + if (ModelUtils.isArraySchema(unaliasSchema)) { + ArraySchema ap = (ArraySchema) unaliasSchema; Schema inner = ap.getItems(); if (inner == null) { LOGGER.warn("{}(array property) does not have a proper inner type defined.Default to string", @@ -433,10 +434,10 @@ public String getTypeDeclaration(Schema p) { inner = new StringSchema().description("TODO default missing array inner type to string"); } return "Vec<" + getTypeDeclaration(inner) + ">"; - } else if (ModelUtils.isMapSchema(p)) { - Schema inner = getAdditionalProperties(p); + } else if (ModelUtils.isMapSchema(unaliasSchema)) { + Schema inner = getAdditionalProperties(unaliasSchema); if (inner == null) { - LOGGER.warn("{}(map property) does not have a proper inner type defined. Default to string", p.getName()); + LOGGER.warn("{}(map property) does not have a proper inner type defined. Default to string", unaliasSchema.getName()); inner = new StringSchema().description("TODO default missing map inner type to string"); } return "::std::collections::HashMap"; @@ -444,7 +445,7 @@ public String getTypeDeclaration(Schema p) { // Not using the supertype invocation, because we want to UpperCamelize // the type. - String schemaType = getSchemaType(p); + String schemaType = getSchemaType(unaliasSchema); if (typeMapping.containsKey(schemaType)) { return typeMapping.get(schemaType); } 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 8d1679467c7b..1e77adf0be40 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 @@ -889,3 +889,27 @@ components: items: type: string enum: ["A", "B", "C"] + ArrayRefItem: + description: Helper object for the array item ref test + type: array + items: + type: string + ObjectRefItem: + description: Helper object for the array item ref test + type: object + additionalProperties: true + ArrayItemRefTest: + description: Test handling of object reference in arrays + type: object + required: + - list_with_array_ref + - list_with_object_ref + properties: + list_with_array_ref: + type: array + items: + $ref: '#/components/schemas/ArrayRefItem' + list_with_object_ref: + type: array + items: + $ref: '#/components/schemas/ObjectRefItem' diff --git a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES index 867a49a5fc29..f711f2d952ff 100644 --- a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES @@ -4,6 +4,7 @@ Cargo.toml README.md docs/ActionContainer.md docs/ApiResponse.md +docs/ArrayItemRefTest.md docs/Baz.md docs/Category.md docs/EnumArrayTesting.md @@ -33,6 +34,7 @@ src/apis/user_api.rs src/lib.rs src/models/action_container.rs src/models/api_response.rs +src/models/array_item_ref_test.rs src/models/baz.rs src/models/category.rs src/models/enum_array_testing.rs diff --git a/samples/client/petstore/rust/hyper/petstore/README.md b/samples/client/petstore/rust/hyper/petstore/README.md index e8fdb7278e1c..62eb7dd27d10 100644 --- a/samples/client/petstore/rust/hyper/petstore/README.md +++ b/samples/client/petstore/rust/hyper/petstore/README.md @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description - [ActionContainer](docs/ActionContainer.md) - [ApiResponse](docs/ApiResponse.md) + - [ArrayItemRefTest](docs/ArrayItemRefTest.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md new file mode 100644 index 000000000000..57e521d9ce6a --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md @@ -0,0 +1,12 @@ +# ArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](array.md) | | +**list_with_object_ref** | [**Vec<::std::collections::HashMap>**](map.md) | | + +[[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/array_item_ref_test.rs b/samples/client/petstore/rust/hyper/petstore/src/models/array_item_ref_test.rs new file mode 100644 index 000000000000..95671e629b39 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/array_item_ref_test.rs @@ -0,0 +1,33 @@ +/* + * 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 + */ + +/// ArrayItemRefTest : Test handling of object reference in arrays + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ArrayItemRefTest { + #[serde(rename = "list_with_array_ref")] + pub list_with_array_ref: Vec>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec<::std::collections::HashMap>, +} + +impl ArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec<::std::collections::HashMap>) -> ArrayItemRefTest { + ArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + + 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 b92cce18b275..d9e709091bdb 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs @@ -2,6 +2,8 @@ pub mod action_container; pub use self::action_container::ActionContainer; pub mod api_response; pub use self::api_response::ApiResponse; +pub mod array_item_ref_test; +pub use self::array_item_ref_test::ArrayItemRefTest; pub mod baz; pub use self::baz::Baz; pub mod category; 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 3a11dc47e550..b253ebe526e5 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 @@ -4,6 +4,7 @@ Cargo.toml README.md docs/ActionContainer.md docs/ApiResponse.md +docs/ArrayItemRefTest.md docs/Baz.md docs/Category.md docs/EnumArrayTesting.md @@ -31,6 +32,7 @@ src/apis/user_api.rs src/lib.rs src/models/action_container.rs src/models/api_response.rs +src/models/array_item_ref_test.rs src/models/baz.rs src/models/category.rs src/models/enum_array_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 6b569b157784..ac0244b8a7ae 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description - [ActionContainer](docs/ActionContainer.md) - [ApiResponse](docs/ApiResponse.md) + - [ArrayItemRefTest](docs/ArrayItemRefTest.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md new file mode 100644 index 000000000000..57e521d9ce6a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md @@ -0,0 +1,12 @@ +# ArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](array.md) | | +**list_with_object_ref** | [**Vec<::std::collections::HashMap>**](map.md) | | + +[[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/array_item_ref_test.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/array_item_ref_test.rs new file mode 100644 index 000000000000..95671e629b39 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/array_item_ref_test.rs @@ -0,0 +1,33 @@ +/* + * 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 + */ + +/// ArrayItemRefTest : Test handling of object reference in arrays + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ArrayItemRefTest { + #[serde(rename = "list_with_array_ref")] + pub list_with_array_ref: Vec>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec<::std::collections::HashMap>, +} + +impl ArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec<::std::collections::HashMap>) -> ArrayItemRefTest { + ArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + + 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 b92cce18b275..d9e709091bdb 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 @@ -2,6 +2,8 @@ pub mod action_container; pub use self::action_container::ActionContainer; pub mod api_response; pub use self::api_response::ApiResponse; +pub mod array_item_ref_test; +pub use self::array_item_ref_test::ArrayItemRefTest; pub mod baz; pub use self::baz::Baz; pub mod category; 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 3a11dc47e550..b253ebe526e5 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES @@ -4,6 +4,7 @@ Cargo.toml README.md docs/ActionContainer.md docs/ApiResponse.md +docs/ArrayItemRefTest.md docs/Baz.md docs/Category.md docs/EnumArrayTesting.md @@ -31,6 +32,7 @@ src/apis/user_api.rs src/lib.rs src/models/action_container.rs src/models/api_response.rs +src/models/array_item_ref_test.rs src/models/baz.rs src/models/category.rs src/models/enum_array_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 0de8d36614af..689113a62abe 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/README.md @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description - [ActionContainer](docs/ActionContainer.md) - [ApiResponse](docs/ApiResponse.md) + - [ArrayItemRefTest](docs/ArrayItemRefTest.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md new file mode 100644 index 000000000000..57e521d9ce6a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md @@ -0,0 +1,12 @@ +# ArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](array.md) | | +**list_with_object_ref** | [**Vec<::std::collections::HashMap>**](map.md) | | + +[[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/array_item_ref_test.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/array_item_ref_test.rs new file mode 100644 index 000000000000..95671e629b39 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/array_item_ref_test.rs @@ -0,0 +1,33 @@ +/* + * 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 + */ + +/// ArrayItemRefTest : Test handling of object reference in arrays + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ArrayItemRefTest { + #[serde(rename = "list_with_array_ref")] + pub list_with_array_ref: Vec>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec<::std::collections::HashMap>, +} + +impl ArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec<::std::collections::HashMap>) -> ArrayItemRefTest { + ArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + + 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 b92cce18b275..d9e709091bdb 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 @@ -2,6 +2,8 @@ pub mod action_container; pub use self::action_container::ActionContainer; pub mod api_response; pub use self::api_response::ApiResponse; +pub mod array_item_ref_test; +pub use self::array_item_ref_test::ArrayItemRefTest; pub mod baz; pub use self::baz::Baz; pub mod category; 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 3a11dc47e550..b253ebe526e5 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES @@ -4,6 +4,7 @@ Cargo.toml README.md docs/ActionContainer.md docs/ApiResponse.md +docs/ArrayItemRefTest.md docs/Baz.md docs/Category.md docs/EnumArrayTesting.md @@ -31,6 +32,7 @@ src/apis/user_api.rs src/lib.rs src/models/action_container.rs src/models/api_response.rs +src/models/array_item_ref_test.rs src/models/baz.rs src/models/category.rs src/models/enum_array_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 ce9b8c08e276..6b0aa5b9508d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description - [ActionContainer](docs/ActionContainer.md) - [ApiResponse](docs/ApiResponse.md) + - [ArrayItemRefTest](docs/ArrayItemRefTest.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md new file mode 100644 index 000000000000..57e521d9ce6a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md @@ -0,0 +1,12 @@ +# ArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](array.md) | | +**list_with_object_ref** | [**Vec<::std::collections::HashMap>**](map.md) | | + +[[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/array_item_ref_test.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/array_item_ref_test.rs new file mode 100644 index 000000000000..95671e629b39 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/array_item_ref_test.rs @@ -0,0 +1,33 @@ +/* + * 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 + */ + +/// ArrayItemRefTest : Test handling of object reference in arrays + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ArrayItemRefTest { + #[serde(rename = "list_with_array_ref")] + pub list_with_array_ref: Vec>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec<::std::collections::HashMap>, +} + +impl ArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec<::std::collections::HashMap>) -> ArrayItemRefTest { + ArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + + 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 b92cce18b275..d9e709091bdb 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 @@ -2,6 +2,8 @@ pub mod action_container; pub use self::action_container::ActionContainer; pub mod api_response; pub use self::api_response::ApiResponse; +pub mod array_item_ref_test; +pub use self::array_item_ref_test::ArrayItemRefTest; pub mod baz; pub use self::baz::Baz; pub mod category; diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES index 3a11dc47e550..b253ebe526e5 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES @@ -4,6 +4,7 @@ Cargo.toml README.md docs/ActionContainer.md docs/ApiResponse.md +docs/ArrayItemRefTest.md docs/Baz.md docs/Category.md docs/EnumArrayTesting.md @@ -31,6 +32,7 @@ src/apis/user_api.rs src/lib.rs src/models/action_container.rs src/models/api_response.rs +src/models/array_item_ref_test.rs src/models/baz.rs src/models/category.rs src/models/enum_array_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore/README.md b/samples/client/petstore/rust/reqwest/petstore/README.md index 939d946cc1bd..7e5002ac2abf 100644 --- a/samples/client/petstore/rust/reqwest/petstore/README.md +++ b/samples/client/petstore/rust/reqwest/petstore/README.md @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description - [ActionContainer](docs/ActionContainer.md) - [ApiResponse](docs/ApiResponse.md) + - [ArrayItemRefTest](docs/ArrayItemRefTest.md) - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md new file mode 100644 index 000000000000..57e521d9ce6a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md @@ -0,0 +1,12 @@ +# ArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](array.md) | | +**list_with_object_ref** | [**Vec<::std::collections::HashMap>**](map.md) | | + +[[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/array_item_ref_test.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/array_item_ref_test.rs new file mode 100644 index 000000000000..95671e629b39 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/array_item_ref_test.rs @@ -0,0 +1,33 @@ +/* + * 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 + */ + +/// ArrayItemRefTest : Test handling of object reference in arrays + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ArrayItemRefTest { + #[serde(rename = "list_with_array_ref")] + pub list_with_array_ref: Vec>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec<::std::collections::HashMap>, +} + +impl ArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec<::std::collections::HashMap>) -> ArrayItemRefTest { + ArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + + 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 b92cce18b275..d9e709091bdb 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs @@ -2,6 +2,8 @@ pub mod action_container; pub use self::action_container::ActionContainer; pub mod api_response; pub use self::api_response::ApiResponse; +pub mod array_item_ref_test; +pub use self::array_item_ref_test::ArrayItemRefTest; pub mod baz; pub use self::baz::Baz; pub mod category; From b6fc982b93c137d223a9c2a028184cf83b8295e8 Mon Sep 17 00:00:00 2001 From: Thomas von Rosenberg Date: Wed, 7 Dec 2022 10:41:08 +0100 Subject: [PATCH 2/2] [rust] Fix trailing whitespace in petstore definition --- .../openapi-generator/src/test/resources/3_0/rust/petstore.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1e77adf0be40..41861771aadd 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 @@ -801,7 +801,7 @@ components: properties: uuid: type: string - format: uuid + format: uuid ActionContainer: required: - action