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 6a944b06260..ef438aeb297 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 @@ -22,15 +22,18 @@ import java.io.IOException; import java.io.Writer; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import org.openapitools.codegen.CliOption; @@ -342,6 +345,32 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon break; } } + + // Check if there are duplicate mappings in the discriminator + // ie. + // ``` + // mappings: + // student: '#/components/schemas/Person' + // teacher: '#/components/schemas/Person' + // car: '#/components/schemas/Vehicle' + // ``` + // + // Should be mapped to an enum with `PersonStudent`, `PersonTeacher`, `Vehicle` to 2 `Person` enum variants. (a compiler error) + if (cm.discriminator.getMapping() != null) { + if (hasDuplicateValues(cm.discriminator.getMapping())) { + var inverted = invertMap(cm.discriminator.getMapping()); + for (var s : inverted.entrySet()) { + if (s.getValue().size() > 1) { + LOGGER.debug("Found duplicated enum model (" + s.getKey() + ") in model " + cm.name + ". Adding suffix to model names."); + for (var m : cm.discriminator.getMappedModels()) { + if (s.getValue().contains(m.getMappingName())) { + m.setModelName(m.getModelName() + StringUtils.camelize(m.getMappingName())); + } + } + } + } + } + } } // Flag structs with byteArrays in them so that we can annotate them with the serde_as macro @@ -789,4 +818,18 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon .put("lifetimeName", new ReplaceAllLambda("^r#", "r_")); } + public static Map> invertMap(Map map) { + Map> invertedMap = new HashMap<>(); + + for (Map.Entry entry : map.entrySet()) { + invertedMap.computeIfAbsent(entry.getValue(), k -> new ArrayList<>()).add(entry.getKey()); + } + + return invertedMap; + } + + public static boolean hasDuplicateValues(Map map) { + Set uniqueValues = new HashSet<>(map.values()); + return uniqueValues.size() < map.size(); + } } 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 acad24abb04..f7d7c341029 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 @@ -656,6 +656,26 @@ paths: application/json: schema: $ref: '#/components/schemas/TypeTesting' + '/tests/discriminatorDuplicateEnums': + get: + tags: + - testing + summary: 'Test for duplicate enums when using discriminator. (One of the issues in #20500)' + responses: + '200': + description: test + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/Person' + - $ref: '#/components/schemas/Vehicle' + discriminator: + propertyName: objectType + mapping: + student: '#/components/schemas/Person' + teacher: '#/components/schemas/Person' + car: '#/components/schemas/Vehicle' externalDocs: description: Find out more about Swagger url: 'http://swagger.io' @@ -1014,4 +1034,24 @@ components: properties: foo: {} required: ["foo"] + Person: + type: object + properties: + type: + type: string + name: + type: string + required: + - type + - name + Vehicle: + type: object + properties: + type: + type: string + speed: + type: number + required: + - type + - speed diff --git a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES index 5767a23c8ba..b493e74d9ef 100644 --- a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/client.rs src/apis/configuration.rs @@ -37,6 +40,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -51,9 +55,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/hyper/petstore/README.md b/samples/client/petstore/rust/hyper/petstore/README.md index f6319d46f24..be5ad201001 100644 --- a/samples/client/petstore/rust/hyper/petstore/README.md +++ b/samples/client/petstore/rust/hyper/petstore/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **Get** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **Get** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **Post** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **Get** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **Get** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **Post** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/hyper/petstore/docs/Person.md b/samples/client/petstore/rust/hyper/petstore/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md b/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md index 131b5dda5a8..3b39f8fe1e4 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **Get** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **Get** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/hyper/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/hyper/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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/docs/Vehicle.md b/samples/client/petstore/rust/hyper/petstore/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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/apis/testing_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs index fc1876aa030..6a25163f352 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs @@ -37,12 +37,21 @@ impl TestingApiClient } pub trait TestingApi: Send + Sync { + fn tests_discriminator_duplicate_enums_get(&self, ) -> Pin> + Send>>; fn tests_file_response_get(&self, ) -> Pin> + Send>>; fn tests_type_testing_get(&self, ) -> Pin> + Send>>; } implTestingApi for TestingApiClient where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn tests_discriminator_duplicate_enums_get(&self, ) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/discriminatorDuplicateEnums".to_string()) + ; + + req.execute(self.configuration.borrow()) + } + #[allow(unused_mut)] fn tests_file_response_get(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/fileResponse".to_string()) diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/hyper/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + 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 da642be6a19..ee02ccdd530 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/person.rs b/samples/client/petstore/rust/hyper/petstore/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/vehicle.rs b/samples/client/petstore/rust/hyper/petstore/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES index d935311d38c..b4b855f56c7 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/hyper0x/petstore/README.md b/samples/client/petstore/rust/hyper0x/petstore/README.md index c41a4d7e0e9..84d267b340f 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/README.md +++ b/samples/client/petstore/rust/hyper0x/petstore/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Person.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/hyper0x/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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/hyper0x/petstore/docs/Vehicle.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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/hyper0x/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs index a7df972d733..9b9f100d3b5 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs @@ -36,12 +36,21 @@ impl TestingApiClient } pub trait TestingApi { + fn tests_discriminator_duplicate_enums_get(&self, ) -> Pin>>>; fn tests_file_response_get(&self, ) -> Pin>>>; fn tests_type_testing_get(&self, ) -> Pin>>>; } implTestingApi for TestingApiClient where C: Clone + std::marker::Send + Sync { + #[allow(unused_mut)] + fn tests_discriminator_duplicate_enums_get(&self, ) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/discriminatorDuplicateEnums".to_string()) + ; + + req.execute(self.configuration.borrow()) + } + #[allow(unused_mut)] fn tests_file_response_get(&self, ) -> Pin>>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/fileResponse".to_string()) diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs index da642be6a19..ee02ccdd530 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/person.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/vehicle.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES index d935311d38c..b4b855f56c7 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/README.md b/samples/client/petstore/rust/reqwest-trait/petstore/README.md index abfb091ca35..e1495831e58 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/README.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Person.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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-trait/petstore/docs/Vehicle.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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-trait/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/apis/testing_api.rs index d59233d2d98..23e06cb6b74 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/apis/testing_api.rs @@ -23,6 +23,11 @@ use crate::apis::ContentType; #[async_trait] pub trait TestingApi: Send + Sync { + /// GET /tests/discriminatorDuplicateEnums + /// + /// + async fn tests_discriminator_duplicate_enums_get<>(&self, ) -> Result>; + /// GET /tests/fileResponse /// /// @@ -48,6 +53,43 @@ impl TestingApiClient { #[async_trait] impl TestingApi for TestingApiClient { + async fn tests_discriminator_duplicate_enums_get<>(&self, ) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/discriminatorDuplicateEnums", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestsDiscriminatorDuplicateEnumsGet200Response`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TestsDiscriminatorDuplicateEnumsGet200Response`")))), + } + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } + } + async fn tests_file_response_get<>(&self, ) -> Result> { let local_var_configuration = &self.configuration; @@ -124,6 +166,13 @@ impl TestingApi for TestingApiClient { } +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs index da642be6a19..ee02ccdd530 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/person.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + 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 d935311d38c..b4b855f56c7 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 @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.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 f478f035b2b..dd231fc2a3f 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Person.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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/docs/Vehicle.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs index 24717a36538..39951422299 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs @@ -15,6 +15,14 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +/// struct for typed successes of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetSuccess { + Status200(models::TestsDiscriminatorDuplicateEnumsGet200Response), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -31,6 +39,13 @@ pub enum TestsTypeTestingGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -46,6 +61,31 @@ pub enum TestsTypeTestingGetError { } +pub async fn tests_discriminator_duplicate_enums_get(configuration: &configuration::Configuration) -> Result, Error> { + + let uri_str = format!("{}/tests/discriminatorDuplicateEnums", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { let uri_str = format!("{}/tests/fileResponse", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + 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 da642be6a19..ee02ccdd530 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 @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/person.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES index d935311d38c..b4b855f56c7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md index e38f79988b8..ec65eefaa7b 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Person.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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-tokensource/docs/Vehicle.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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-tokensource/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs index 24717a36538..39951422299 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs @@ -15,6 +15,14 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +/// struct for typed successes of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetSuccess { + Status200(models::TestsDiscriminatorDuplicateEnumsGet200Response), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -31,6 +39,13 @@ pub enum TestsTypeTestingGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -46,6 +61,31 @@ pub enum TestsTypeTestingGetError { } +pub async fn tests_discriminator_duplicate_enums_get(configuration: &configuration::Configuration) -> Result, Error> { + + let uri_str = format!("{}/tests/discriminatorDuplicateEnums", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { let uri_str = format!("{}/tests/fileResponse", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs index da642be6a19..ee02ccdd530 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/person.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + 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 d935311d38c..b4b855f56c7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async/README.md b/samples/client/petstore/rust/reqwest/petstore-async/README.md index 72996d36543..a49b8383246 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Person.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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/docs/Vehicle.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs index 24717a36538..39951422299 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs @@ -15,6 +15,14 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +/// struct for typed successes of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetSuccess { + Status200(models::TestsDiscriminatorDuplicateEnumsGet200Response), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -31,6 +39,13 @@ pub enum TestsTypeTestingGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -46,6 +61,31 @@ pub enum TestsTypeTestingGetError { } +pub async fn tests_discriminator_duplicate_enums_get(configuration: &configuration::Configuration) -> Result, Error> { + + let uri_str = format!("{}/tests/discriminatorDuplicateEnums", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { let uri_str = format!("{}/tests/fileResponse", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + 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 da642be6a19..ee02ccdd530 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 @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/person.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES index d935311d38c..b4b855f56c7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md index 3dd5fd8df91..814ca9706a6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Person.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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-avoid-box/docs/Vehicle.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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-avoid-box/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs index 24717a36538..39951422299 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs @@ -15,6 +15,14 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +/// struct for typed successes of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetSuccess { + Status200(models::TestsDiscriminatorDuplicateEnumsGet200Response), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -31,6 +39,13 @@ pub enum TestsTypeTestingGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -46,6 +61,31 @@ pub enum TestsTypeTestingGetError { } +pub async fn tests_discriminator_duplicate_enums_get(configuration: &configuration::Configuration) -> Result, Error> { + + let uri_str = format!("{}/tests/discriminatorDuplicateEnums", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_file_response_get(configuration: &configuration::Configuration) -> Result> { let uri_str = format!("{}/tests/fileResponse", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs index da642be6a19..ee02ccdd530 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/person.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + 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 d935311d38c..b4b855f56c7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md index 5ed03ffe8db..8ccd2587a19 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Person.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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/docs/Vehicle.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs index ed232269085..ec77bc31852 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs @@ -15,6 +15,13 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -30,6 +37,40 @@ pub enum TestsTypeTestingGetError { } +pub fn tests_discriminator_duplicate_enums_get(configuration: &configuration::Configuration, ) -> Result> { + + let uri_str = format!("{}/tests/discriminatorDuplicateEnums", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestsDiscriminatorDuplicateEnumsGet200Response`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TestsDiscriminatorDuplicateEnumsGet200Response`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { let uri_str = format!("{}/tests/fileResponse", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + 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 da642be6a19..ee02ccdd530 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 @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/person.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES index 1c83a6638ad..4b93759e464 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES @@ -14,14 +14,17 @@ docs/FooNullableArray.md docs/FooNumericEnumTesting.md docs/FooOptionalTesting.md docs/FooOrder.md +docs/FooPerson.md docs/FooPet.md docs/FooPropertyTest.md docs/FooRef.md docs/FooReturn.md docs/FooTag.md +docs/FooTestsDiscriminatorDuplicateEnumsGet200Response.md docs/FooTypeTesting.md docs/FooUniqueItemArrayTesting.md docs/FooUser.md +docs/FooVehicle.md docs/PetApi.md docs/StoreApi.md docs/TestingApi.md @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/foo__tests_discriminator_duplicate_enums_get_200_response.rs src/models/foo_action_container.rs src/models/foo_any_type_test.rs src/models/foo_api_response.rs @@ -46,6 +50,7 @@ src/models/foo_nullable_array.rs src/models/foo_numeric_enum_testing.rs src/models/foo_optional_testing.rs src/models/foo_order.rs +src/models/foo_person.rs src/models/foo_pet.rs src/models/foo_property_test.rs src/models/foo_ref.rs @@ -54,4 +59,5 @@ src/models/foo_tag.rs src/models/foo_type_testing.rs src/models/foo_unique_item_array_testing.rs src/models/foo_user.rs +src/models/foo_vehicle.rs src/models/mod.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md index 1303b7a8174..5b39b1b6238 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [FooNumericEnumTesting](docs/FooNumericEnumTesting.md) - [FooOptionalTesting](docs/FooOptionalTesting.md) - [FooOrder](docs/FooOrder.md) + - [FooPerson](docs/FooPerson.md) - [FooPet](docs/FooPet.md) - [FooPropertyTest](docs/FooPropertyTest.md) - [FooRef](docs/FooRef.md) - [FooReturn](docs/FooReturn.md) - [FooTag](docs/FooTag.md) + - [FooTestsDiscriminatorDuplicateEnumsGet200Response](docs/FooTestsDiscriminatorDuplicateEnumsGet200Response.md) - [FooTypeTesting](docs/FooTypeTesting.md) - [FooUniqueItemArrayTesting](docs/FooUniqueItemArrayTesting.md) - [FooUser](docs/FooUser.md) + - [FooVehicle](docs/FooVehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPerson.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPerson.md new file mode 100644 index 00000000000..4d49712842a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPerson.md @@ -0,0 +1,12 @@ +# FooPerson + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..7d3e59af314 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# FooTestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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-model-name-prefix/docs/FooVehicle.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooVehicle.md new file mode 100644 index 00000000000..56cdd69ac69 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooVehicle.md @@ -0,0 +1,12 @@ +# FooVehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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-model-name-prefix/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md index b4e85b93b20..b977e72b885 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::FooTestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::FooTestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs index 9aeb411aed4..d8a822536bd 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs @@ -15,6 +15,13 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -30,6 +37,40 @@ pub enum TestsTypeTestingGetError { } +pub fn tests_discriminator_duplicate_enums_get(configuration: &configuration::Configuration, ) -> Result> { + + let uri_str = format!("{}/tests/discriminatorDuplicateEnums", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooTestsDiscriminatorDuplicateEnumsGet200Response`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooTestsDiscriminatorDuplicateEnumsGet200Response`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { let uri_str = format!("{}/tests/fileResponse", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo__tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo__tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..10653b9911a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo__tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum FooTestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + FooVehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + FooPersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + FooPersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for FooTestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::FooVehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_person.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_person.rs new file mode 100644 index 00000000000..f9cf485e6ba --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FooPerson { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl FooPerson { + pub fn new(r#type: String, name: String) -> FooPerson { + FooPerson { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_vehicle.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_vehicle.rs new file mode 100644 index 00000000000..3647e46f8a6 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FooVehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl FooVehicle { + pub fn new(r#type: String, speed: f64) -> FooVehicle { + FooVehicle { + r#type, + speed, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs index 256941bfbc1..6eb5170bcb7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs @@ -20,6 +20,8 @@ pub mod foo_optional_testing; pub use self::foo_optional_testing::FooOptionalTesting; pub mod foo_order; pub use self::foo_order::FooOrder; +pub mod foo_person; +pub use self::foo_person::FooPerson; pub mod foo_pet; pub use self::foo_pet::FooPet; pub mod foo_property_test; @@ -30,9 +32,13 @@ pub mod foo_return; pub use self::foo_return::FooReturn; pub mod foo_tag; pub use self::foo_tag::FooTag; +pub mod foo__tests_discriminator_duplicate_enums_get_200_response; +pub use self::foo__tests_discriminator_duplicate_enums_get_200_response::FooTestsDiscriminatorDuplicateEnumsGet200Response; pub mod foo_type_testing; pub use self::foo_type_testing::FooTypeTesting; pub mod foo_unique_item_array_testing; pub use self::foo_unique_item_array_testing::FooUniqueItemArrayTesting; pub mod foo_user; pub use self::foo_user::FooUser; +pub mod foo_vehicle; +pub use self::foo_vehicle::FooVehicle; diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES index d935311d38c..b4b855f56c7 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES @@ -14,6 +14,7 @@ docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md docs/Order.md +docs/Person.md docs/Pet.md docs/PetApi.md docs/PropertyTest.md @@ -22,10 +23,12 @@ docs/Return.md docs/StoreApi.md docs/Tag.md docs/TestingApi.md +docs/TestsDiscriminatorDuplicateEnumsGet200Response.md docs/TypeTesting.md docs/UniqueItemArrayTesting.md docs/User.md docs/UserApi.md +docs/Vehicle.md git_push.sh src/apis/configuration.rs src/apis/fake_api.rs @@ -35,6 +38,7 @@ src/apis/store_api.rs src/apis/testing_api.rs src/apis/user_api.rs src/lib.rs +src/models/_tests_discriminator_duplicate_enums_get_200_response.rs src/models/action_container.rs src/models/any_type_test.rs src/models/api_response.rs @@ -49,9 +53,11 @@ src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs src/models/order.rs +src/models/person.rs 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 +src/models/vehicle.rs diff --git a/samples/client/petstore/rust/reqwest/petstore/README.md b/samples/client/petstore/rust/reqwest/petstore/README.md index abfb091ca35..e1495831e58 100644 --- a/samples/client/petstore/rust/reqwest/petstore/README.md +++ b/samples/client/petstore/rust/reqwest/petstore/README.md @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description *StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_discriminator_duplicate_enums_get**](docs/TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user @@ -64,14 +65,17 @@ Class | Method | HTTP request | Description - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) - [Order](docs/Order.md) + - [Person](docs/Person.md) - [Pet](docs/Pet.md) - [PropertyTest](docs/PropertyTest.md) - [Ref](docs/Ref.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestsDiscriminatorDuplicateEnumsGet200Response](docs/TestsDiscriminatorDuplicateEnumsGet200Response.md) - [TypeTesting](docs/TypeTesting.md) - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) To get access to the crate's generated documentation, use: diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/Person.md b/samples/client/petstore/rust/reqwest/petstore/docs/Person.md new file mode 100644 index 00000000000..20b43cc0345 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md index 9c26af24912..1d26ae8655d 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md @@ -4,11 +4,37 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**tests_discriminator_duplicate_enums_get**](TestingApi.md#tests_discriminator_duplicate_enums_get) | **GET** /tests/discriminatorDuplicateEnums | Test for duplicate enums when using discriminator. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +## tests_discriminator_duplicate_enums_get + +> models::TestsDiscriminatorDuplicateEnumsGet200Response tests_discriminator_duplicate_enums_get() +Test for duplicate enums when using discriminator. (One of the issues in #20500) + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TestsDiscriminatorDuplicateEnumsGet200Response**](_tests_discriminatorDuplicateEnums_get_200_response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + ## tests_file_response_get > std::path::PathBuf tests_file_response_get() diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md b/samples/client/petstore/rust/reqwest/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md new file mode 100644 index 00000000000..43793582456 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/TestsDiscriminatorDuplicateEnumsGet200Response.md @@ -0,0 +1,10 @@ +# TestsDiscriminatorDuplicateEnumsGet200Response + +## Enum Variants + +| Name | Value | +|---- | -----| + +[[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/docs/Vehicle.md b/samples/client/petstore/rust/reqwest/petstore/docs/Vehicle.md new file mode 100644 index 00000000000..1a4b48467fd --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs index ed232269085..ec77bc31852 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs @@ -15,6 +15,13 @@ use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +/// struct for typed errors of method [`tests_discriminator_duplicate_enums_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsDiscriminatorDuplicateEnumsGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_file_response_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -30,6 +37,40 @@ pub enum TestsTypeTestingGetError { } +pub fn tests_discriminator_duplicate_enums_get(configuration: &configuration::Configuration, ) -> Result> { + + let uri_str = format!("{}/tests/discriminatorDuplicateEnums", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TestsDiscriminatorDuplicateEnumsGet200Response`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TestsDiscriminatorDuplicateEnumsGet200Response`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { let uri_str = format!("{}/tests/fileResponse", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs new file mode 100644 index 00000000000..5f777674594 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/_tests_discriminator_duplicate_enums_get_200_response.rs @@ -0,0 +1,57 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(tag = "objectType")] +pub enum TestsDiscriminatorDuplicateEnumsGet200Response { + #[serde(rename="car")] + Vehicle { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="student")] + PersonStudent { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, + #[serde(rename="teacher")] + PersonTeacher { + #[serde(rename = "type")] + r#type: String, + #[serde(rename = "name")] + name: String, + #[serde(rename = "speed")] + speed: f64, + }, +} + +impl Default for TestsDiscriminatorDuplicateEnumsGet200Response { + fn default() -> Self { + Self::Vehicle { + r#type: Default::default(), + name: Default::default(), + speed: Default::default(), + } + + } +} + + 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 da642be6a19..ee02ccdd530 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs @@ -20,6 +20,8 @@ pub mod optional_testing; pub use self::optional_testing::OptionalTesting; pub mod order; pub use self::order::Order; +pub mod person; +pub use self::person::Person; pub mod pet; pub use self::pet::Pet; pub mod property_test; @@ -30,9 +32,13 @@ pub mod model_return; pub use self::model_return::Return; pub mod tag; pub use self::tag::Tag; +pub mod _tests_discriminator_duplicate_enums_get_200_response; +pub use self::_tests_discriminator_duplicate_enums_get_200_response::TestsDiscriminatorDuplicateEnumsGet200Response; 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; +pub mod vehicle; +pub use self::vehicle::Vehicle; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/person.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/person.rs new file mode 100644 index 00000000000..67c2da45b5c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/vehicle.rs new file mode 100644 index 00000000000..45cf0f72115 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * 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 + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} +