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 351282d5cc5..6a944b06260 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 @@ -206,6 +206,8 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon typeMapping.put("date", "string"); typeMapping.put("DateTime", "String"); typeMapping.put("password", "String"); + typeMapping.put("decimal", "String"); + // TODO(bcourtine): review file mapping. // I tried to map as "std::io::File", but Reqwest multipart file requires a "AsRef" param. // Getting a file from a Path is simple, but the opposite is difficult. So I map as "std::path::Path". 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 97ead87c5e4..acad24abb04 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 @@ -871,6 +871,7 @@ components: - boolean - uuid - bytes + - decimal properties: int32: type: integer @@ -894,6 +895,9 @@ components: bytes: type: string format: byte + decimal: + type: string + format: number Return: description: Test using keywords type: object diff --git a/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/hyper/petstore/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/type_testing.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/type_testing.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md index 9d847fc1cbf..cc73c990687 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/foo_type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_type_testing.rs index 62147ee60b7..4fe82f1015f 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_type_testing.rs @@ -34,11 +34,13 @@ pub struct FooTypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl FooTypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> FooTypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> FooTypeTesting { FooTypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl FooTypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md index 4f650eb1aa2..393d1b9bd27 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md @@ -12,6 +12,7 @@ Name | Type | Description | Notes **boolean** | **bool** | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **bytes** | **String** | | +**decimal** | **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/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/type_testing.rs index dba87bdb3cf..9e797e82298 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/type_testing.rs @@ -34,11 +34,13 @@ pub struct TypeTesting { #[serde_as(as = "serde_with::base64::Base64")] #[serde(rename = "bytes")] pub bytes: Vec, + #[serde(rename = "decimal")] + pub decimal: String, } impl TypeTesting { /// Test handling of different field data types - pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec) -> TypeTesting { + pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec, decimal: String) -> TypeTesting { TypeTesting { int32, int64, @@ -48,6 +50,7 @@ impl TypeTesting { boolean, uuid, bytes, + decimal, } } } diff --git a/samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs index a6a710abf52..0ee189f7f5f 100644 --- a/samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs +++ b/samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs @@ -13,7 +13,8 @@ fn test_types() { string: String::from("something"), boolean: true, uuid: Uuid::new_v4(), - bytes: vec![1,2,3,4] + bytes: vec![1, 2, 3, 4], + decimal: String::from("foo"), }; assert_eq!(type_of(tt.int32), "i32"); assert_eq!(type_of(tt.int64), "i64"); @@ -22,6 +23,7 @@ fn test_types() { assert_eq!(type_of(tt.string), "alloc::string::String"); assert_eq!(type_of(tt.boolean), "bool"); assert_eq!(type_of(tt.uuid), "uuid::Uuid"); + assert_eq!(type_of(tt.decimal), "alloc::string::String"); } fn type_of(_: T) -> &'static str {