Skip to content

Commit bafab62

Browse files
committed
[rust] fixed compiler errors for decimal types
1 parent 0ff8c46 commit bafab62

File tree

23 files changed

+59
-11
lines changed

23 files changed

+59
-11
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ public RustClientCodegen() {
206206
typeMapping.put("date", "string");
207207
typeMapping.put("DateTime", "String");
208208
typeMapping.put("password", "String");
209+
typeMapping.put("decimal", "String");
210+
209211
// TODO(bcourtine): review file mapping.
210212
// I tried to map as "std::io::File", but Reqwest multipart file requires a "AsRef<Path>" param.
211213
// Getting a file from a Path is simple, but the opposite is difficult. So I map as "std::path::Path".

modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ components:
871871
- boolean
872872
- uuid
873873
- bytes
874+
- decimal
874875
properties:
875876
int32:
876877
type: integer
@@ -894,6 +895,9 @@ components:
894895
bytes:
895896
type: string
896897
format: byte
898+
decimal:
899+
type: string
900+
format: number
897901
Return:
898902
description: Test using keywords
899903
type: object

samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/hyper/petstore/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/hyper0x/petstore/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest-trait/petstore/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest/petstore-async/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct FooTypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl FooTypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> FooTypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> FooTypeTesting {
4244
FooTypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl FooTypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Name | Type | Description | Notes
1212
**boolean** | **bool** | |
1313
**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | |
1414
**bytes** | **String** | |
15+
**decimal** | **String** | |
1516

1617
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1718

samples/client/petstore/rust/reqwest/petstore/src/models/type_testing.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ pub struct TypeTesting {
3434
#[serde_as(as = "serde_with::base64::Base64")]
3535
#[serde(rename = "bytes")]
3636
pub bytes: Vec<u8>,
37+
#[serde(rename = "decimal")]
38+
pub decimal: String,
3739
}
3840

3941
impl TypeTesting {
4042
/// Test handling of different field data types
41-
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>) -> TypeTesting {
43+
pub fn new(int32: i32, int64: i64, float: f32, double: f64, string: String, boolean: bool, uuid: uuid::Uuid, bytes: Vec<u8>, decimal: String) -> TypeTesting {
4244
TypeTesting {
4345
int32,
4446
int64,
@@ -48,6 +50,7 @@ impl TypeTesting {
4850
boolean,
4951
uuid,
5052
bytes,
53+
decimal,
5154
}
5255
}
5356
}

samples/client/petstore/rust/reqwest/petstore/tests/type_testing.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ fn test_types() {
1313
string: String::from("something"),
1414
boolean: true,
1515
uuid: Uuid::new_v4(),
16-
bytes: vec![1,2,3,4]
16+
bytes: vec![1, 2, 3, 4],
17+
decimal: Some(String::from("foo")),
1718
};
1819
assert_eq!(type_of(tt.int32), "i32");
1920
assert_eq!(type_of(tt.int64), "i64");
@@ -22,6 +23,7 @@ fn test_types() {
2223
assert_eq!(type_of(tt.string), "alloc::string::String");
2324
assert_eq!(type_of(tt.boolean), "bool");
2425
assert_eq!(type_of(tt.uuid), "uuid::Uuid");
26+
assert_eq!(type_of(tt.decimal), "alloc::string::String");
2527
}
2628

2729
fn type_of<T>(_: T) -> &'static str {

0 commit comments

Comments
 (0)