[rust] fixed compiler errors for decimal types (#20708)

This commit is contained in:
Ross Sullivan 2025-02-22 23:58:26 +09:00 committed by GitHub
parent 0ff8c46595
commit 28c7b9b956
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 59 additions and 11 deletions

View File

@ -206,6 +206,8 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
typeMapping.put("date", "string"); typeMapping.put("date", "string");
typeMapping.put("DateTime", "String"); typeMapping.put("DateTime", "String");
typeMapping.put("password", "String"); typeMapping.put("password", "String");
typeMapping.put("decimal", "String");
// TODO(bcourtine): review file mapping. // TODO(bcourtine): review file mapping.
// I tried to map as "std::io::File", but Reqwest multipart file requires a "AsRef<Path>" param. // I tried to map as "std::io::File", but Reqwest multipart file requires a "AsRef<Path>" param.
// Getting a file from a Path is simple, but the opposite is difficult. So I map as "std::path::Path". // Getting a file from a Path is simple, but the opposite is difficult. So I map as "std::path::Path".

View File

@ -871,6 +871,7 @@ components:
- boolean - boolean
- uuid - uuid
- bytes - bytes
- decimal
properties: properties:
int32: int32:
type: integer type: integer
@ -894,6 +895,9 @@ components:
bytes: bytes:
type: string type: string
format: byte format: byte
decimal:
type: string
format: number
Return: Return:
description: Test using keywords description: Test using keywords
type: object type: object

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct FooTypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl FooTypeTesting { impl FooTypeTesting {
/// Test handling of different field data types /// 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<u8>) -> FooTypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> FooTypeTesting {
FooTypeTesting { FooTypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl FooTypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -12,6 +12,7 @@ Name | Type | Description | Notes
**boolean** | **bool** | | **boolean** | **bool** | |
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | **uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
**bytes** | **String** | | **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) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -34,11 +34,13 @@ pub struct TypeTesting {
#[serde_as(as = "serde_with::base64::Base64")] #[serde_as(as = "serde_with::base64::Base64")]
#[serde(rename = "bytes")] #[serde(rename = "bytes")]
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
#[serde(rename = "decimal")]
pub decimal: String,
} }
impl TypeTesting { impl TypeTesting {
/// Test handling of different field data types /// 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<u8>) -> TypeTesting { pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
TypeTesting { TypeTesting {
int32, int32,
int64, int64,
@ -48,6 +50,7 @@ impl TypeTesting {
boolean, boolean,
uuid, uuid,
bytes, bytes,
decimal,
} }
} }
} }

View File

@ -13,7 +13,8 @@ fn test_types() {
string: String::from("something"), string: String::from("something"),
boolean: true, boolean: true,
uuid: Uuid::new_v4(), 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.int32), "i32");
assert_eq!(type_of(tt.int64), "i64"); 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.string), "alloc::string::String");
assert_eq!(type_of(tt.boolean), "bool"); assert_eq!(type_of(tt.boolean), "bool");
assert_eq!(type_of(tt.uuid), "uuid::Uuid"); assert_eq!(type_of(tt.uuid), "uuid::Uuid");
assert_eq!(type_of(tt.decimal), "alloc::string::String");
} }
fn type_of<T>(_: T) -> &'static str { fn type_of<T>(_: T) -> &'static str {