Skip to content

Commit f549147

Browse files
committed
Updated tests to now use chrono
1 parent c45a093 commit f549147

35 files changed

Lines changed: 41 additions & 24 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
905905
}
906906

907907
this.additionalProperties.put("hasUUIDs", hasUUIDs);
908-
this.additionalProperties.put("hasChronoType", hasChronoTypes);
908+
this.additionalProperties.put("hasChronoTypes", hasChronoTypes);
909909
return objs;
910910
}
911911

@@ -923,6 +923,12 @@ private boolean hasChronoTypeInProperties(List<CodegenProperty> properties) {
923923
return checkForPropertiesRecursively(properties, (property) -> property.isDate || property.isDateTime);
924924
}
925925

926+
/**
927+
* Recursively searches for a condition in a property
928+
* @param properties the {@link CodegenProperty} to recursively search for
929+
* @param propertyCheck the {@link Function} to be applied to check an individual {@link CodegenProperty} for a match
930+
* @return true if there is at least one match, false if there is no match
931+
*/
926932
private boolean checkForPropertiesRecursively(List<CodegenProperty> properties, Function<CodegenProperty, Boolean> propertyCheck){
927933
for (CodegenProperty property : properties) {
928934
if (propertyCheck.apply(property)) {

modules/openapi-generator/src/main/resources/rust/Cargo.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ url = "^2.5"
4646
uuid = { version = "^1.8", features = ["serde", "v4"] }
4747
{{/hasUUIDs}}
4848
{{#hasChronoTypes}}
49-
chrono = { version = "^0.4" }
49+
chrono = { version = "^0.4", features = ["serde"] }
5050
{{/hasChronoTypes}}
5151
{{#hyper}}
5252
{{#hyper0x}}

samples/client/petstore/rust/hyper/petstore/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ serde_json = "^1.0"
1313
serde_repr = "^0.1"
1414
url = "^2.5"
1515
uuid = { version = "^1.8", features = ["serde", "v4"] }
16+
chrono = { version = "^0.4", features = ["serde"] }
1617
hyper = { version = "^1.3.1", features = ["full"] }
1718
hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] }
1819
http-body-util = { version = "0.1.2" }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
77
**id** | Option<**i64**> | | [optional]
88
**pet_id** | Option<**i64**> | | [optional]
99
**quantity** | Option<**i32**> | | [optional]
10-
**ship_date** | Option<**String**> | | [optional]
10+
**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional]
1111
**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional]
1212
**complete** | Option<**bool**> | | [optional][default to false]
1313

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Order {
2121
#[serde(rename = "quantity", skip_serializing_if = "Option::is_none")]
2222
pub quantity: Option<i32>,
2323
#[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")]
24-
pub ship_date: Option<String>,
24+
pub ship_date: Option<chrono::NaiveDateTime>,
2525
/// Order Status
2626
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
2727
pub status: Option<Status>,

samples/client/petstore/rust/hyper0x/petstore/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ serde_json = "^1.0"
1313
serde_repr = "^0.1"
1414
url = "^2.5"
1515
uuid = { version = "^1.8", features = ["serde", "v4"] }
16+
chrono = { version = "^0.4", features = ["serde"] }
1617
hyper = { version = "~0.14", features = ["full"] }
1718
hyper-tls = "~0.5"
1819
http = "~0.2"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
77
**id** | Option<**i64**> | | [optional]
88
**pet_id** | Option<**i64**> | | [optional]
99
**quantity** | Option<**i32**> | | [optional]
10-
**ship_date** | Option<**String**> | | [optional]
10+
**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional]
1111
**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional]
1212
**complete** | Option<**bool**> | | [optional][default to false]
1313

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Order {
2121
#[serde(rename = "quantity", skip_serializing_if = "Option::is_none")]
2222
pub quantity: Option<i32>,
2323
#[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")]
24-
pub ship_date: Option<String>,
24+
pub ship_date: Option<chrono::NaiveDateTime>,
2525
/// Order Status
2626
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
2727
pub status: Option<Status>,

samples/client/petstore/rust/reqwest-trait/petstore/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ serde_json = "^1.0"
1313
serde_repr = "^0.1"
1414
url = "^2.5"
1515
uuid = { version = "^1.8", features = ["serde", "v4"] }
16+
chrono = { version = "^0.4", features = ["serde"] }
1617
async-trait = "^0.1"
1718
reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "stream", "query", "form"] }
1819
mockall = { version = "^0.13", optional = true}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
77
**id** | Option<**i64**> | | [optional]
88
**pet_id** | Option<**i64**> | | [optional]
99
**quantity** | Option<**i32**> | | [optional]
10-
**ship_date** | Option<**String**> | | [optional]
10+
**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional]
1111
**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional]
1212
**complete** | Option<**bool**> | | [optional][default to false]
1313

0 commit comments

Comments
 (0)