From c45a0931f4674424fd2d9ff1146e9953954bcb92 Mon Sep 17 00:00:00 2001 From: Richard Paterson Date: Mon, 6 Apr 2026 09:46:01 +0200 Subject: [PATCH 1/7] Functional Change --- .../codegen/languages/RustClientCodegen.java | 50 ++++++++++++++++--- .../src/main/resources/rust/Cargo.mustache | 3 ++ 2 files changed, 46 insertions(+), 7 deletions(-) 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 b90a1d98cf73..4ae5975c6479 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 @@ -45,6 +45,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; public class RustClientCodegen extends AbstractRustCodegen implements CodegenConfig { @@ -91,6 +92,9 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon // The API has at least one UUID type. // If the API does not contain any UUIDs we do not need depend on the `uuid` crate private boolean hasUUIDs = false; + // The API has at least one Chrono type. + // If the API does not contain any Dates or DateTimes we do not need to depend on the `chrono` crate + private boolean hasChronoTypes = false; @Override public CodegenType getTag() { @@ -182,8 +186,8 @@ public RustClientCodegen() { typeMapping.put("map", "std::collections::HashMap"); typeMapping.put("UUID", "uuid::Uuid"); typeMapping.put("URI", "String"); - typeMapping.put("date", "string"); - typeMapping.put("DateTime", "String"); + typeMapping.put("date", "chrono::NaiveDate"); + typeMapping.put("DateTime", "chrono::NaiveDateTime"); typeMapping.put("password", "String"); typeMapping.put("decimal", "String"); @@ -772,12 +776,21 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List properties) { + return checkForPropertiesRecursively(properties, (property) -> property.isUuid); + } + + /** + * Recursively searches for a model's properties for a Date or DateTime type field. + */ + private boolean hasChronoTypeInProperties(List properties) { + return checkForPropertiesRecursively(properties, (property) -> property.isDate || property.isDateTime); + } + + private boolean checkForPropertiesRecursively(List properties, Function propertyCheck){ for (CodegenProperty property : properties) { - if (property.isUuid) { + if (propertyCheck.apply(property)) { return true; } // Check nested properties - if (property.items != null && hasUuidInProperties(Collections.singletonList(property.items))) { + if (property.items != null && checkForPropertiesRecursively(Collections.singletonList(property.items), propertyCheck)) { return true; } - if (property.additionalProperties != null && hasUuidInProperties(Collections.singletonList(property.additionalProperties))) { + if (property.additionalProperties != null && checkForPropertiesRecursively(Collections.singletonList(property.additionalProperties), propertyCheck)) { return true; } - if (property.vars != null && hasUuidInProperties(property.vars)) { + if (property.vars != null && checkForPropertiesRecursively(property.vars, propertyCheck)) { return true; } } diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache index 16b981bedef9..dd37e223f2ab 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -45,6 +45,9 @@ url = "^2.5" {{#hasUUIDs}} uuid = { version = "^1.8", features = ["serde", "v4"] } {{/hasUUIDs}} +{{#hasChronoTypes}} +chrono = { version = "^0.4" } +{{/hasChronoTypes}} {{#hyper}} {{#hyper0x}} hyper = { version = "~0.14", features = ["full"] } From f5491475964e4227518eba9fa4fe7ee7e583cbea Mon Sep 17 00:00:00 2001 From: Richard Paterson Date: Mon, 6 Apr 2026 10:16:43 +0200 Subject: [PATCH 2/7] Updated tests to now use chrono --- .../openapitools/codegen/languages/RustClientCodegen.java | 8 +++++++- .../src/main/resources/rust/Cargo.mustache | 2 +- samples/client/petstore/rust/hyper/petstore/Cargo.toml | 1 + samples/client/petstore/rust/hyper/petstore/docs/Order.md | 2 +- .../petstore/rust/hyper/petstore/src/models/order.rs | 2 +- samples/client/petstore/rust/hyper0x/petstore/Cargo.toml | 1 + .../client/petstore/rust/hyper0x/petstore/docs/Order.md | 2 +- .../petstore/rust/hyper0x/petstore/src/models/order.rs | 2 +- .../petstore/rust/reqwest-trait/petstore/Cargo.toml | 1 + .../petstore/rust/reqwest-trait/petstore/docs/Order.md | 2 +- .../rust/reqwest-trait/petstore/src/models/order.rs | 2 +- .../rust/reqwest/petstore-async-middleware/Cargo.toml | 1 + .../rust/reqwest/petstore-async-middleware/docs/Order.md | 2 +- .../reqwest/petstore-async-middleware/src/models/order.rs | 2 +- .../rust/reqwest/petstore-async-tokensource/Cargo.toml | 1 + .../rust/reqwest/petstore-async-tokensource/docs/Order.md | 2 +- .../petstore-async-tokensource/src/models/order.rs | 2 +- .../petstore/rust/reqwest/petstore-async/Cargo.toml | 1 + .../petstore/rust/reqwest/petstore-async/docs/Order.md | 2 +- .../rust/reqwest/petstore-async/src/models/order.rs | 2 +- .../petstore/rust/reqwest/petstore-avoid-box/Cargo.toml | 1 + .../rust/reqwest/petstore-avoid-box/docs/Order.md | 2 +- .../rust/reqwest/petstore-avoid-box/src/models/order.rs | 2 +- .../rust/reqwest/petstore-awsv4signature/Cargo.toml | 1 + .../rust/reqwest/petstore-awsv4signature/docs/Order.md | 2 +- .../reqwest/petstore-awsv4signature/src/models/order.rs | 2 +- .../rust/reqwest/petstore-model-name-prefix/Cargo.toml | 1 + .../reqwest/petstore-model-name-prefix/docs/FooOrder.md | 2 +- .../petstore-model-name-prefix/src/models/foo_order.rs | 2 +- .../rust/reqwest/petstore-serde-path-to-error/Cargo.toml | 1 + .../reqwest/petstore-serde-path-to-error/docs/Order.md | 2 +- .../petstore-serde-path-to-error/src/models/order.rs | 2 +- samples/client/petstore/rust/reqwest/petstore/Cargo.toml | 1 + .../client/petstore/rust/reqwest/petstore/docs/Order.md | 2 +- .../petstore/rust/reqwest/petstore/src/models/order.rs | 2 +- 35 files changed, 41 insertions(+), 24 deletions(-) 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 4ae5975c6479..361c7d3b2791 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 @@ -905,7 +905,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List properties) { return checkForPropertiesRecursively(properties, (property) -> property.isDate || property.isDateTime); } + /** + * Recursively searches for a condition in a property + * @param properties the {@link CodegenProperty} to recursively search for + * @param propertyCheck the {@link Function} to be applied to check an individual {@link CodegenProperty} for a match + * @return true if there is at least one match, false if there is no match + */ private boolean checkForPropertiesRecursively(List properties, Function propertyCheck){ for (CodegenProperty property : properties) { if (propertyCheck.apply(property)) { diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache index dd37e223f2ab..1ccb78f96fcd 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -46,7 +46,7 @@ url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } {{/hasUUIDs}} {{#hasChronoTypes}} -chrono = { version = "^0.4" } +chrono = { version = "^0.4", features = ["serde"] } {{/hasChronoTypes}} {{#hyper}} {{#hyper0x}} diff --git a/samples/client/petstore/rust/hyper/petstore/Cargo.toml b/samples/client/petstore/rust/hyper/petstore/Cargo.toml index a9eedf18dea5..d235972838b4 100644 --- a/samples/client/petstore/rust/hyper/petstore/Cargo.toml +++ b/samples/client/petstore/rust/hyper/petstore/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } hyper = { version = "^1.3.1", features = ["full"] } hyper-util = { version = "0.1.5", features = ["client", "client-legacy", "http1", "http2"] } http-body-util = { version = "0.1.2" } diff --git a/samples/client/petstore/rust/hyper/petstore/docs/Order.md b/samples/client/petstore/rust/hyper/petstore/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs index e81f64a29808..ab725449d756 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/hyper0x/petstore/Cargo.toml b/samples/client/petstore/rust/hyper0x/petstore/Cargo.toml index a1b39ea2340f..f3a38b0650a6 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/Cargo.toml +++ b/samples/client/petstore/rust/hyper0x/petstore/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } hyper = { version = "~0.14", features = ["full"] } hyper-tls = "~0.5" http = "~0.2" diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs index e81f64a29808..ab725449d756 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/Cargo.toml b/samples/client/petstore/rust/reqwest-trait/petstore/Cargo.toml index 247dd258ab92..d2448eb8030b 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/Cargo.toml +++ b/samples/client/petstore/rust/reqwest-trait/petstore/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } async-trait = "^0.1" reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "stream", "query", "form"] } mockall = { version = "^0.13", optional = true} diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs index a66e7dbb5689..b59834fdbb88 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml index 828fb5eed7b9..af923f39a9fb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } tokio = { version = "^1.46.0", features = ["fs"] } tokio-util = { version = "^0.7", features = ["codec"] } reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "stream", "query", "form"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs index e81f64a29808..ab725449d756 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml index 8c048ea5011b..17109d673be7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } tokio = { version = "^1.46.0", features = ["fs"] } tokio-util = { version = "^0.7", features = ["codec"] } reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "stream", "query", "form"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs index e81f64a29808..ab725449d756 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml index 669e37f37908..acb30770e7d0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } tokio = { version = "^1.46.0", features = ["fs"] } tokio-util = { version = "^0.7", features = ["codec"] } reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "stream", "query", "form"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs index e81f64a29808..ab725449d756 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml index 07d1d1b5e45f..f980a300eea6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } tokio = { version = "^1.46.0", features = ["fs"] } tokio-util = { version = "^0.7", features = ["codec"] } reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "stream", "query", "form"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs index e81f64a29808..ab725449d756 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml index e7abf677ae26..31f43147374b 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } aws-sigv4 = "0.3.0" http = "0.2.5" secrecy = "0.8.0" diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs index e81f64a29808..ab725449d756 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/Cargo.toml index f169c7176d0c..d3c7022b1fcd 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } reqwest = { version = "^0.13", default-features = false, features = ["json", "blocking", "multipart", "query", "form"] } [features] diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md index 47dc108651df..889f5ce43459 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs index 1b504b7a984b..d552b9bff2af 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs @@ -21,7 +21,7 @@ pub struct FooOrder { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/Cargo.toml index 0fe629323f08..0db56a51e107 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/Cargo.toml @@ -14,6 +14,7 @@ serde_repr = "^0.1" serde_path_to_error = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } tokio = { version = "^1.46.0", features = ["fs"] } tokio-util = { version = "^0.7", features = ["codec"] } reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "stream", "query", "form"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs index a66e7dbb5689..b59834fdbb88 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml index d9ee0b5e481a..8f467c6f3c81 100644 --- a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml @@ -13,6 +13,7 @@ serde_json = "^1.0" serde_repr = "^0.1" url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } +chrono = { version = "^0.4", features = ["serde"] } reqwest = { version = "^0.13", default-features = false, features = ["json", "blocking", "multipart", "query", "form"] } [dev-dependencies] diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md index ee573a52eb8a..600305eb0033 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**String**> | | [optional] +**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs index a66e7dbb5689..b59834fdbb88 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, From 4598f8c56526c5babf9594a779e816f46f809965 Mon Sep 17 00:00:00 2001 From: Richard Paterson Date: Mon, 6 Apr 2026 12:41:00 +0200 Subject: [PATCH 3/7] Added no chrono test case --- .../rust-reqwest-petstore-no-chrono.yaml | 11 + .../codegen/languages/RustClientCodegen.java | 47 +- .../src/main/resources/rust/Cargo.mustache | 4 +- .../reqwest/petstore-no-chrono/.gitignore | 3 + .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 71 +++ .../.openapi-generator/VERSION | 1 + .../reqwest/petstore-no-chrono/.travis.yml | 1 + .../reqwest/petstore-no-chrono/Cargo.toml | 21 + .../rust/reqwest/petstore-no-chrono/README.md | 98 ++++ .../docs/ActionContainer.md | 11 + .../petstore-no-chrono/docs/AnyTypeTest.md | 11 + .../petstore-no-chrono/docs/ApiResponse.md | 13 + .../docs/ArrayItemRefTest.md | 12 + .../reqwest/petstore-no-chrono/docs/Baz.md | 14 + .../petstore-no-chrono/docs/Category.md | 12 + .../docs/EnumArrayTesting.md | 11 + .../petstore-no-chrono/docs/FakeApi.md | 43 ++ .../docs/ModelWithInlineEnum.md | 14 + .../docs/ModelWithInlineEnumMetadata.md | 11 + .../petstore-no-chrono/docs/NullableArray.md | 14 + .../docs/NumericEnumTesting.md | 15 + .../docs/OptionalTesting.md | 14 + .../reqwest/petstore-no-chrono/docs/Order.md | 16 + .../reqwest/petstore-no-chrono/docs/Page.md | 12 + .../reqwest/petstore-no-chrono/docs/Person.md | 12 + .../reqwest/petstore-no-chrono/docs/Pet.md | 16 + .../reqwest/petstore-no-chrono/docs/PetApi.md | 324 +++++++++++ .../petstore-no-chrono/docs/PropertyTest.md | 11 + .../reqwest/petstore-no-chrono/docs/Ref.md | 11 + .../reqwest/petstore-no-chrono/docs/Return.md | 13 + .../petstore-no-chrono/docs/StoreApi.md | 129 +++++ .../reqwest/petstore-no-chrono/docs/Tag.md | 12 + .../docs/TestAllOfWithMultiMetadataOnly.md | 12 + .../petstore-no-chrono/docs/TestingApi.md | 151 +++++ .../petstore-no-chrono/docs/TypeTesting.md | 20 + .../docs/UniqueItemArrayTesting.md | 11 + .../reqwest/petstore-no-chrono/docs/User.md | 18 + .../petstore-no-chrono/docs/UserApi.md | 255 +++++++++ .../petstore-no-chrono/docs/Vehicle.md | 12 + .../petstore-no-chrono/docs/WithInnerOneOf.md | 11 + .../reqwest/petstore-no-chrono/git_push.sh | 57 ++ .../src/apis/configuration.rs | 51 ++ .../petstore-no-chrono/src/apis/fake_api.rs | 68 +++ .../petstore-no-chrono/src/apis/mod.rs | 120 ++++ .../petstore-no-chrono/src/apis/pet_api.rs | 525 ++++++++++++++++++ .../petstore-no-chrono/src/apis/store_api.rs | 195 +++++++ .../src/apis/testing_api.rs | 225 ++++++++ .../petstore-no-chrono/src/apis/user_api.rs | 369 ++++++++++++ .../reqwest/petstore-no-chrono/src/lib.rs | 11 + .../src/models/action_container.rs | 27 + .../src/models/any_type_test.rs | 27 + .../src/models/api_response.rs | 35 ++ .../src/models/array_item_ref_test.rs | 32 ++ .../petstore-no-chrono/src/models/baz.rs | 42 ++ .../petstore-no-chrono/src/models/category.rs | 32 ++ .../src/models/enum_array_testing.rs | 45 ++ .../petstore-no-chrono/src/models/mod.rs | 89 +++ .../src/models/model_ref.rs | 29 + .../src/models/model_return.rs | 35 ++ .../src/models/model_with_inline_enum.rs | 73 +++ .../models/model_with_inline_enum_metadata.rs | 29 + .../src/models/nullable_array.rs | 36 ++ .../src/models/numeric_enum_testing.rs | 42 ++ .../src/models/optional_testing.rs | 38 ++ .../petstore-no-chrono/src/models/order.rs | 61 ++ .../petstore-no-chrono/src/models/page.rs | 30 + .../petstore-no-chrono/src/models/person.rs | 30 + .../petstore-no-chrono/src/models/pet.rs | 61 ++ .../src/models/property_test.rs | 29 + .../petstore-no-chrono/src/models/tag.rs | 32 ++ .../test_all_of_with_multi_metadata_only.rs | 31 ++ .../src/models/type_testing.rs | 61 ++ .../src/models/unique_item_array_testing.rs | 46 ++ .../petstore-no-chrono/src/models/user.rs | 51 ++ .../petstore-no-chrono/src/models/vehicle.rs | 30 + .../src/models/with_inner_one_of.rs | 27 + 77 files changed, 4231 insertions(+), 11 deletions(-) create mode 100644 bin/configs/rust-reqwest-petstore-no-chrono.yaml create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/.gitignore create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator-ignore create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/FILES create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/VERSION create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/.travis.yml create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/Cargo.toml create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/README.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ActionContainer.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/AnyTypeTest.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ApiResponse.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ArrayItemRefTest.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Baz.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Category.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/EnumArrayTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/FakeApi.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ModelWithInlineEnum.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ModelWithInlineEnumMetadata.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/NullableArray.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/NumericEnumTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/OptionalTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Order.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Page.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Person.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Pet.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/PetApi.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/PropertyTest.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Ref.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Return.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/StoreApi.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Tag.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TestAllOfWithMultiMetadataOnly.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TestingApi.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TypeTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/UniqueItemArrayTesting.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/User.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/UserApi.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Vehicle.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/WithInnerOneOf.md create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/git_push.sh create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/fake_api.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/mod.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/pet_api.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/store_api.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/testing_api.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/user_api.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/lib.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/action_container.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/any_type_test.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/api_response.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/array_item_ref_test.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/baz.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/category.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/enum_array_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/mod.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_ref.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_return.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum_metadata.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/nullable_array.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/numeric_enum_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/optional_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/order.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/page.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/person.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/pet.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/property_test.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/tag.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/test_all_of_with_multi_metadata_only.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/type_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/unique_item_array_testing.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/user.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/vehicle.rs create mode 100644 samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/with_inner_one_of.rs diff --git a/bin/configs/rust-reqwest-petstore-no-chrono.yaml b/bin/configs/rust-reqwest-petstore-no-chrono.yaml new file mode 100644 index 000000000000..2a0cc7328c76 --- /dev/null +++ b/bin/configs/rust-reqwest-petstore-no-chrono.yaml @@ -0,0 +1,11 @@ +generatorName: rust +outputDir: samples/client/petstore/rust/reqwest/petstore-no-chrono +library: reqwest +inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/rust +additionalProperties: + supportAsync: false + useChrono: false + packageName: petstore-reqwest-no-chrono +enumNameMappings: + delivered: shipped 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 361c7d3b2791..865de031e16f 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 @@ -55,6 +55,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon @Setter(AccessLevel.PRIVATE) private boolean supportMiddleware = false; @Setter(AccessLevel.PRIVATE) private boolean useSerdePathToError = false; @Setter(AccessLevel.PRIVATE) private boolean supportTokenSource = false; + private boolean useChrono = true; private boolean supportMultipleResponses = false; private boolean withAWSV4Signature = false; @Setter private boolean preferUnsignedInt = false; @@ -74,6 +75,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon public static final String SUPPORT_MIDDLEWARE = "supportMiddleware"; public static final String USE_SERDE_PATH_TO_ERROR = "useSerdePathToError"; public static final String SUPPORT_TOKEN_SOURCE = "supportTokenSource"; + public static final String USE_CHRONO = "useChrono"; public static final String SUPPORT_MULTIPLE_RESPONSES = "supportMultipleResponses"; public static final String PREFER_UNSIGNED_INT = "preferUnsignedInt"; public static final String BEST_FIT_INT = "bestFitInt"; @@ -94,7 +96,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon private boolean hasUUIDs = false; // The API has at least one Chrono type. // If the API does not contain any Dates or DateTimes we do not need to depend on the `chrono` crate - private boolean hasChronoTypes = false; + private boolean usesChronoTypes = false; @Override public CodegenType getTag() { @@ -186,8 +188,10 @@ public RustClientCodegen() { typeMapping.put("map", "std::collections::HashMap"); typeMapping.put("UUID", "uuid::Uuid"); typeMapping.put("URI", "String"); + // Temporarily set the default to chrono. Then when `processOpts` is called it will update to not use chrono if specified typeMapping.put("date", "chrono::NaiveDate"); typeMapping.put("DateTime", "chrono::NaiveDateTime"); + typeMapping.put("password", "String"); typeMapping.put("decimal", "String"); @@ -220,6 +224,8 @@ public RustClientCodegen() { .defaultValue(Boolean.FALSE.toString())); cliOptions.add(new CliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); + cliOptions.add(new CliOption(USE_CHRONO, "If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::NaiveDateTime` for `date-time`)", SchemaTypeUtil.BOOLEAN_TYPE) + .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix)); @@ -467,6 +473,11 @@ public void processOpts() { } writePropertyBack(SUPPORT_TOKEN_SOURCE, getSupportTokenSource()); + if (additionalProperties.containsKey(USE_CHRONO)) { + this.setUseChrono(convertPropertyToBoolean(USE_CHRONO)); + } + writePropertyBack(USE_CHRONO, isUseChrono()); + if (additionalProperties.containsKey(SUPPORT_MULTIPLE_RESPONSES)) { this.setSupportMultipleReturns(convertPropertyToBoolean(SUPPORT_MULTIPLE_RESPONSES)); } @@ -784,11 +795,13 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List boolean hasDuplicateValues(Map map) { Set uniqueValues = new HashSet<>(map.values()); return uniqueValues.size() < map.size(); } + + + private boolean isUseChrono() { + return useChrono; + } + + private void setUseChrono(boolean useChrono) { + this.useChrono = useChrono; + if(isUseChrono()){ + typeMapping.put("date", "chrono::NaiveDate"); + typeMapping.put("DateTime", "chrono::NaiveDateTime"); + }else{ + typeMapping.put("date", "String"); + typeMapping.put("DateTime", "String"); + } + } } diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache index 1ccb78f96fcd..d1cb78a1e9f4 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -45,9 +45,9 @@ url = "^2.5" {{#hasUUIDs}} uuid = { version = "^1.8", features = ["serde", "v4"] } {{/hasUUIDs}} -{{#hasChronoTypes}} +{{#usesChronoTypes}} chrono = { version = "^0.4", features = ["serde"] } -{{/hasChronoTypes}} +{{/usesChronoTypes}} {{#hyper}} {{#hyper0x}} hyper = { version = "~0.14", features = ["full"] } diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/.gitignore b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/FILES new file mode 100644 index 000000000000..47b8ff2042ca --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/FILES @@ -0,0 +1,71 @@ +.gitignore +.travis.yml +Cargo.toml +README.md +docs/ActionContainer.md +docs/AnyTypeTest.md +docs/ApiResponse.md +docs/ArrayItemRefTest.md +docs/Baz.md +docs/Category.md +docs/EnumArrayTesting.md +docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md +docs/NullableArray.md +docs/NumericEnumTesting.md +docs/OptionalTesting.md +docs/Order.md +docs/Page.md +docs/Person.md +docs/Pet.md +docs/PetApi.md +docs/PropertyTest.md +docs/Ref.md +docs/Return.md +docs/StoreApi.md +docs/Tag.md +docs/TestAllOfWithMultiMetadataOnly.md +docs/TestingApi.md +docs/TypeTesting.md +docs/UniqueItemArrayTesting.md +docs/User.md +docs/UserApi.md +docs/Vehicle.md +docs/WithInnerOneOf.md +git_push.sh +src/apis/configuration.rs +src/apis/fake_api.rs +src/apis/mod.rs +src/apis/pet_api.rs +src/apis/store_api.rs +src/apis/testing_api.rs +src/apis/user_api.rs +src/lib.rs +src/models/action_container.rs +src/models/any_type_test.rs +src/models/api_response.rs +src/models/array_item_ref_test.rs +src/models/baz.rs +src/models/category.rs +src/models/enum_array_testing.rs +src/models/mod.rs +src/models/model_ref.rs +src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs +src/models/nullable_array.rs +src/models/numeric_enum_testing.rs +src/models/optional_testing.rs +src/models/order.rs +src/models/page.rs +src/models/person.rs +src/models/pet.rs +src/models/property_test.rs +src/models/tag.rs +src/models/test_all_of_with_multi_metadata_only.rs +src/models/type_testing.rs +src/models/unique_item_array_testing.rs +src/models/user.rs +src/models/vehicle.rs +src/models/with_inner_one_of.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/VERSION new file mode 100644 index 000000000000..f7962df3e243 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.22.0-SNAPSHOT diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/.travis.yml b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.travis.yml new file mode 100644 index 000000000000..22761ba7ee19 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-no-chrono/Cargo.toml new file mode 100644 index 000000000000..f562208793f3 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "petstore-reqwest-no-chrono" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] +description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters." +license = "Apache-2.0" +edition = "2021" + +[dependencies] +serde = { version = "^1.0", features = ["derive"] } +serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] } +serde_json = "^1.0" +serde_repr = "^0.1" +url = "^2.5" +uuid = { version = "^1.8", features = ["serde", "v4"] } +reqwest = { version = "^0.13", default-features = false, features = ["json", "blocking", "multipart", "query", "form"] } + +[features] +default = ["native-tls"] +native-tls = ["reqwest/native-tls"] +rustls = ["reqwest/rustls"] diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/README.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/README.md new file mode 100644 index 000000000000..48d6cce053fc --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/README.md @@ -0,0 +1,98 @@ +# Rust API client for petstore-reqwest-no-chrono + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.22.0-SNAPSHOT +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `petstore-reqwest-no-chrono` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +petstore-reqwest-no-chrono = { path = "./petstore-reqwest-no-chrono" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*FakeApi* | [**test_nullable_required_param**](docs/FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{user_name} | To test nullable required parameters +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**pets_explode_post**](docs/PetApi.md#pets_explode_post) | **POST** /pets/explode | List all pets +*PetApi* | [**pets_post**](docs/PetApi.md#pets_post) | **POST** /pets | List all pets +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) +*TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors +*TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [ActionContainer](docs/ActionContainer.md) + - [AnyTypeTest](docs/AnyTypeTest.md) + - [ApiResponse](docs/ApiResponse.md) + - [ArrayItemRefTest](docs/ArrayItemRefTest.md) + - [Baz](docs/Baz.md) + - [Category](docs/Category.md) + - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) + - [NullableArray](docs/NullableArray.md) + - [NumericEnumTesting](docs/NumericEnumTesting.md) + - [OptionalTesting](docs/OptionalTesting.md) + - [Order](docs/Order.md) + - [Page](docs/Page.md) + - [Person](docs/Person.md) + - [Pet](docs/Pet.md) + - [PropertyTest](docs/PropertyTest.md) + - [Ref](docs/Ref.md) + - [Return](docs/Return.md) + - [Tag](docs/Tag.md) + - [TestAllOfWithMultiMetadataOnly](docs/TestAllOfWithMultiMetadataOnly.md) + - [TypeTesting](docs/TypeTesting.md) + - [UniqueItemArrayTesting](docs/UniqueItemArrayTesting.md) + - [User](docs/User.md) + - [Vehicle](docs/Vehicle.md) + - [WithInnerOneOf](docs/WithInnerOneOf.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ActionContainer.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ActionContainer.md new file mode 100644 index 000000000000..4e0a0ba49615 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ActionContainer.md @@ -0,0 +1,11 @@ +# ActionContainer + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**action** | [**models::Baz**](Baz.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) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/AnyTypeTest.md new file mode 100644 index 000000000000..ed6cc47063ac --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/AnyTypeTest.md @@ -0,0 +1,11 @@ +# AnyTypeTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | Option<**serde_json::Value**> | | + +[[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-no-chrono/docs/ApiResponse.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ApiResponse.md new file mode 100644 index 000000000000..b5125ba685b1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ApiResponse.md @@ -0,0 +1,13 @@ +# ApiResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | Option<**i32**> | | [optional] +**r#type** | Option<**String**> | | [optional] +**message** | Option<**String**> | | [optional] + +[[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-no-chrono/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ArrayItemRefTest.md new file mode 100644 index 000000000000..bbb039922bd7 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ArrayItemRefTest.md @@ -0,0 +1,12 @@ +# ArrayItemRefTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**list_with_array_ref** | [**Vec>**](Vec.md) | | +**list_with_object_ref** | **Vec>** | | + +[[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-no-chrono/docs/Baz.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Baz.md new file mode 100644 index 000000000000..e9c4c693d898 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Baz.md @@ -0,0 +1,14 @@ +# Baz + +## Enum Variants + +| Name | Value | +|---- | -----| +| A | A | +| B | B | +| Empty | | + + +[[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-no-chrono/docs/Category.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Category.md new file mode 100644 index 000000000000..1cf67347c057 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Category.md @@ -0,0 +1,12 @@ +# Category + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**name** | Option<**String**> | | [optional] + +[[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-no-chrono/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/EnumArrayTesting.md new file mode 100644 index 000000000000..cdac6bc1965a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/EnumArrayTesting.md @@ -0,0 +1,11 @@ +# EnumArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**required_enums** | **Vec** | (enum: A, B, C) | + +[[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-no-chrono/docs/FakeApi.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/FakeApi.md new file mode 100644 index 000000000000..ca1ec4a34638 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/FakeApi.md @@ -0,0 +1,43 @@ +# \FakeApi + +All URIs are relative to *http://localhost/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_nullable_required_param**](FakeApi.md#test_nullable_required_param) | **GET** /fake/user/{user_name} | To test nullable required parameters + + + +## test_nullable_required_param + +> test_nullable_required_param(user_name, dummy_required_nullable_param, any_type, uppercase, content) +To test nullable required parameters + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user_name** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] | +**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] | +**any_type** | **String** | | [required] | +**uppercase** | Option<**String**> | To test parameter names in upper case | | +**content** | Option<**String**> | To test escaping of parameters in rust code works | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[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-no-chrono/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[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-no-chrono/docs/NullableArray.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/NullableArray.md new file mode 100644 index 000000000000..3b4aaa9668fc --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/NullableArray.md @@ -0,0 +1,14 @@ +# NullableArray + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_nullable** | Option<**Vec**> | | [optional] +**just_array** | Option<**Vec**> | | [optional] +**nullable_string** | Option<**String**> | | [optional] +**just_string** | Option<**String**> | | [optional] + +[[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-no-chrono/docs/NumericEnumTesting.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/NumericEnumTesting.md new file mode 100644 index 000000000000..6e99038d397e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/NumericEnumTesting.md @@ -0,0 +1,15 @@ +# NumericEnumTesting + +## Enum Variants + +| Name | Value | +|---- | -----| +| Variant0 | 0 | +| Variant1 | 1 | +| Variant2 | 2 | +| Variant3 | 3 | + + +[[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-no-chrono/docs/OptionalTesting.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/OptionalTesting.md new file mode 100644 index 000000000000..029e38eb9772 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/OptionalTesting.md @@ -0,0 +1,14 @@ +# OptionalTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**optional_nonnull** | Option<**String**> | | [optional] +**required_nonnull** | **String** | | +**optional_nullable** | Option<**String**> | | [optional] +**required_nullable** | Option<**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-no-chrono/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Order.md new file mode 100644 index 000000000000..ee573a52eb8a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Order.md @@ -0,0 +1,16 @@ +# Order + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**pet_id** | Option<**i64**> | | [optional] +**quantity** | Option<**i32**> | | [optional] +**ship_date** | Option<**String**> | | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] +**complete** | Option<**bool**> | | [optional][default to false] + +[[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-no-chrono/docs/Page.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Page.md new file mode 100644 index 000000000000..dac3d45928d3 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Page.md @@ -0,0 +1,12 @@ +# Page + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**page** | Option<**i32**> | | [optional] +**per_page** | Option<**i32**> | | [optional] + +[[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-no-chrono/docs/Person.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Person.md new file mode 100644 index 000000000000..20b43cc0345e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Person.md @@ -0,0 +1,12 @@ +# Person + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**name** | **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-no-chrono/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Pet.md new file mode 100644 index 000000000000..ac5bbde8c174 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Pet.md @@ -0,0 +1,16 @@ +# Pet + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**category** | Option<[**models::Category**](Category.md)> | | [optional] +**name** | **String** | | +**photo_urls** | **Vec** | | +**tags** | Option<[**Vec**](Tag.md)> | | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] + +[[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-no-chrono/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/PetApi.md new file mode 100644 index 000000000000..63d277a8830d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/PetApi.md @@ -0,0 +1,324 @@ +# \PetApi + +All URIs are relative to *http://localhost/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**pets_explode_post**](PetApi.md#pets_explode_post) | **POST** /pets/explode | List all pets +[**pets_post**](PetApi.md#pets_post) | **POST** /pets | List all pets +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +## add_pet + +> models::Pet add_pet(pet) +Add a new pet to the store + +This is the description for the addPet operation + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] | + +### Return type + +[**models::Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_pet + +> delete_pet(pet_id, api_key) +Deletes a pet + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | Pet id to delete | [required] | +**api_key** | Option<**String**> | | | + +### Return type + + (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## find_pets_by_status + +> Vec find_pets_by_status(status, r#type) +Finds Pets by status + +Multiple status values can be provided with comma separated strings. This is also a multi-line description to test rust doc comments + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | [**Vec**](String.md) | Status values that need to be considered for filter | [required] | +**r#type** | Option<[**Vec**](String.md)> | Make sure that Rust keywords like type work as query params | | + +### Return type + +[**Vec**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## find_pets_by_tags + +> Vec find_pets_by_tags(tags) +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**tags** | [**Vec**](String.md) | Tags to filter by | [required] | + +### Return type + +[**Vec**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_pet_by_id + +> models::Pet get_pet_by_id(pet_id) +Find pet by ID + +Returns a single pet + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet to return | [required] | + +### Return type + +[**models::Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## pets_explode_post + +> Vec pets_explode_post(page_explode) +List all pets + +Returns a list of pets + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | + +### Return type + +[**Vec**](Pet.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## pets_post + +> Vec pets_post(page) +List all pets + +Returns a list of pets + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**page** | Option<[**Page**](Page.md)> | The page number | | + +### Return type + +[**Vec**](Pet.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_pet + +> models::Pet update_pet(pet) +Update an existing pet + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet** | [**Pet**](Pet.md) | Pet object that needs to be added to the store | [required] | + +### Return type + +[**models::Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/json, application/xml +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_pet_with_form + +> update_pet_with_form(pet_id, name, status) +Updates a pet in the store with form data + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet that needs to be updated | [required] | +**name** | Option<**String**> | Updated name of the pet | | +**status** | Option<**String**> | Updated status of the pet | | + +### Return type + + (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: application/x-www-form-urlencoded +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## upload_file + +> models::ApiResponse upload_file(pet_id, additional_metadata, file) +uploads an image + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**pet_id** | **i64** | ID of pet to update | [required] | +**additional_metadata** | Option<**String**> | Additional data to pass to server | | +**file** | Option<**std::path::PathBuf**> | file to upload | | + +### Return type + +[**models::ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/PropertyTest.md new file mode 100644 index 000000000000..e8261d40d3a3 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/PropertyTest.md @@ -0,0 +1,11 @@ +# PropertyTest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | Option<**uuid::Uuid**> | | [optional] + +[[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-no-chrono/docs/Ref.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Ref.md new file mode 100644 index 000000000000..04f9d0aa55a2 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Ref.md @@ -0,0 +1,11 @@ +# Ref + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dummy** | Option<**String**> | | [optional] + +[[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-no-chrono/docs/Return.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Return.md new file mode 100644 index 000000000000..04710a019db2 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Return.md @@ -0,0 +1,13 @@ +# Return + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#match** | Option<**i32**> | | [optional] +**r#async** | Option<**bool**> | | [optional] +**param_super** | Option<**bool**> | | [optional] + +[[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-no-chrono/docs/StoreApi.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/StoreApi.md new file mode 100644 index 000000000000..02a9ccabdb8a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/StoreApi.md @@ -0,0 +1,129 @@ +# \StoreApi + +All URIs are relative to *http://localhost/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + + +## delete_order + +> delete_order(order_id) +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **String** | ID of the order that needs to be deleted | [required] | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_inventory + +> std::collections::HashMap get_inventory() +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +**std::collections::HashMap** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_order_by_id + +> models::Order get_order_by_id(order_id) +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order_id** | **i64** | ID of pet that needs to be fetched | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## place_order + +> models::Order place_order(order) +Place an order for a pet + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**order** | [**Order**](Order.md) | order placed for purchasing the pet | [required] | + +### Return type + +[**models::Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Tag.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Tag.md new file mode 100644 index 000000000000..7bf71ab0e9d8 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Tag.md @@ -0,0 +1,12 @@ +# Tag + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**name** | Option<**String**> | | [optional] + +[[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-no-chrono/docs/TestAllOfWithMultiMetadataOnly.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TestAllOfWithMultiMetadataOnly.md new file mode 100644 index 000000000000..dd00f5fe3f70 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TestAllOfWithMultiMetadataOnly.md @@ -0,0 +1,12 @@ +# TestAllOfWithMultiMetadataOnly + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**foo** | Option<**Vec**> | This is a test for allOf with metadata only fields | [optional] + +[[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-no-chrono/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TestingApi.md new file mode 100644 index 000000000000..a14a8e0c081d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TestingApi.md @@ -0,0 +1,151 @@ +# \TestingApi + +All URIs are relative to *http://localhost/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) +[**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors +[**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema + + + +## tests_all_of_with_one_model_get + +> String tests_all_of_with_one_model_get(person) +Test for allOf with a single option. (One of the issues in #20500) + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**person** | [**Person**](Person.md) | | [required] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## tests_file_response_get + +> std::path::PathBuf tests_file_response_get() +Returns an image file + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**std::path::PathBuf**](std::path::PathBuf.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: image/jpeg + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## tests_type_testing_get + +> models::TypeTesting tests_type_testing_get() +Route to test the TypeTesting schema + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**models::TypeTesting**](TypeTesting.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TypeTesting.md new file mode 100644 index 000000000000..4134b7a23531 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/TypeTesting.md @@ -0,0 +1,20 @@ +# TypeTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**int32** | **i32** | | +**int64** | **i64** | | +**float** | **f32** | | +**double** | **f64** | | +**string** | **String** | | +**boolean** | **bool** | | +**uuid** | **uuid::Uuid** | | +**bytes** | **String** | | +**nullable_bytes** | Option<**String**> | | [optional] +**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-no-chrono/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/UniqueItemArrayTesting.md new file mode 100644 index 000000000000..32b20fdb80c9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/UniqueItemArrayTesting.md @@ -0,0 +1,11 @@ +# UniqueItemArrayTesting + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | + +[[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-no-chrono/docs/User.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/User.md new file mode 100644 index 000000000000..19d813622ede --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/User.md @@ -0,0 +1,18 @@ +# User + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**username** | **String** | | +**first_name** | Option<**String**> | | [optional] +**last_name** | **String** | | +**email** | Option<**String**> | | [optional] +**password** | Option<**String**> | | [optional] +**phone** | Option<**String**> | | [optional] +**user_status** | Option<**i32**> | User Status | [optional] + +[[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-no-chrono/docs/UserApi.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/UserApi.md new file mode 100644 index 000000000000..7930130a923b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/UserApi.md @@ -0,0 +1,255 @@ +# \UserApi + +All URIs are relative to *http://localhost/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + + +## create_user + +> create_user(user) +Create user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user** | [**User**](User.md) | Created user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_users_with_array_input + +> create_users_with_array_input(user) +Creates list of users with given input array + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user** | [**Vec**](User.md) | List of user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_users_with_list_input + +> create_users_with_list_input(user) +Creates list of users with given input array + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**user** | [**Vec**](User.md) | List of user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## delete_user + +> delete_user(username) +Delete user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be deleted | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_user_by_name + +> models::User get_user_by_name(username) +Get user by user name + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] | + +### Return type + +[**models::User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## login_user + +> String login_user(username, password) +Logs user into the system + + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | The user name for login | [required] | +**password** | **String** | The password for login in clear text | [required] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/xml, application/json, text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## logout_user + +> logout_user() +Logs out current logged in user session + + + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_user + +> update_user(username, user) +Updated user + +This can only be done by the logged in user. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**username** | **String** | name that need to be deleted | [required] | +**user** | [**User**](User.md) | Updated user object | [required] | + +### Return type + + (empty response body) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Vehicle.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Vehicle.md new file mode 100644 index 000000000000..1a4b48467fd6 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/Vehicle.md @@ -0,0 +1,12 @@ +# Vehicle + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | | +**speed** | **f64** | | + +[[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-no-chrono/docs/WithInnerOneOf.md b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/WithInnerOneOf.md new file mode 100644 index 000000000000..93c6ada0387f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/docs/WithInnerOneOf.md @@ -0,0 +1,11 @@ +# WithInnerOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | Option<[**models::Order**](Order.md)> | | [optional] + +[[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-no-chrono/git_push.sh b/samples/client/petstore/rust/reqwest/petstore-no-chrono/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs new file mode 100644 index 000000000000..8295708bc87a --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::blocking::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "http://localhost/v2".to_owned(), + user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), + client: reqwest::blocking::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/fake_api.rs new file mode 100644 index 000000000000..ca15d542e25b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/fake_api.rs @@ -0,0 +1,68 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`test_nullable_required_param`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestNullableRequiredParamError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + + +/// +pub fn test_nullable_required_param(configuration: &configuration::Configuration, user_name: &str, dummy_required_nullable_param: Option<&str>, any_type: &str, uppercase: Option<&str>, content: Option<&str>) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_user_name = user_name; + let p_header_dummy_required_nullable_param = dummy_required_nullable_param; + let p_query_any_type = any_type; + let p_header_uppercase = uppercase; + let p_query_content = content; + + let uri_str = format!("{}/fake/user/{user_name}", configuration.base_path, user_name=crate::apis::urlencode(p_path_user_name)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_content { + req_builder = req_builder.query(&[("content", ¶m_value.to_string())]); + } + req_builder = req_builder.query(&[("anyType", &p_query_any_type.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + match p_header_dummy_required_nullable_param { + Some(param_value) => { req_builder = req_builder.header("dummy_required_nullable_param", param_value.to_string()); }, + None => { req_builder = req_builder.header("dummy_required_nullable_param", ""); }, + } + if let Some(param_value) = p_header_uppercase { + req_builder = req_builder.header("UPPERCASE", param_value.to_string()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/mod.rs new file mode 100644 index 000000000000..a075c8414431 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/mod.rs @@ -0,0 +1,120 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + }, + serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +/// Internal use only +/// A content type supported by this client. +#[allow(dead_code)] +enum ContentType { + Json, + Text, + Unsupported(String) +} + +impl From<&str> for ContentType { + fn from(content_type: &str) -> Self { + if content_type.starts_with("application") && content_type.contains("json") { + return Self::Json; + } else if content_type.starts_with("text/plain") { + return Self::Text; + } else { + return Self::Unsupported(content_type.to_string()); + } + } +} + +pub mod fake_api; +pub mod pet_api; +pub mod store_api; +pub mod testing_api; +pub mod user_api; + +pub mod configuration; diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/pet_api.rs new file mode 100644 index 000000000000..b10a2ad35fc0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/pet_api.rs @@ -0,0 +1,525 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`add_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddPetError { + Status405(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeletePetError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`find_pets_by_status`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByStatusError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`find_pets_by_tags`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum FindPetsByTagsError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_pet_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetPetByIdError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`pets_explode_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PetsExplodePostError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`pets_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PetsPostError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_pet`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetError { + Status400(), + Status404(), + Status405(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_pet_with_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdatePetWithFormError { + Status405(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`upload_file`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadFileError { + UnknownValue(serde_json::Value), +} + + +/// This is the description for the addPet operation +pub fn add_pet(configuration: &configuration::Configuration, pet: models::Pet) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_pet = pet; + + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_pet); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn delete_pet(configuration: &configuration::Configuration, pet_id: i64, api_key: Option<&str>) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_pet_id = pet_id; + let p_header_api_key = api_key; + + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=p_path_pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(param_value) = p_header_api_key { + req_builder = req_builder.header("api_key", param_value.to_string()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Multiple status values can be provided with comma separated strings. This is also a multi-line description to test rust doc comments +pub fn find_pets_by_status(configuration: &configuration::Configuration, status: Vec, r#type: Option>) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_status = status; + let p_query_type = r#type; + + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + req_builder = match "csv" { + "multi" => req_builder.query(&p_query_status.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("status", &p_query_status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + }; + if let Some(ref param_value) = p_query_type { + req_builder = match "csv" { + "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("type".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("type", ¶m_value.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + }; + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. +#[deprecated] +pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_tags = tags; + + let uri_str = format!("{}/pet/findByTags", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + req_builder = match "csv" { + "multi" => req_builder.query(&p_query_tags.into_iter().map(|p| ("tags".to_owned(), p.to_string())).collect::>()), + _ => req_builder.query(&[("tags", &p_query_tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + }; + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Returns a single pet +pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_pet_id = pet_id; + + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=p_path_pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Returns a list of pets +pub fn pets_explode_post(configuration: &configuration::Configuration, page_explode: Option) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_page_explode = page_explode; + + let uri_str = format!("{}/pets/explode", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref param_value) = p_query_page_explode { + req_builder = req_builder.query(¶m_value); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Returns a list of pets +pub fn pets_post(configuration: &configuration::Configuration, page: Option) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_page = page; + + let uri_str = format!("{}/pets", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref param_value) = p_query_page { + req_builder = req_builder.query(&[("page", &serde_json::to_string(param_value)?)]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn update_pet(configuration: &configuration::Configuration, pet: models::Pet) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_pet = pet; + + let uri_str = format!("{}/pet", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + req_builder = req_builder.json(&p_body_pet); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn update_pet_with_form(configuration: &configuration::Configuration, pet_id: i64, name: Option<&str>, status: Option<&str>) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_pet_id = pet_id; + let p_form_name = name; + let p_form_status = status; + + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=p_path_pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + let mut multipart_form_params = std::collections::HashMap::new(); + if let Some(param_value) = p_form_name { + multipart_form_params.insert("name", param_value.to_string()); + } + if let Some(param_value) = p_form_status { + multipart_form_params.insert("status", param_value.to_string()); + } + req_builder = req_builder.form(&multipart_form_params); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, additional_metadata: Option<&str>, file: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_pet_id = pet_id; + let p_form_additional_metadata = additional_metadata; + let p_form_file = file; + + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=p_path_pet_id); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref token) = configuration.oauth_access_token { + req_builder = req_builder.bearer_auth(token.to_owned()); + }; + let mut multipart_form = reqwest::blocking::multipart::Form::new(); + if let Some(param_value) = p_form_additional_metadata { + multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); + } + if let Some(ref param_value) = p_form_file { + multipart_form = multipart_form.file("file", param_value)?; + } + req_builder = req_builder.multipart(multipart_form); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiResponse`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiResponse`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/store_api.rs new file mode 100644 index 000000000000..478804744901 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/store_api.rs @@ -0,0 +1,195 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`delete_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOrderError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_inventory`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInventoryError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_order_by_id`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOrderByIdError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`place_order`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PlaceOrderError { + Status400(), + UnknownValue(serde_json::Value), +} + + +/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +pub fn delete_order(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_order_id = order_id; + + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(p_path_order_id)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Returns a map of status codes to quantities +pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result, Error> { + + let uri_str = format!("{}/store/inventory", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, i32>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, i32>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions +pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i64) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_order_id = order_id; + + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=p_path_order_id); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn place_order(configuration: &configuration::Configuration, order: models::Order) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_order = order; + + let uri_str = format!("{}/store/order", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_order); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/testing_api.rs new file mode 100644 index 000000000000..f286b427dac9 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/testing_api.rs @@ -0,0 +1,225 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`tests_all_of_with_one_model_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsAllOfWithOneModelGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_file_response_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsFileResponseGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_type_testing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsTypeTestingGetError { + UnknownValue(serde_json::Value), +} + + +pub fn tests_all_of_with_one_model_get(configuration: &configuration::Configuration, person: models::Person) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_person = person; + + let uri_str = format!("{}/tests/allOfWithOneModel", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_person); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub fn tests_file_response_get(configuration: &configuration::Configuration, ) -> Result> { + + let uri_str = format!("{}/tests/fileResponse", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(resp) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Tests inline enum query parameters +pub fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, status: Option<&str>) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_status = status; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, model_with_inline_enum: models::ModelWithInlineEnum) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_model_with_inline_enum = model_with_inline_enum; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModelWithInlineEnum`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModelWithInlineEnum`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { + + let uri_str = format!("{}/tests/typeTesting", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TypeTesting`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TypeTesting`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/user_api.rs new file mode 100644 index 000000000000..78bff1645121 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/user_api.rs @@ -0,0 +1,369 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`create_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUserError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_users_with_array_input`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithArrayInputError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_users_with_list_input`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateUsersWithListInputError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`delete_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteUserError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_user_by_name`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetUserByNameError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`login_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LoginUserError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`logout_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum LogoutUserError { + DefaultResponse(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_user`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateUserError { + Status400(), + Status404(), + UnknownValue(serde_json::Value), +} + + +/// This can only be done by the logged in user. +pub fn create_user(configuration: &configuration::Configuration, user: models::User) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_user = user; + + let uri_str = format!("{}/user", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + req_builder = req_builder.json(&p_body_user); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn create_users_with_array_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_user = user; + + let uri_str = format!("{}/user/createWithArray", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + req_builder = req_builder.json(&p_body_user); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn create_users_with_list_input(configuration: &configuration::Configuration, user: Vec) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_user = user; + + let uri_str = format!("{}/user/createWithList", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + req_builder = req_builder.json(&p_body_user); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// This can only be done by the logged in user. +pub fn delete_user(configuration: &configuration::Configuration, username: &str) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_username = username; + + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(p_path_username)); + let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn get_user_by_name(configuration: &configuration::Configuration, username: &str) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_username = username; + + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(p_path_username)); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn login_user(configuration: &configuration::Configuration, username: &str, password: &str) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_username = username; + let p_query_password = password; + + let uri_str = format!("{}/user/login", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + req_builder = req_builder.query(&[("username", &p_query_username.to_string())]); + req_builder = req_builder.query(&[("password", &p_query_password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Ok(content), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// +pub fn logout_user(configuration: &configuration::Configuration, ) -> Result<(), Error> { + + let uri_str = format!("{}/user/logout", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// This can only be done by the logged in user. +pub fn update_user(configuration: &configuration::Configuration, username: &str, user: models::User) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_path_username = username; + let p_body_user = user; + + let uri_str = format!("{}/user/{username}", configuration.base_path, username=crate::apis::urlencode(p_path_username)); + let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let value = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.header("api_key", value); + }; + req_builder = req_builder.json(&p_body_user); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/lib.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/lib.rs new file mode 100644 index 000000000000..e1520628d762 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde_repr; +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/action_container.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/action_container.rs new file mode 100644 index 000000000000..0dd27c0e5c84 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/action_container.rs @@ -0,0 +1,27 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ActionContainer { + #[serde(rename = "action")] + pub action: models::Baz, +} + +impl ActionContainer { + pub fn new(action: models::Baz) -> ActionContainer { + ActionContainer { + action, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/any_type_test.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/any_type_test.rs new file mode 100644 index 000000000000..8a873991fd42 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/any_type_test.rs @@ -0,0 +1,27 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct AnyTypeTest { + #[serde(rename = "foo", deserialize_with = "Option::deserialize")] + pub foo: Option, +} + +impl AnyTypeTest { + pub fn new(foo: Option) -> AnyTypeTest { + AnyTypeTest { + foo, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/api_response.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/api_response.rs new file mode 100644 index 000000000000..0a60da0f4773 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/api_response.rs @@ -0,0 +1,35 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ApiResponse : Describes the result of uploading an image resource +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ApiResponse { + #[serde(rename = "code", skip_serializing_if = "Option::is_none")] + pub code: Option, + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub r#type: Option, + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl ApiResponse { + /// Describes the result of uploading an image resource + pub fn new() -> ApiResponse { + ApiResponse { + code: None, + r#type: None, + message: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/array_item_ref_test.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/array_item_ref_test.rs new file mode 100644 index 000000000000..4ac1e8a2fe9c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/array_item_ref_test.rs @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ArrayItemRefTest : Test handling of object reference in arrays +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ArrayItemRefTest { + #[serde(rename = "list_with_array_ref")] + pub list_with_array_ref: Vec>, + #[serde(rename = "list_with_object_ref")] + pub list_with_object_ref: Vec>, +} + +impl ArrayItemRefTest { + /// Test handling of object reference in arrays + pub fn new(list_with_array_ref: Vec>, list_with_object_ref: Vec>) -> ArrayItemRefTest { + ArrayItemRefTest { + list_with_array_ref, + list_with_object_ref, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/baz.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/baz.rs new file mode 100644 index 000000000000..17b42c0bd4f0 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/baz.rs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Baz : Test handling of empty variants +/// Test handling of empty variants +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Baz { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "")] + Empty, + +} + +impl std::fmt::Display for Baz { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::A => write!(f, "A"), + Self::B => write!(f, "B"), + Self::Empty => write!(f, ""), + } + } +} + +impl Default for Baz { + fn default() -> Baz { + Self::A + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/category.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/category.rs new file mode 100644 index 000000000000..9ecf89d354d6 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/category.rs @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Category : A category for a pet +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Category { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl Category { + /// A category for a pet + pub fn new() -> Category { + Category { + id: None, + name: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/enum_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/enum_array_testing.rs new file mode 100644 index 000000000000..2ac40c307756 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/enum_array_testing.rs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// EnumArrayTesting : Test of enum array +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct EnumArrayTesting { + #[serde(rename = "required_enums")] + pub required_enums: Vec, +} + +impl EnumArrayTesting { + /// Test of enum array + pub fn new(required_enums: Vec) -> EnumArrayTesting { + EnumArrayTesting { + required_enums, + } + } +} +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum RequiredEnums { + #[serde(rename = "A")] + A, + #[serde(rename = "B")] + B, + #[serde(rename = "C")] + C, +} + +impl Default for RequiredEnums { + fn default() -> RequiredEnums { + Self::A + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/mod.rs new file mode 100644 index 000000000000..5f33e4b9f1ed --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/mod.rs @@ -0,0 +1,89 @@ +pub mod action_container; +pub use self::action_container::ActionContainer; +pub mod any_type_test; +pub use self::any_type_test::AnyTypeTest; +pub mod api_response; +pub use self::api_response::ApiResponse; +pub mod array_item_ref_test; +pub use self::array_item_ref_test::ArrayItemRefTest; +pub mod baz; +pub use self::baz::Baz; +pub mod category; +pub use self::category::Category; +pub mod enum_array_testing; +pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; +pub mod nullable_array; +pub use self::nullable_array::NullableArray; +pub mod numeric_enum_testing; +pub use self::numeric_enum_testing::NumericEnumTesting; +pub mod optional_testing; +pub use self::optional_testing::OptionalTesting; +pub mod order; +pub use self::order::Order; +pub mod page; +pub use self::page::Page; +pub mod person; +pub use self::person::Person; +pub mod pet; +pub use self::pet::Pet; +pub mod property_test; +pub use self::property_test::PropertyTest; +pub mod model_ref; +pub use self::model_ref::Ref; +pub mod model_return; +pub use self::model_return::Return; +pub mod tag; +pub use self::tag::Tag; +pub mod test_all_of_with_multi_metadata_only; +pub use self::test_all_of_with_multi_metadata_only::TestAllOfWithMultiMetadataOnly; +pub mod type_testing; +pub use self::type_testing::TypeTesting; +pub mod unique_item_array_testing; +pub use self::unique_item_array_testing::UniqueItemArrayTesting; +pub mod user; +pub use self::user::User; +pub mod vehicle; +pub use self::vehicle::Vehicle; +pub mod with_inner_one_of; +pub use self::with_inner_one_of::WithInnerOneOf; +use serde::{Deserialize, Deserializer, Serializer}; +use serde_with::{de::DeserializeAsWrap, ser::SerializeAsWrap, DeserializeAs, SerializeAs}; +use std::marker::PhantomData; + +pub(crate) struct DoubleOption(PhantomData); + +impl SerializeAs>> for DoubleOption +where + TAs: SerializeAs, +{ + fn serialize_as(values: &Option>, serializer: S) -> Result + where + S: Serializer, + { + match values { + None => serializer.serialize_unit(), + Some(None) => serializer.serialize_none(), + Some(Some(v)) => serializer.serialize_some(&SerializeAsWrap::::new(v)), + } + } +} + +impl<'de, T, TAs> DeserializeAs<'de, Option>> for DoubleOption +where + TAs: DeserializeAs<'de, T>, + T: std::fmt::Debug, +{ + fn deserialize_as(deserializer: D) -> Result>, D::Error> + where + D: Deserializer<'de>, + { + Ok(Some( + DeserializeAsWrap::, Option>::deserialize(deserializer)? + .into_inner(), + )) + } +} diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_ref.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_ref.rs new file mode 100644 index 000000000000..9862cb1a48ef --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_ref.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Ref : using reserved word as model name +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Ref { + #[serde(rename = "dummy", skip_serializing_if = "Option::is_none")] + pub dummy: Option, +} + +impl Ref { + /// using reserved word as model name + pub fn new() -> Ref { + Ref { + dummy: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_return.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_return.rs new file mode 100644 index 000000000000..07d9268e6e68 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_return.rs @@ -0,0 +1,35 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Return : Test using keywords +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Return { + #[serde(rename = "match", skip_serializing_if = "Option::is_none")] + pub r#match: Option, + #[serde(rename = "async", skip_serializing_if = "Option::is_none")] + pub r#async: Option, + #[serde(rename = "super", skip_serializing_if = "Option::is_none")] + pub param_super: Option, +} + +impl Return { + /// Test using keywords + pub fn new() -> Return { + Return { + r#match: None, + r#async: None, + param_super: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/nullable_array.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/nullable_array.rs new file mode 100644 index 000000000000..a155ea1176ab --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/nullable_array.rs @@ -0,0 +1,36 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct NullableArray { + #[serde(rename = "array_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub array_nullable: Option>>, + #[serde(rename = "just_array", skip_serializing_if = "Option::is_none")] + pub just_array: Option>, + #[serde(rename = "nullable_string", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub nullable_string: Option>, + #[serde(rename = "just_string", skip_serializing_if = "Option::is_none")] + pub just_string: Option, +} + +impl NullableArray { + pub fn new() -> NullableArray { + NullableArray { + array_nullable: None, + just_array: None, + nullable_string: None, + just_string: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/numeric_enum_testing.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/numeric_enum_testing.rs new file mode 100644 index 000000000000..e3681aa61778 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/numeric_enum_testing.rs @@ -0,0 +1,42 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use serde_repr::{Serialize_repr,Deserialize_repr}; +/// NumericEnumTesting : testing that numeric enums are converted correctly +/// testing that numeric enums are converted correctly +#[repr(i64)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr)] +pub enum NumericEnumTesting { + Variant0 = 0, + Variant1 = 1, + Variant2 = 2, + Variant3 = 3, + +} + +impl std::fmt::Display for NumericEnumTesting { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", match self { + Self::Variant0 => "0", + Self::Variant1 => "1", + Self::Variant2 => "2", + Self::Variant3 => "3", + }) + } +} +impl Default for NumericEnumTesting { + fn default() -> NumericEnumTesting { + Self::Variant0 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/optional_testing.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/optional_testing.rs new file mode 100644 index 000000000000..72e5a009a623 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/optional_testing.rs @@ -0,0 +1,38 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// OptionalTesting : Test handling of optional and nullable fields +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OptionalTesting { + #[serde(rename = "optional_nonnull", skip_serializing_if = "Option::is_none")] + pub optional_nonnull: Option, + #[serde(rename = "required_nonnull")] + pub required_nonnull: String, + #[serde(rename = "optional_nullable", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub optional_nullable: Option>, + #[serde(rename = "required_nullable", deserialize_with = "Option::deserialize")] + pub required_nullable: Option, +} + +impl OptionalTesting { + /// Test handling of optional and nullable fields + pub fn new(required_nonnull: String, required_nullable: Option) -> OptionalTesting { + OptionalTesting { + optional_nonnull: None, + required_nonnull, + optional_nullable: None, + required_nullable, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/order.rs new file mode 100644 index 000000000000..a66e7dbb5689 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/order.rs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Order : An order for a pets from the pet store +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Order { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "petId", skip_serializing_if = "Option::is_none")] + pub pet_id: Option, + #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] + pub quantity: Option, + #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] + pub ship_date: Option, + /// Order Status + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "complete", skip_serializing_if = "Option::is_none")] + pub complete: Option, +} + +impl Order { + /// An order for a pets from the pet store + pub fn new() -> Order { + Order { + id: None, + pet_id: None, + quantity: None, + ship_date: None, + status: None, + complete: None, + } + } +} +/// Order Status +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "placed")] + Placed, + #[serde(rename = "approved")] + Approved, + #[serde(rename = "delivered")] + shipped, +} + +impl Default for Status { + fn default() -> Status { + Self::Placed + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/page.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/page.rs new file mode 100644 index 000000000000..3e007e7eb38c --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/page.rs @@ -0,0 +1,30 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Page { + #[serde(rename = "page", skip_serializing_if = "Option::is_none")] + pub page: Option, + #[serde(rename = "perPage", skip_serializing_if = "Option::is_none")] + pub per_page: Option, +} + +impl Page { + pub fn new() -> Page { + Page { + page: None, + per_page: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/person.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/person.rs new file mode 100644 index 000000000000..67c2da45b5cb --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/person.rs @@ -0,0 +1,30 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Person { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "name")] + pub name: String, +} + +impl Person { + pub fn new(r#type: String, name: String) -> Person { + Person { + r#type, + name, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/pet.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/pet.rs new file mode 100644 index 000000000000..785fb5390bed --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/pet.rs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Pet : A pet for sale in the pet store +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Pet { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "category", skip_serializing_if = "Option::is_none")] + pub category: Option>, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "photoUrls")] + pub photo_urls: Vec, + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, + /// pet status in the store + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, +} + +impl Pet { + /// A pet for sale in the pet store + pub fn new(name: String, photo_urls: Vec) -> Pet { + Pet { + id: None, + category: None, + name, + photo_urls, + tags: None, + status: None, + } + } +} +/// pet status in the store +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "available")] + Available, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "sold")] + Sold, +} + +impl Default for Status { + fn default() -> Status { + Self::Available + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/property_test.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/property_test.rs new file mode 100644 index 000000000000..c98e7c762b58 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/property_test.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PropertyTest : A model to test various formats, e.g. UUID +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PropertyTest { + #[serde(rename = "uuid", skip_serializing_if = "Option::is_none")] + pub uuid: Option, +} + +impl PropertyTest { + /// A model to test various formats, e.g. UUID + pub fn new() -> PropertyTest { + PropertyTest { + uuid: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/tag.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/tag.rs new file mode 100644 index 000000000000..8fe4eebd723b --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/tag.rs @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Tag : A tag for a pet +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Tag { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, +} + +impl Tag { + /// A tag for a pet + pub fn new() -> Tag { + Tag { + id: None, + name: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/test_all_of_with_multi_metadata_only.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/test_all_of_with_multi_metadata_only.rs new file mode 100644 index 000000000000..5d7ad9147d3f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/test_all_of_with_multi_metadata_only.rs @@ -0,0 +1,31 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TestAllOfWithMultiMetadataOnly { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// This is a test for allOf with metadata only fields + #[serde(rename = "foo", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub foo: Option>>, +} + +impl TestAllOfWithMultiMetadataOnly { + pub fn new() -> TestAllOfWithMultiMetadataOnly { + TestAllOfWithMultiMetadataOnly { + id: None, + foo: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/type_testing.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/type_testing.rs new file mode 100644 index 000000000000..1c406069fece --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/type_testing.rs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +use serde_with::serde_as; + +/// TypeTesting : Test handling of different field data types +#[serde_as] +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TypeTesting { + #[serde(rename = "int32")] + pub int32: i32, + #[serde(rename = "int64")] + pub int64: i64, + #[serde(rename = "float")] + pub float: f32, + #[serde(rename = "double")] + pub double: f64, + #[serde(rename = "string")] + pub string: String, + #[serde(rename = "boolean")] + pub boolean: bool, + #[serde(rename = "uuid")] + pub uuid: uuid::Uuid, + #[serde_as(as = "serde_with::base64::Base64")] + #[serde(rename = "bytes")] + pub bytes: Vec, + #[serde_as(as = "super::DoubleOption")] + #[serde(rename = "nullableBytes", default, skip_serializing_if = "Option::is_none")] + pub nullable_bytes: Option>>, + #[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, decimal: String) -> TypeTesting { + TypeTesting { + int32, + int64, + float, + double, + string, + boolean, + uuid, + bytes, + nullable_bytes: None, + decimal, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/unique_item_array_testing.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/unique_item_array_testing.rs new file mode 100644 index 000000000000..bddcf9d5c195 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/unique_item_array_testing.rs @@ -0,0 +1,46 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// UniqueItemArrayTesting : Test handling of enum array with unique items +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UniqueItemArrayTesting { + /// Helper object for the unique item array test + #[serde(rename = "unique_item_array")] + pub unique_item_array: std::collections::HashSet, +} + +impl UniqueItemArrayTesting { + /// Test handling of enum array with unique items + pub fn new(unique_item_array: std::collections::HashSet) -> UniqueItemArrayTesting { + UniqueItemArrayTesting { + unique_item_array, + } + } +} +/// Helper object for the unique item array test +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum UniqueItemArray { + #[serde(rename = "unique_item_1")] + UniqueItem1, + #[serde(rename = "unique_item_2")] + UniqueItem2, + #[serde(rename = "unique_item_3")] + UniqueItem3, +} + +impl Default for UniqueItemArray { + fn default() -> UniqueItemArray { + Self::UniqueItem1 + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/user.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/user.rs new file mode 100644 index 000000000000..c88c469a4ebe --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/user.rs @@ -0,0 +1,51 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// User : A User who is purchasing from the pet store +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "username")] + pub username: String, + #[serde(rename = "firstName", skip_serializing_if = "Option::is_none")] + pub first_name: Option, + #[serde(rename = "lastName")] + pub last_name: String, + #[serde(rename = "email", skip_serializing_if = "Option::is_none")] + pub email: Option, + #[serde(rename = "password", skip_serializing_if = "Option::is_none")] + pub password: Option, + #[serde(rename = "phone", skip_serializing_if = "Option::is_none")] + pub phone: Option, + /// User Status + #[serde(rename = "userStatus", skip_serializing_if = "Option::is_none")] + pub user_status: Option, +} + +impl User { + /// A User who is purchasing from the pet store + pub fn new(username: String, last_name: String) -> User { + User { + id: None, + username, + first_name: None, + last_name, + email: None, + password: None, + phone: None, + user_status: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/vehicle.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/vehicle.rs new file mode 100644 index 000000000000..45cf0f72115f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/vehicle.rs @@ -0,0 +1,30 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Vehicle { + #[serde(rename = "type")] + pub r#type: String, + #[serde(rename = "speed")] + pub speed: f64, +} + +impl Vehicle { + pub fn new(r#type: String, speed: f64) -> Vehicle { + Vehicle { + r#type, + speed, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/with_inner_one_of.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/with_inner_one_of.rs new file mode 100644 index 000000000000..a00c4e1c375e --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/models/with_inner_one_of.rs @@ -0,0 +1,27 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct WithInnerOneOf { + #[serde(rename = "foo", skip_serializing_if = "Option::is_none")] + pub foo: Option>, +} + +impl WithInnerOneOf { + pub fn new() -> WithInnerOneOf { + WithInnerOneOf { + foo: None, + } + } +} + From 1f0442b869acfc8a7070a195c01417f5b1d168db Mon Sep 17 00:00:00 2001 From: Richard Paterson Date: Mon, 6 Apr 2026 12:53:40 +0200 Subject: [PATCH 4/7] Docs update --- docs/generators/rust.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/generators/rust.md b/docs/generators/rust.md index 8eaf83e474c9..ab70382f29f5 100644 --- a/docs/generators/rust.md +++ b/docs/generators/rust.md @@ -34,6 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option| |false| |topLevelApiClient|Creates a top level `Api` trait and `ApiClient` struct that contain all Apis. This option is for 'reqwest-trait' library only| |false| |useBonBuilder|Use the bon crate for building parameter types. This option is for the 'reqwest-trait' library only| |false| +|useChrono|If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::NaiveDateTime` for `date-time`)| |true| |useSerdePathToError|If set, use the serde_path_to_error library to enhance serde error messages. This option is for 'reqwest' and 'reqwest-trait' library only| |false| |useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false| |withAWSV4Signature|whether to include AWS v4 signature support| |false| From 1fcc34840244505a5cd3d6f5efde53589051a9f6 Mon Sep 17 00:00:00 2001 From: Richard Paterson Date: Mon, 6 Apr 2026 14:03:57 +0200 Subject: [PATCH 5/7] Review change from `chrono::NaiveDateTime` to `chrono::DateTime `` --- .../openapitools/codegen/languages/RustClientCodegen.java | 6 +++--- samples/client/petstore/rust/hyper/petstore/docs/Order.md | 2 +- .../client/petstore/rust/hyper/petstore/src/models/order.rs | 2 +- samples/client/petstore/rust/hyper0x/petstore/docs/Order.md | 2 +- .../petstore/rust/hyper0x/petstore/src/models/order.rs | 2 +- .../petstore/rust/reqwest-trait/petstore/docs/Order.md | 2 +- .../rust/reqwest-trait/petstore/src/models/order.rs | 2 +- .../rust/reqwest/petstore-async-middleware/docs/Order.md | 2 +- .../reqwest/petstore-async-middleware/src/models/order.rs | 2 +- .../rust/reqwest/petstore-async-tokensource/docs/Order.md | 2 +- .../reqwest/petstore-async-tokensource/src/models/order.rs | 2 +- .../petstore/rust/reqwest/petstore-async/docs/Order.md | 2 +- .../rust/reqwest/petstore-async/src/models/order.rs | 2 +- .../petstore/rust/reqwest/petstore-avoid-box/docs/Order.md | 2 +- .../rust/reqwest/petstore-avoid-box/src/models/order.rs | 2 +- .../rust/reqwest/petstore-awsv4signature/docs/Order.md | 2 +- .../reqwest/petstore-awsv4signature/src/models/order.rs | 2 +- .../reqwest/petstore-model-name-prefix/docs/FooOrder.md | 2 +- .../petstore-model-name-prefix/src/models/foo_order.rs | 2 +- .../rust/reqwest/petstore-serde-path-to-error/docs/Order.md | 2 +- .../petstore-serde-path-to-error/src/models/order.rs | 2 +- samples/client/petstore/rust/reqwest/petstore/docs/Order.md | 2 +- .../petstore/rust/reqwest/petstore/src/models/order.rs | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) 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 865de031e16f..f1efbcc5d816 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 @@ -190,7 +190,7 @@ public RustClientCodegen() { typeMapping.put("URI", "String"); // Temporarily set the default to chrono. Then when `processOpts` is called it will update to not use chrono if specified typeMapping.put("date", "chrono::NaiveDate"); - typeMapping.put("DateTime", "chrono::NaiveDateTime"); + typeMapping.put("DateTime", "chrono::DateTime"); typeMapping.put("password", "String"); typeMapping.put("decimal", "String"); @@ -224,7 +224,7 @@ public RustClientCodegen() { .defaultValue(Boolean.FALSE.toString())); cliOptions.add(new CliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); - cliOptions.add(new CliOption(USE_CHRONO, "If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::NaiveDateTime` for `date-time`)", SchemaTypeUtil.BOOLEAN_TYPE) + cliOptions.add(new CliOption(USE_CHRONO, "If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::DateTime>` for `date-time`)", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); @@ -1003,7 +1003,7 @@ private void setUseChrono(boolean useChrono) { this.useChrono = useChrono; if(isUseChrono()){ typeMapping.put("date", "chrono::NaiveDate"); - typeMapping.put("DateTime", "chrono::NaiveDateTime"); + typeMapping.put("DateTime", "chrono::DateTime"); }else{ typeMapping.put("date", "String"); typeMapping.put("DateTime", "String"); diff --git a/samples/client/petstore/rust/hyper/petstore/docs/Order.md b/samples/client/petstore/rust/hyper/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs index b59834fdbb88..eac7b5106a28 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md index 889f5ce43459..1e53d01c7c9a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs index d552b9bff2af..0cdd1c37d703 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs @@ -21,7 +21,7 @@ pub struct FooOrder { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs index b59834fdbb88..eac7b5106a28 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs index b59834fdbb88..eac7b5106a28 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, From 967d43f79c453ff3402d2b6751b9a73a8c54262b Mon Sep 17 00:00:00 2001 From: Richard Paterson Date: Mon, 6 Apr 2026 14:03:57 +0200 Subject: [PATCH 6/7] Review change from `chrono::NaiveDateTime` to `chrono::DateTime` --- .../openapitools/codegen/languages/RustClientCodegen.java | 6 +++--- samples/client/petstore/rust/hyper/petstore/docs/Order.md | 2 +- .../client/petstore/rust/hyper/petstore/src/models/order.rs | 2 +- samples/client/petstore/rust/hyper0x/petstore/docs/Order.md | 2 +- .../petstore/rust/hyper0x/petstore/src/models/order.rs | 2 +- .../petstore/rust/reqwest-trait/petstore/docs/Order.md | 2 +- .../rust/reqwest-trait/petstore/src/models/order.rs | 2 +- .../rust/reqwest/petstore-async-middleware/docs/Order.md | 2 +- .../reqwest/petstore-async-middleware/src/models/order.rs | 2 +- .../rust/reqwest/petstore-async-tokensource/docs/Order.md | 2 +- .../reqwest/petstore-async-tokensource/src/models/order.rs | 2 +- .../petstore/rust/reqwest/petstore-async/docs/Order.md | 2 +- .../rust/reqwest/petstore-async/src/models/order.rs | 2 +- .../petstore/rust/reqwest/petstore-avoid-box/docs/Order.md | 2 +- .../rust/reqwest/petstore-avoid-box/src/models/order.rs | 2 +- .../rust/reqwest/petstore-awsv4signature/docs/Order.md | 2 +- .../reqwest/petstore-awsv4signature/src/models/order.rs | 2 +- .../reqwest/petstore-model-name-prefix/docs/FooOrder.md | 2 +- .../petstore-model-name-prefix/src/models/foo_order.rs | 2 +- .../rust/reqwest/petstore-serde-path-to-error/docs/Order.md | 2 +- .../petstore-serde-path-to-error/src/models/order.rs | 2 +- samples/client/petstore/rust/reqwest/petstore/docs/Order.md | 2 +- .../petstore/rust/reqwest/petstore/src/models/order.rs | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) 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 865de031e16f..f1efbcc5d816 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 @@ -190,7 +190,7 @@ public RustClientCodegen() { typeMapping.put("URI", "String"); // Temporarily set the default to chrono. Then when `processOpts` is called it will update to not use chrono if specified typeMapping.put("date", "chrono::NaiveDate"); - typeMapping.put("DateTime", "chrono::NaiveDateTime"); + typeMapping.put("DateTime", "chrono::DateTime"); typeMapping.put("password", "String"); typeMapping.put("decimal", "String"); @@ -224,7 +224,7 @@ public RustClientCodegen() { .defaultValue(Boolean.FALSE.toString())); cliOptions.add(new CliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); - cliOptions.add(new CliOption(USE_CHRONO, "If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::NaiveDateTime` for `date-time`)", SchemaTypeUtil.BOOLEAN_TYPE) + cliOptions.add(new CliOption(USE_CHRONO, "If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::DateTime>` for `date-time`)", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE) .defaultValue(Boolean.FALSE.toString())); @@ -1003,7 +1003,7 @@ private void setUseChrono(boolean useChrono) { this.useChrono = useChrono; if(isUseChrono()){ typeMapping.put("date", "chrono::NaiveDate"); - typeMapping.put("DateTime", "chrono::NaiveDateTime"); + typeMapping.put("DateTime", "chrono::DateTime"); }else{ typeMapping.put("date", "String"); typeMapping.put("DateTime", "String"); diff --git a/samples/client/petstore/rust/hyper/petstore/docs/Order.md b/samples/client/petstore/rust/hyper/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs index b59834fdbb88..eac7b5106a28 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs index ab725449d756..88fd8af084bb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md index 889f5ce43459..1e53d01c7c9a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs index d552b9bff2af..0cdd1c37d703 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_order.rs @@ -21,7 +21,7 @@ pub struct FooOrder { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs index b59834fdbb88..eac7b5106a28 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md index 600305eb0033..f0e1f78c5385 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | Option<**i64**> | | [optional] **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] -**ship_date** | Option<**chrono::NaiveDateTime**> | | [optional] +**ship_date** | Option<**chrono::DateTime**> | | [optional] **status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs index b59834fdbb88..eac7b5106a28 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/order.rs @@ -21,7 +21,7 @@ pub struct Order { #[serde(rename = "quantity", skip_serializing_if = "Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate", skip_serializing_if = "Option::is_none")] - pub ship_date: Option, + pub ship_date: Option>, /// Order Status #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, From fb34e91891e6e475a68cd310613be9dfdf3a1617 Mon Sep 17 00:00:00 2001 From: Richard Paterson Date: Mon, 6 Apr 2026 14:04:32 +0200 Subject: [PATCH 7/7] Doc update --- docs/generators/rust.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/generators/rust.md b/docs/generators/rust.md index ab70382f29f5..f26c7a2cd3dc 100644 --- a/docs/generators/rust.md +++ b/docs/generators/rust.md @@ -34,7 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option| |false| |topLevelApiClient|Creates a top level `Api` trait and `ApiClient` struct that contain all Apis. This option is for 'reqwest-trait' library only| |false| |useBonBuilder|Use the bon crate for building parameter types. This option is for the 'reqwest-trait' library only| |false| -|useChrono|If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::NaiveDateTime` for `date-time`)| |true| +|useChrono|If set, use chrono to represent date time objects (`chrono::NaiveDate` for `date` and `chrono::DateTime<chrono::FixedOffset>>` for `date-time`)| |true| |useSerdePathToError|If set, use the serde_path_to_error library to enhance serde error messages. This option is for 'reqwest' and 'reqwest-trait' library only| |false| |useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |false| |withAWSV4Signature|whether to include AWS v4 signature support| |false|