Skip to content

Commit b1e10c7

Browse files
[Rust Server] Regenerate samples.
1 parent fa5ef80 commit b1e10c7

File tree

108 files changed

+4587
-2499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+4587
-2499
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[build]
2+
rustflags = [
3+
"-W", "missing_docs", # detects missing documentation for public members
4+
5+
"-W", "trivial_casts", # detects trivial casts which could be removed
6+
7+
"-W", "trivial_numeric_casts", # detects trivial casts of numeric types which could be removed
8+
9+
# unsafe is used in `TokioIo` bridging code copied from `hyper`.
10+
# "-W", "unsafe_code", # usage of `unsafe` code
11+
12+
"-W", "unused_qualifications", # detects unnecessarily qualified names
13+
14+
"-W", "unused_extern_crates", # extern crates that are never used
15+
16+
"-W", "unused_import_braces", # unnecessary braces around an imported item
17+
18+
"-D", "warnings", # all warnings should be denied
19+
]

samples/server/petstore/rust-server/output/multipart-v3/.openapi-generator/FILES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.cargo/config
1+
.cargo/config.toml
22
.gitignore
33
Cargo.toml
44
README.md
@@ -16,6 +16,7 @@ examples/server-key.pem
1616
examples/server/main.rs
1717
examples/server/server.rs
1818
examples/server/server_auth.rs
19+
examples/server/tokio_io.rs
1920
src/auth.rs
2021
src/client/mod.rs
2122
src/context.rs

samples/server/petstore/rust-server/output/multipart-v3/Cargo.toml

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ client = [
1313
"mime_0_2",
1414
"multipart", "multipart/client", "swagger/multipart_form",
1515
"hyper_0_10", "mime_multipart", "swagger/multipart_related",
16-
"hyper", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
16+
"hyper", "hyper-util/http1", "hyper-util/http2", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
1717
]
1818
server = [
1919
"mime_0_2",
@@ -22,71 +22,76 @@ server = [
2222
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
2323
]
2424
cli = [
25-
"anyhow", "clap-verbosity-flag", "simple_logger", "structopt", "tokio"
25+
"anyhow", "clap", "clap-verbosity-flag", "simple_logger", "tokio"
2626
]
2727
conversion = ["frunk", "frunk_derives", "frunk_core", "frunk-enum-core", "frunk-enum-derive"]
2828

2929
[target.'cfg(any(target_os = "macos", target_os = "windows", target_os = "ios"))'.dependencies]
3030
native-tls = { version = "0.2", optional = true }
31-
hyper-tls = { version = "0.5", optional = true }
31+
hyper-tls = { version = "0.6", optional = true }
3232

3333
[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dependencies]
34-
hyper-openssl = { version = "0.9", optional = true }
35-
openssl = {version = "0.10", optional = true }
34+
hyper-openssl = { version = "0.10", optional = true }
35+
openssl = { version = "0.10", optional = true }
3636

3737
[dependencies]
3838
# Common
39-
async-trait = "0.1.24"
39+
async-trait = "0.1.88"
4040
chrono = { version = "0.4", features = ["serde"] }
4141
futures = "0.3"
42-
swagger = { version = "6.1", features = ["serdejson", "server", "client", "tls", "tcp"] }
43-
log = "0.4.0"
42+
swagger = { version = "7.0.0-rc2", features = ["serdejson", "server", "client", "tls"] }
43+
log = "0.4.27"
4444
mime = "0.3"
4545

4646
serde = { version = "1.0", features = ["derive"] }
4747
serde_json = "1.0"
48-
validator = { version = "0.16", features = ["derive"] }
48+
validator = { version = "0.20", features = ["derive"] }
4949

5050
# Crates included if required by the API definition
5151
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
5252
multipart = { version = "0.16", default-features = false, optional = true }
5353

5454
# Common between server and client features
55-
hyper = {version = "0.14", features = ["full"], optional = true}
56-
mime_multipart = {version = "0.5", optional = true}
57-
hyper_0_10 = {package = "hyper", version = "0.10", default-features = false, optional=true}
58-
serde_ignored = {version = "0.1.1", optional = true}
59-
url = {version = "2.1", optional = true}
55+
bytes = "1.10.1"
56+
http-body-util = "0.1.3"
57+
hyper = { version = "1.6", features = ["full"], optional = true }
58+
hyper-util = { version = "0.1.12", features = ["service"] }
59+
mime_multipart = { version = "0.5", optional = true }
60+
hyper_0_10 = {package = "hyper", version = "0.10", default-features = false, optional=true }
61+
serde_ignored = { version = "0.1.12", optional = true }
62+
url = { version = "2.5", optional = true }
6063

6164
# Client-specific
65+
tower-service = "0.3.3"
6266

6367
# Server, and client callback-specific
64-
lazy_static = { version = "1.4", optional = true }
65-
percent-encoding = {version = "2.1.0", optional = true}
66-
regex = {version = "1.3", optional = true}
68+
lazy_static = { version = "1.5", optional = true }
69+
percent-encoding = { version = "2.3.1", optional = true }
70+
regex = { version = "1.11", optional = true }
6771

6872
# CLI-specific
6973
anyhow = { version = "1", optional = true }
70-
clap-verbosity-flag = { version = "0.3", optional = true }
71-
simple_logger = { version = "2.0", features = ["stderr"], optional = true }
72-
structopt = { version = "0.3", optional = true }
73-
tokio = { version = "0.2", features = ["rt-threaded", "macros", "stream"], optional = true }
74+
clap-verbosity-flag = { version = "3.0", optional = true }
75+
simple_logger = { version = "5.0", features = ["stderr"], optional = true }
76+
tokio = { version = "1.45", features = ["rt-multi-thread", "macros"], optional = true }
7477

7578
# Conversion
76-
frunk = { version = "0.4.0", optional = true }
77-
frunk_derives = { version = "0.4.0", optional = true }
78-
frunk_core = { version = "0.4.0", optional = true }
79+
frunk = { version = "0.4.3", optional = true }
80+
frunk_derives = { version = "0.4.3", optional = true }
81+
frunk_core = { version = "0.4.3", optional = true }
7982
frunk-enum-derive = { version = "0.3.0", optional = true }
8083
frunk-enum-core = { version = "0.3.0", optional = true }
8184

8285
# Bearer authentication
83-
jsonwebtoken = { version = "9.3.0", optional = false }
86+
jsonwebtoken = { version = "9.3.1", optional = false }
8487

8588
[dev-dependencies]
86-
clap = "2.25"
89+
always_send = "0.1.1"
90+
clap = "4.5"
8791
env_logger = "0.11"
88-
tokio = { version = "1.14", features = ["full"] }
92+
tokio = { version = "1.45", features = ["full"] }
8993
native-tls = "0.2"
94+
pin-project = "1.1.10"
9095

9196
[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dev-dependencies]
9297
tokio-openssl = "0.6"

samples/server/petstore/rust-server/output/multipart-v3/bin/cli.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! CLI tool driving the API client
22
use anyhow::{anyhow, Context, Result};
3+
use clap::Parser;
34
use log::{debug, info};
45
// models may be unused if all inputs are primitive types
56
#[allow(unused_imports)]
@@ -10,7 +11,6 @@ use multipart_v3::{
1011
MultipleIdenticalMimeTypesPostResponse,
1112
};
1213
use simple_logger::SimpleLogger;
13-
use structopt::StructOpt;
1414
use swagger::{AuthData, ContextBuilder, EmptyContext, Push, XSpanIdString};
1515

1616
type ClientContext = swagger::make_context_ty!(
@@ -20,65 +20,65 @@ type ClientContext = swagger::make_context_ty!(
2020
XSpanIdString
2121
);
2222

23-
#[derive(StructOpt, Debug)]
24-
#[structopt(
23+
#[derive(Parser, Debug)]
24+
#[clap(
2525
name = "Multipart OpenAPI V3 Rust Server Test",
2626
version = "1.0.7",
2727
about = "CLI access to Multipart OpenAPI V3 Rust Server Test"
2828
)]
2929
struct Cli {
30-
#[structopt(subcommand)]
30+
#[clap(subcommand)]
3131
operation: Operation,
3232

3333
/// Address or hostname of the server hosting this API, including optional port
34-
#[structopt(short = "a", long, default_value = "http://localhost")]
34+
#[clap(short = 'a', long, default_value = "http://localhost")]
3535
server_address: String,
3636

3737
/// Path to the client private key if using client-side TLS authentication
3838
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
39-
#[structopt(long, requires_all(&["client-certificate", "server-certificate"]))]
39+
#[clap(long, requires_all(&["client-certificate", "server-certificate"]))]
4040
client_key: Option<String>,
4141

4242
/// Path to the client's public certificate associated with the private key
4343
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
44-
#[structopt(long, requires_all(&["client-key", "server-certificate"]))]
44+
#[clap(long, requires_all(&["client-key", "server-certificate"]))]
4545
client_certificate: Option<String>,
4646

4747
/// Path to CA certificate used to authenticate the server
4848
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
49-
#[structopt(long)]
49+
#[clap(long)]
5050
server_certificate: Option<String>,
5151

5252
/// If set, write output to file instead of stdout
53-
#[structopt(short, long)]
53+
#[clap(short, long)]
5454
output_file: Option<String>,
5555

56-
#[structopt(flatten)]
56+
#[command(flatten)]
5757
verbosity: clap_verbosity_flag::Verbosity,
5858
}
5959

60-
#[derive(StructOpt, Debug)]
60+
#[derive(Parser, Debug)]
6161
enum Operation {
6262
MultipartRelatedRequestPost {
63-
#[structopt(parse(try_from_str = parse_json))]
63+
#[clap(value_parser = parse_json::<swagger::ByteArray>)]
6464
required_binary_field: swagger::ByteArray,
65-
#[structopt(parse(try_from_str = parse_json))]
65+
#[clap(value_parser = parse_json::<models::MultipartRequestObjectField>)]
6666
object_field: Option<models::MultipartRequestObjectField>,
67-
#[structopt(parse(try_from_str = parse_json))]
67+
#[clap(value_parser = parse_json::<swagger::ByteArray>)]
6868
optional_binary_field: Option<swagger::ByteArray>,
6969
},
7070
MultipartRequestPost {
7171
string_field: String,
72-
#[structopt(parse(try_from_str = parse_json))]
72+
#[clap(value_parser = parse_json::<swagger::ByteArray>)]
7373
binary_field: swagger::ByteArray,
7474
optional_string_field: Option<String>,
75-
#[structopt(parse(try_from_str = parse_json))]
75+
#[clap(value_parser = parse_json::<models::MultipartRequestObjectField>)]
7676
object_field: Option<models::MultipartRequestObjectField>,
7777
},
7878
MultipleIdenticalMimeTypesPost {
79-
#[structopt(parse(try_from_str = parse_json))]
79+
#[clap(value_parser = parse_json::<swagger::ByteArray>)]
8080
binary1: Option<swagger::ByteArray>,
81-
#[structopt(parse(try_from_str = parse_json))]
81+
#[clap(value_parser = parse_json::<swagger::ByteArray>)]
8282
binary2: Option<swagger::ByteArray>,
8383
},
8484
}
@@ -118,7 +118,7 @@ fn create_client(args: &Cli, context: ClientContext) -> Result<Box<dyn ApiNoCont
118118

119119
#[tokio::main]
120120
async fn main() -> Result<()> {
121-
let args = Cli::from_args();
121+
let args = Cli::parse();
122122
if let Some(log_level) = args.verbosity.log_level() {
123123
SimpleLogger::new().with_level(log_level.to_level_filter()).init()?;
124124
}
@@ -210,6 +210,6 @@ async fn main() -> Result<()> {
210210

211211
// May be unused if all inputs are primitive types
212212
#[allow(dead_code)]
213-
fn parse_json<'a, T: serde::de::Deserialize<'a>>(json_string: &'a str) -> Result<T> {
213+
fn parse_json<T: serde::de::DeserializeOwned>(json_string: &str) -> Result<T> {
214214
serde_json::from_str(json_string).map_err(|err| anyhow!("Error parsing input: {}", err))
215215
}

samples/server/petstore/rust-server/output/multipart-v3/examples/client/main.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use multipart_v3::{Api, ApiNoContext, Claims, Client, ContextWrapperExt, models,
99
MultipartRequestPostResponse,
1010
MultipleIdenticalMimeTypesPostResponse,
1111
};
12-
use clap::{App, Arg};
12+
use clap::{Command, Arg};
1313

1414
// NOTE: Set environment variable RUST_LOG to the name of the executable (or "cargo run") to activate console logging for all loglevels.
1515
// See https://docs.rs/env_logger/latest/env_logger/ for more details
@@ -32,27 +32,25 @@ use client_auth::build_token;
3232
fn main() {
3333
env_logger::init();
3434

35-
let matches = App::new("client")
36-
.arg(Arg::with_name("operation")
35+
let matches = Command::new("client")
36+
.arg(Arg::new("operation")
3737
.help("Sets the operation to run")
38-
.possible_values(&[
38+
.value_parser([
3939
"MultipartRelatedRequestPost",
4040
"MultipartRequestPost",
4141
"MultipleIdenticalMimeTypesPost",
4242
])
4343
.required(true)
4444
.index(1))
45-
.arg(Arg::with_name("https")
45+
.arg(Arg::new("https")
4646
.long("https")
4747
.help("Whether to use HTTPS or not"))
48-
.arg(Arg::with_name("host")
48+
.arg(Arg::new("host")
4949
.long("host")
50-
.takes_value(true)
5150
.default_value("localhost")
5251
.help("Hostname to contact"))
53-
.arg(Arg::with_name("port")
52+
.arg(Arg::new("port")
5453
.long("port")
55-
.takes_value(true)
5654
.default_value("8080")
5755
.help("Port to contact"))
5856
.get_matches();
@@ -76,22 +74,22 @@ fn main() {
7674
b"secret").unwrap();
7775

7876
let auth_data = if !auth_token.is_empty() {
79-
Some(AuthData::Bearer(swagger::auth::Bearer { token: auth_token}))
77+
Some(AuthData::Bearer(auth_token))
8078
} else {
8179
// No Bearer-token available, so return None
8280
None
8381
};
8482

85-
let is_https = matches.is_present("https");
83+
let is_https = matches.contains_id("https");
8684
let base_url = format!("{}://{}:{}",
8785
if is_https { "https" } else { "http" },
88-
matches.value_of("host").unwrap(),
89-
matches.value_of("port").unwrap());
86+
matches.get_one::<String>("host").unwrap(),
87+
matches.get_one::<u16>("port").unwrap());
9088

9189
let context: ClientContext =
9290
swagger::make_context!(ContextBuilder, EmptyContext, auth_data, XSpanIdString::default());
9391

94-
let mut client : Box<dyn ApiNoContext<ClientContext>> = if matches.is_present("https") {
92+
let mut client : Box<dyn ApiNoContext<ClientContext>> = if is_https {
9593
// Using Simple HTTPS
9694
let client = Box::new(Client::try_new_https(&base_url)
9795
.expect("Failed to create HTTPS client"));
@@ -106,7 +104,7 @@ fn main() {
106104

107105
let mut rt = tokio::runtime::Runtime::new().unwrap();
108106

109-
match matches.value_of("operation") {
107+
match matches.get_one::<String>("operation") {
110108
Some("MultipartRelatedRequestPost") => {
111109
let result = rt.block_on(client.multipart_related_request_post(
112110
swagger::ByteArray(Vec::from("BINARY_DATA_HERE")),

samples/server/petstore/rust-server/output/multipart-v3/examples/server/main.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33

44
#![allow(missing_docs)]
55

6-
7-
use clap::{App, Arg};
6+
use clap::{Arg, Command};
87

98
mod server;
109
mod server_auth;
11-
10+
mod tokio_io;
1211

1312
/// Create custom server, wire it to the autogenerated router,
1413
/// and pass it to the web server.
1514
#[tokio::main]
1615
async fn main() {
1716
env_logger::init();
1817

19-
let matches = App::new("server")
20-
.arg(Arg::with_name("https")
21-
.long("https")
22-
.help("Whether to use HTTPS or not"))
18+
let matches = Command::new("server")
19+
.arg(
20+
Arg::new("https")
21+
.long("https")
22+
.help("Whether to use HTTPS or not"),
23+
)
2324
.get_matches();
2425

2526
let addr = "127.0.0.1:8080";
2627

27-
server::create(addr, matches.is_present("https")).await;
28+
server::create(addr, matches.contains_id("https")).await;
2829
}

0 commit comments

Comments
 (0)