From 4ee336a9daad9bd411da3bb560c12ad54bed6666 Mon Sep 17 00:00:00 2001 From: Taufik Rama Date: Tue, 19 Jul 2022 10:03:53 +0700 Subject: [PATCH] [Rust] Changed 'UUID' handling into 'uuid' crate (#12895) * [Rust] Changed 'UUID' handling into 'uuid' crate * [Rust] updated 'samples/' --- .../org/openapitools/codegen/languages/RustClientCodegen.java | 2 +- .../openapi-generator/src/main/resources/rust/Cargo.mustache | 1 + modules/openapi-generator/src/main/resources/rust/request.rs | 1 + samples/client/petstore/rust/hyper/petstore/Cargo.toml | 1 + samples/client/petstore/rust/hyper/petstore/src/apis/request.rs | 1 + samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml | 1 + .../petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml | 1 + samples/client/petstore/rust/reqwest/petstore/Cargo.toml | 1 + 8 files changed, 8 insertions(+), 1 deletion(-) 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 5726d0c46ff1..21a96617b0f4 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 @@ -166,7 +166,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("double", "f64"); typeMapping.put("boolean", "bool"); typeMapping.put("string", "String"); - typeMapping.put("UUID", "String"); + typeMapping.put("UUID", "uuid::Uuid"); typeMapping.put("URI", "String"); 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 4488f0f21265..24f536b5581d 100644 --- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache +++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache @@ -9,6 +9,7 @@ serde = "^1.0" serde_derive = "^1.0" serde_json = "^1.0" url = "^2.2" +uuid = { version = "^1.0", features = ["serde"] } {{#hyper}} hyper = { version = "~0.14", features = ["full"] } hyper-tls = "~0.5" diff --git a/modules/openapi-generator/src/main/resources/rust/request.rs b/modules/openapi-generator/src/main/resources/rust/request.rs index d53037850212..b516ccb0f9ad 100644 --- a/modules/openapi-generator/src/main/resources/rust/request.rs +++ b/modules/openapi-generator/src/main/resources/rust/request.rs @@ -50,6 +50,7 @@ pub(crate) struct Request { serialized_body: Option, } +#[allow(dead_code)] impl Request { pub fn new(method: hyper::Method, path: String) -> Self { Request { diff --git a/samples/client/petstore/rust/hyper/petstore/Cargo.toml b/samples/client/petstore/rust/hyper/petstore/Cargo.toml index 443de5b186a9..daaad97bf864 100644 --- a/samples/client/petstore/rust/hyper/petstore/Cargo.toml +++ b/samples/client/petstore/rust/hyper/petstore/Cargo.toml @@ -9,6 +9,7 @@ serde = "^1.0" serde_derive = "^1.0" serde_json = "^1.0" url = "^2.2" +uuid = { version = "^1.0", features = ["serde"] } hyper = { version = "~0.14", features = ["full"] } hyper-tls = "~0.5" http = "~0.2" diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs index d53037850212..b516ccb0f9ad 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/request.rs @@ -50,6 +50,7 @@ pub(crate) struct Request { serialized_body: Option, } +#[allow(dead_code)] impl Request { pub fn new(method: hyper::Method, path: String) -> Self { Request { diff --git a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml index 5631ecde03b6..5902f2f89001 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml @@ -9,6 +9,7 @@ serde = "^1.0" serde_derive = "^1.0" serde_json = "^1.0" url = "^2.2" +uuid = { version = "^1.0", features = ["serde"] } [dependencies.reqwest] version = "^0.11" features = ["json", "multipart"] diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml index e56ce2cafcf6..bdc29cf694ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml @@ -9,6 +9,7 @@ serde = "^1.0" serde_derive = "^1.0" serde_json = "^1.0" url = "^2.2" +uuid = { version = "^1.0", features = ["serde"] } reqwest = "~0.9" aws-sigv4 = "0.3.0" http = "0.2.5" diff --git a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml index 4e6f624c352b..a815e8f2f2f0 100644 --- a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml @@ -9,6 +9,7 @@ serde = "^1.0" serde_derive = "^1.0" serde_json = "^1.0" url = "^2.2" +uuid = { version = "^1.0", features = ["serde"] } reqwest = "~0.9" [dev-dependencies]