Files
openapi-generator/samples/server/petstore/rust-server/output/rust-server-test/Cargo.toml
Richard Whitehouse 79d11d7129 [Rust Server] Fix panic handling headers (#4877)
[Rust Server] Fix panic handling headers

If we have an API which has multiple auth types, we may panic. This is because
in Hyper 0.11, the following code will panic:

```
use hyper::header::{Authorization, Basic, Bearer, Headers};
fn main() {
    let mut headers = Headers::default();
    let basic = Basic { username: "richard".to_string(), password: None };
    headers.set::<Authorization<Basic>>(Authorization(basic));
    println!("Auth: {:?}", headers.get::<Authorization<Bearer>>());
}
```

as it mixes up an `Authorization<Basic>` and `Authorization<Bearer>` as both
have `Authorization:` as the header name.

This is fixed by using `swagger::SafeHeaders` added in
https://github.com/Metaswitch/swagger-rs/pull/90
2020-01-05 14:46:09 +00:00

66 lines
1.9 KiB
TOML

[package]
name = "rust-server-test"
version = "2.3.4"
authors = []
description = "This spec is for testing rust-server-specific things"
license = "Unlicense"
[features]
default = ["client", "server"]
client = ["serde_ignored", "hyper", "hyper-tls", "native-tls", "openssl", "tokio-core", "url"]
server = ["serde_ignored", "hyper", "hyper-tls", "native-tls", "openssl", "tokio-core", "tokio-proto", "tokio-tls", "regex", "percent-encoding", "url"]
conversion = ["frunk", "frunk_derives", "frunk_core", "frunk-enum-core", "frunk-enum-derive"]
[dependencies]
# Common
chrono = { version = "0.4", features = ["serde"] }
futures = "0.1"
swagger = "2.2"
lazy_static = "1.4"
log = "0.3.0"
mime = "0.2.6"
multipart = "0.13.3"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
# Crates included if required by the API definition
# Common between server and client features
hyper = {version = "0.11", optional = true}
hyper-tls = {version = "0.1.2", optional = true}
native-tls = {version = "0.1.4", optional = true}
openssl = {version = "0.9.14", optional = true}
serde_ignored = {version = "0.0.4", optional = true}
tokio-core = {version = "0.1.6", optional = true}
url = {version = "1.5", optional = true}
# Client-specific
# Server-specific
percent-encoding = {version = "1.0.0", optional = true}
regex = {version = "0.2", optional = true}
tokio-proto = {version = "0.1.1", optional = true}
tokio-tls = {version = "0.1.3", optional = true, features = ["tokio-proto"]}
# Other optional crates
frunk = { version = "0.3.0", optional = true }
frunk_derives = { version = "0.3.0", optional = true }
frunk_core = { version = "0.3.0", optional = true }
frunk-enum-derive = { version = "0.2.0", optional = true }
frunk-enum-core = { version = "0.2.0", optional = true }
[dev-dependencies]
clap = "2.25"
error-chain = "0.12"
uuid = {version = "0.5", features = ["serde", "v4"]}
[[example]]
name = "client"
required-features = ["client"]
[[example]]
name = "server"
required-features = ["server"]