Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Rust edition to 2021 and a few crates #18608

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "{{.}}"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
{{/licenseInfo}}
edition = "2018"
edition = "2021"
{{#publishRustRegistry}}
publish = ["{{.}}"]
{{/publishRustRegistry}}
Expand Down
24 changes: 11 additions & 13 deletions modules/openapi-generator/src/main/resources/rust/Cargo.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "{{.}}"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
{{/licenseInfo}}
edition = "2018"
edition = "2021"
{{#publishRustRegistry}}
publish = ["{{.}}"]
{{/publishRustRegistry}}
Expand All @@ -32,14 +32,13 @@ homepage = "{{.}}
{{/homePageUrl}}

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde = { version = "^1.0", features = ["derive"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using serde with the derive feature instead of serde_derive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: serde_derive hasn't been required in years at this point :) Even the serde docs show using the derive feature: https://serde.rs/derive.html#using-derive

{{#serdeWith}}
serde_with = { version = "^3", default-features = false, features = ["base64", "std", "macros"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
{{/serdeWith}}
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde", "v4"] }
url = "^2.5"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuid = { version = "^1.8", features = ["serde", "v4"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{#hyper}}
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
Expand All @@ -54,16 +53,15 @@ secrecy = "0.8.0"
{{/withAWSV4Signature}}
{{#reqwest}}
{{^supportAsync}}
[dependencies.reqwest]
version = "^0.11"
features = ["json", "blocking", "multipart"]
reqwest = { version = "^0.12", features = ["json", "blocking", "multipart"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{#supportMiddleware}}
reqwest-middleware = { version = "^0.3", features = ["json", "blocking", "multipart"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reqwest-middleware requires the same features as reqwest

{{/supportMiddleware}}
{{/supportAsync}}
{{#supportAsync}}
reqwest = { version = "^0.12", features = ["json", "multipart"] }
{{#supportMiddleware}}
reqwest-middleware = "0.2.0"
reqwest-middleware = { version = "^0.3", features = ["json", "multipart"] }
{{/supportMiddleware}}
[dependencies.reqwest]
version = "^0.11"
features = ["json", "multipart"]
{{/supportAsync}}
{{/reqwest}}
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ impl From<(hyper::StatusCode, hyper::body::Body)> for Error {

impl From<http::Error> for Error {
fn from(e: http::Error) -> Self {
return Error::Http(e)
Error::Http(e)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to return

}
}

impl From<hyper::Error> for Error {
fn from(e: hyper::Error) -> Self {
return Error::Hyper(e)
Error::Hyper(e)
}
}

impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
return Error::Serde(e)
Error::Serde(e)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_json;
extern crate url;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{>partial_header}}
use crate::models;
use serde::{Deserialize, Serialize};
{{#models}}
{{#model}}
{{^isEnum}}{{#vendorExtensions.x-rust-has-byte-array}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{>partial_header}}

use reqwest;

use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};

Expand Down Expand Up @@ -174,7 +174,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/bodyParams}}
{{/hasBodyParam}}
{{^hasBodyParam}}
&"",
"",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy to the rescue :)

{{/hasBodyParam}}
) {
Ok(new_headers) => new_headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl AWSv4Key {
value.to_str().expect("header value should be a string").to_string()));
}
}
return Ok(additional_headers);
Ok(additional_headers)
}
}
{{/withAWSV4Signature}}
Expand Down
1 change: 1 addition & 0 deletions samples/client/others/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ["hyper/*", "reqwest/*", "reqwest-regression-16119"]
resolver = "2"
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2018"
edition = "2021"

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde", "v4"] }
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
http = "~0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ impl From<(hyper::StatusCode, hyper::body::Body)> for Error {

impl From<http::Error> for Error {
fn from(e: http::Error) -> Self {
return Error::Http(e)
Error::Http(e)
}
}

impl From<hyper::Error> for Error {
fn from(e: hyper::Error) -> Self {
return Error::Hyper(e)
Error::Hyper(e)
}
}

impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
return Error::Serde(e)
Error::Serde(e)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_json;
extern crate url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
Expand Down
9 changes: 4 additions & 5 deletions samples/client/others/rust/hyper/composed-oneof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2018"
edition = "2021"

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde", "v4"] }
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
http = "~0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ impl From<(hyper::StatusCode, hyper::body::Body)> for Error {

impl From<http::Error> for Error {
fn from(e: http::Error) -> Self {
return Error::Http(e)
Error::Http(e)
}
}

impl From<hyper::Error> for Error {
fn from(e: hyper::Error) -> Self {
return Error::Hyper(e)
Error::Hyper(e)
}
}

impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
return Error::Serde(e)
Error::Serde(e)
}
}

Expand Down
3 changes: 0 additions & 3 deletions samples/client/others/rust/hyper/composed-oneof/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_json;
extern crate url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjA {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjB {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjC {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjD {
Expand Down
9 changes: 4 additions & 5 deletions samples/client/others/rust/hyper/emptyObject/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ authors = ["OpenAPI Generator team and contributors"]
description = "Ensure rust supports empty objects using serde::Value"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2018"
edition = "2021"

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde", "v4"] }
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
http = "~0.2"
Expand Down
6 changes: 3 additions & 3 deletions samples/client/others/rust/hyper/emptyObject/src/apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ impl From<(hyper::StatusCode, hyper::body::Body)> for Error {

impl From<http::Error> for Error {
fn from(e: http::Error) -> Self {
return Error::Http(e)
Error::Http(e)
}
}

impl From<hyper::Error> for Error {
fn from(e: hyper::Error) -> Self {
return Error::Hyper(e)
Error::Hyper(e)
}
}

impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
return Error::Serde(e)
Error::Serde(e)
}
}

Expand Down
3 changes: 0 additions & 3 deletions samples/client/others/rust/hyper/emptyObject/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_arguments)]

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_json;
extern crate url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct EmptyObject {
Expand Down
9 changes: 4 additions & 5 deletions samples/client/others/rust/hyper/oneOf-array-map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ authors = ["OpenAPI Generator team and contributors"]
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
# Override this license by providing a License Object in the OpenAPI.
license = "Unlicense"
edition = "2018"
edition = "2021"

[dependencies]
serde = "^1.0"
serde_derive = "^1.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
url = "^2.2"
uuid = { version = "^1.0", features = ["serde", "v4"] }
url = "^2.5"
uuid = { version = "^1.8", features = ["serde", "v4"] }
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
http = "~0.2"
Expand Down
Loading
Loading