-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
[Rust] Configurable default features from reqwest dependency #22041
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
[Rust] Configurable default features from reqwest dependency #22041
Conversation
This change removes the default features (specifically native-tls) from the reqwest dependency in the Rust client generator. This allows users to explicitly choose their TLS backend without automatically including openssl-sys as a transitive dependency. Users can now explicitly enable TLS backends using feature flags: - native-tls - rustls-tls - default-tls Fixes OpenAPITools#21933
f019545
to
137a660
Compare
@frol @farcaller @richardwhiuk @paladinzh @jacob-pro @dsteeley for review |
LGTM, thanks for raising as a follow-up to the previous PR. |
what about adding an option to let users choose? |
An option to set a Cargo feature? Sounds a bit complicated to me. But if that's a show stopper for 7.16 then yes, I'll do it. |
the next release v7.17.0 allows breaking changes with fallback so if you can add an option with native-tls (or empty) as the default, then we can include this enhancement in the upcoming release |
thanks again for putting together the following to highlight it's a breaking change: Breaking Change Notice
[dependencies]
my_api_client = { version = "1.0", features = ["native-tls"] }
# or
my_api_client = { version = "1.0", features = ["rustls-tls"] } is it correct to say that users need to manually update the auto-generated Cargo.toml in order to consume the API client? |
There was a typo in the codeblock so I fixed it.
No. There will be 0 required modification of the generated What the codeblock shows is that the feature is enabled by the user's crate that will use the generated SDK.
OK so IMHO to be backward compatible the default value for this option will have to be the current default feature, so |
…e default This change adds a new generator option `reqwestDefaultFeatures` that allows users to configure the default Cargo features for the reqwest dependency. The option accepts: - An array of strings in YAML config: reqwestDefaultFeatures: ["native-tls"] - A comma-separated string via CLI: --additional-properties=reqwestDefaultFeatures=native-tls - An empty value for no defaults: reqwestDefaultFeatures: [] Default value: ["native-tls"] (maintains backward compatibility) This addresses the feedback in OpenAPITools#21933 to make the change opt-in rather than breaking existing users. Users can now: - Keep the current behavior (default) - Opt-out: reqwestDefaultFeatures: [] - Use alternative TLS: reqwestDefaultFeatures: ["rustls-tls"] - Combine features: reqwestDefaultFeatures: ["native-tls", "cookies"] Fixes OpenAPITools#21933
I've updated the PR to address the feedback. Here's what changed: Changes MadeAdded a new generator option Key Points✅ Backward Compatible: Default value is UsageYAML configuration: additionalProperties:
reqwestDefaultFeatures: [] # No default features
# or
reqwestDefaultFeatures: ["rustls-tls"] # Use rustls
# or
reqwestDefaultFeatures: ["native-tls", "cookies"] # Multiple features CLI: --additional-properties=reqwestDefaultFeatures= # Empty for no defaults
--additional-properties=reqwestDefaultFeatures=rustls-tls # Single feature
--additional-properties=reqwestDefaultFeatures=rustls-tls,cookies # Multiple (comma-separated) Implementation Details
All builds, samples, and documentation have been regenerated successfully. |
nice 👍 thanks for the contribution |
PR checklist
master
Description
This PR removes the default features (specifically
native-tls
) from the reqwest dependency in the Rust client generator. This allows users to explicitly choose their TLS backend without automatically includingopenssl-sys
as a transitive dependency.Problem
As described in #21933, the current implementation sets
default = ["native-tls"]
, which:openssl-sys
as a transitive dependencySolution
Cargo.mustache
template to setdefault = []
instead ofdefault = ["native-tls"]
Available TLS Backends
After this change, users can explicitly select:
native-tls
: Uses platform-native TLS (OpenSSL on Linux, SChannel on Windows, Security Framework on macOS)rustls-tls
: Uses rustls, a pure Rust TLS implementationdefault-tls
: Uses reqwest's default choiceBreaking Change Notice
Cargo.toml
:This is not a breaking change (cf #22041 (comment))
Testing
Cargo.toml
files have empty default features listFixes #21933