OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.23k stars 6.43k forks source link

[REQ] Alternative TLS libraries for rust --library hyper #11197

Open wimax-grapl opened 2 years ago

wimax-grapl commented 2 years ago

Is your feature request related to a problem? Please describe.

Currently, upon running with

    --generator-name rust \
    --library hyper \

the generated client's Cargo.toml declares a dependency on hyper-tls. This, in turn, depends on the system tls lib (libssl-dev/openssl-dev). Instead, I'd prefer to be able to specify a dependency on alternative TLS libraries (specifically, hyper-rustls).

Describe the solution you'd like

Some new flag to --additional-properties/configOptions to select which TLS library to use for hyper. That flag would be documented on https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/rust.md

Describe alternatives you've considered

sed -i "s/hyper-tls.*/hyper-rustls = \"${HYPER_RUSTLS_VERSION}\"/g" "${CARGO_TOML}"

is what I'm trying right now; no promises that that even works 😭

Additional context

__

wimax-grapl commented 2 years ago

Actually, same could be asked for Reqwest, where I have a similarly bad replace to insert

features = ["json", "multipart", "rustls-tls"]
default_features = false
wing328 commented 2 years ago

@wimax-grapl thanks for the suggestion. For the time being, you can use customised templates (via -t in the CLI) to use a particular library.

Is hyper-rustls better than hyper-tls? If that's the case, we can simply replace it assuming the change is transparency to the end users (developers of the Rust client)

wimax-grapl commented 2 years ago

I don't think it'd qualify as transparent or necessarily better; my understanding is it's a choice between "Do you want to use the system's libssl libs, or a compiled-in-Rust statically-linked library?"