Skip to content

Commit a7cacce

Browse files
[Rust-Axum] Dynamically set the types of integer literals (#20133)
* Dynamically set the types of integer literals * Change the literal limits from i32 to adaptive limits * Remove length literal types
1 parent 4c5a57f commit a7cacce

File tree

23 files changed

+44
-44
lines changed

23 files changed

+44
-44
lines changed

modules/openapi-generator/src/main/resources/rust-axum/models.mustache

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ use crate::{models, types::*};
4444
{{/pattern}}
4545
{{#maximum}}
4646
{{#minimum}}
47-
range(min = {{minimum}}, max = {{maximum}}),
47+
range(min = {{minimum}}{{{dataType}}}, max = {{maximum}}{{{dataType}}}),
4848
{{/minimum}}
4949
{{^minimum}}
50-
range(max = {{maximum}}),
50+
range(max = {{maximum}}{{{dataType}}}),
5151
{{/minimum}}
5252
{{/maximum}}
5353
{{#minimum}}
5454
{{^maximum}}
55-
range(min = {{minimum}}),
55+
range(min = {{minimum}}{{{dataType}}}),
5656
{{/maximum}}
5757
{{/minimum}}
5858
{{#maxItems}}
@@ -136,15 +136,15 @@ use crate::{models, types::*};
136136
{{/pattern}}
137137
{{#maximum}}
138138
{{#minimum}}
139-
range(min = {{minimum}}, max = {{maximum}}),
139+
range(min = {{minimum}}{{{dataType}}}, max = {{maximum}}{{{dataType}}}),
140140
{{/minimum}}
141141
{{^minimum}}
142-
range(max = {{maximum}}),
142+
range(max = {{maximum}}{{{dataType}}}),
143143
{{/minimum}}
144144
{{/maximum}}
145145
{{#minimum}}
146146
{{^maximum}}
147-
range(min = {{minimum}}),
147+
range(min = {{minimum}}{{{dataType}}}),
148148
{{/maximum}}
149149
{{/minimum}}
150150
{{#maxItems}}
@@ -240,15 +240,15 @@ use crate::{models, types::*};
240240
{{/pattern}}
241241
{{#maximum}}
242242
{{#minimum}}
243-
range(min = {{minimum}}, max = {{maximum}}),
243+
range(min = {{minimum}}{{{dataType}}}, max = {{maximum}}{{{dataType}}}),
244244
{{/minimum}}
245245
{{^minimum}}
246-
range(max = {{maximum}}),
246+
range(max = {{maximum}}{{{dataType}}}),
247247
{{/minimum}}
248248
{{/maximum}}
249249
{{#minimum}}
250250
{{^maximum}}
251-
range(min = {{minimum}}),
251+
range(min = {{minimum}}{{{dataType}}}),
252252
{{/maximum}}
253253
{{/minimum}}
254254
{{#maxItems}}
@@ -644,15 +644,15 @@ pub struct {{{classname}}} {
644644
{{/pattern}}
645645
{{#maximum}}
646646
{{#minimum}}
647-
range(min = {{minimum}}, max = {{maximum}}),
647+
range(min = {{minimum}}{{{dataType}}}, max = {{maximum}}{{{dataType}}}),
648648
{{/minimum}}
649649
{{^minimum}}
650-
range(max = {{maximum}}),
650+
range(max = {{maximum}}{{{dataType}}}),
651651
{{/minimum}}
652652
{{/maximum}}
653653
{{#minimum}}
654654
{{^maximum}}
655-
range(min = {{minimum}}),
655+
range(min = {{minimum}}{{{dataType}}}),
656656
{{/maximum}}
657657
{{/minimum}}
658658
{{#maxItems}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/apikey-auths/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 1.0.0
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/multipart-v3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 1.0.7
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/openapi-v3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 1.0.7
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/ops-v3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 0.0.1
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 1.0.0
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub struct DeleteOrderPathParams {
115115
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
116116
pub struct GetOrderByIdPathParams {
117117
/// ID of pet that needs to be fetched
118-
#[validate(range(min = 1, max = 5))]
118+
#[validate(range(min = 1i64, max = 5i64))]
119119
pub order_id: i64,
120120
}
121121

@@ -2739,12 +2739,12 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<EnumTest> {
27392739
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
27402740
pub struct FormatTest {
27412741
#[serde(rename = "integer")]
2742-
#[validate(range(min = 10, max = 100))]
2742+
#[validate(range(min = 10u8, max = 100u8))]
27432743
#[serde(skip_serializing_if = "Option::is_none")]
27442744
pub integer: Option<u8>,
27452745

27462746
#[serde(rename = "int32")]
2747-
#[validate(range(min = 20, max = 200))]
2747+
#[validate(range(min = 20u8, max = 200u8))]
27482748
#[serde(skip_serializing_if = "Option::is_none")]
27492749
pub int32: Option<u8>,
27502750

@@ -2753,16 +2753,16 @@ pub struct FormatTest {
27532753
pub int64: Option<i64>,
27542754

27552755
#[serde(rename = "number")]
2756-
#[validate(range(min = 32.1, max = 543.2))]
2756+
#[validate(range(min = 32.1f64, max = 543.2f64))]
27572757
pub number: f64,
27582758

27592759
#[serde(rename = "float")]
2760-
#[validate(range(min = 54.3, max = 987.6))]
2760+
#[validate(range(min = 54.3f32, max = 987.6f32))]
27612761
#[serde(skip_serializing_if = "Option::is_none")]
27622762
pub float: Option<f32>,
27632763

27642764
#[serde(rename = "double")]
2765-
#[validate(range(min = 67.8, max = 123.4))]
2765+
#[validate(range(min = 67.8f64, max = 123.4f64))]
27662766
#[serde(skip_serializing_if = "Option::is_none")]
27672767
pub double: Option<f64>,
27682768

@@ -5522,13 +5522,13 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<Tag> {
55225522
pub struct TestEndpointParametersRequest {
55235523
/// None
55245524
#[serde(rename = "integer")]
5525-
#[validate(range(min = 10, max = 100))]
5525+
#[validate(range(min = 10u8, max = 100u8))]
55265526
#[serde(skip_serializing_if = "Option::is_none")]
55275527
pub integer: Option<u8>,
55285528

55295529
/// None
55305530
#[serde(rename = "int32")]
5531-
#[validate(range(min = 20, max = 200))]
5531+
#[validate(range(min = 20u8, max = 200u8))]
55325532
#[serde(skip_serializing_if = "Option::is_none")]
55335533
pub int32: Option<u8>,
55345534

@@ -5539,18 +5539,18 @@ pub struct TestEndpointParametersRequest {
55395539

55405540
/// None
55415541
#[serde(rename = "number")]
5542-
#[validate(range(min = 32.1, max = 543.2))]
5542+
#[validate(range(min = 32.1f64, max = 543.2f64))]
55435543
pub number: f64,
55445544

55455545
/// None
55465546
#[serde(rename = "float")]
5547-
#[validate(range(max = 987.6))]
5547+
#[validate(range(max = 987.6f32))]
55485548
#[serde(skip_serializing_if = "Option::is_none")]
55495549
pub float: Option<f32>,
55505550

55515551
/// None
55525552
#[serde(rename = "double")]
5553-
#[validate(range(min = 67.8, max = 123.4))]
5553+
#[validate(range(min = 67.8f64, max = 123.4f64))]
55545554
pub double: f64,
55555555

55565556
/// None
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/petstore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 1.0.0
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

samples/server/petstore/rust-axum/output/petstore/src/models.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct DeleteOrderPathParams {
6969
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
7070
pub struct GetOrderByIdPathParams {
7171
/// ID of pet that needs to be fetched
72-
#[validate(range(min = 1, max = 5))]
72+
#[validate(range(min = 1i64, max = 5i64))]
7373
pub order_id: i64,
7474
}
7575

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/ping-bearer-auth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 1.0
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/rust-axum-header-uuid/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 0.1.9
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/rust-axum-test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 2.3.4
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0-SNAPSHOT
1+
7.11.0-SNAPSHOT

samples/server/petstore/rust-axum/output/rust-axum-validation-test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ server, you can easily generate a server stub.
1212
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
1313

1414
- API version: 0.0.1
15-
- Generator version: 7.10.0-SNAPSHOT
15+
- Generator version: 7.11.0-SNAPSHOT
1616

1717

1818

0 commit comments

Comments
 (0)