Skip to content

Commit 421f423

Browse files
committed
Further tweaks to rust-server HTTPS feature flagging
1 parent 2d9a24a commit 421f423

24 files changed

Lines changed: 88 additions & 88 deletions

File tree

modules/openapi-generator/src/main/resources/rust-server/Cargo.mustache

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ homepage = "{{.}}"
3232
{{/homePageUrl}}
3333

3434
[features]
35-
default = ["client", "server"]
35+
default = ["client", "server", "client-tls"]
3636
client = [
3737
{{#apiUsesMultipartFormData}}
3838
"multipart", "multipart/client", "swagger/multipart_form",
@@ -172,13 +172,15 @@ clap = "4.5"
172172
env_logger = "0.11"
173173
tokio = { version = "1.49", features = ["full"] }
174174
native-tls = "0.2"
175-
openssl = "0.10"
176-
tokio-openssl = "0.6"
177175
pin-project = "1.1.10"
178176

179177
# Bearer authentication, used in examples
180178
jsonwebtoken = {version = "10.0.0", features = ["rust_crypto"]}
181179

180+
[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dev-dependencies]
181+
openssl = "0.10"
182+
tokio-openssl = "0.6"
183+
182184
[[example]]
183185
name = "client"
184186
required-features = ["client"]

modules/openapi-generator/src/main/resources/rust-server/README.mustache

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ The generated library has a few optional features that can be activated through
139139
* This defaults to disabled and allows JSON Schema validation of received data using `MakeService::set_validation` or `Service::set_validation`.
140140
* Note, enabling validation will have a performance penalty, especially if the API heavily uses regex based checks.
141141

142-
### Enabling HTTPS/TLS Support
142+
### HTTPS/TLS Support
143143

144-
By default, only HTTP support is included. To enable HTTPS, add the `client-tls` feature:
144+
HTTPS support is included by default. To disable it (for example, to reduce dependencies), you can:
145145

146146
```toml
147147
[dependencies]
148-
{{{packageName}}} = { version = "{{{packageVersion}}}", features = ["client-tls"] }
148+
{{{packageName}}} = { version = "{{{packageVersion}}}", default-features = false, features = ["client", "server"] }
149149
```
150150

151151
**For server with callbacks that need HTTPS:**
@@ -158,8 +158,6 @@ The TLS backend is automatically selected based on your target platform:
158158
- **macOS, Windows, iOS**: Uses `native-tls` (system TLS libraries)
159159
- **Linux, Unix, other platforms**: Uses `openssl`
160160

161-
This ensures the best compatibility and native integration on each platform.
162-
163161
See https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section for how to use features in your `Cargo.toml`.
164162

165163
## Documentation for API Endpoints

modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<C> Client<
241241
> where
242242
C: Clone + Send + Sync + 'static
243243
{
244-
/// Create a client with a TLS connection to the server using native-tls.
244+
/// Create a client with a TLS connection to the server.
245245
///
246246
/// # Arguments
247247
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"
@@ -255,7 +255,7 @@ impl<C> Client<
255255
Self::try_new_with_connector(base_path, Some("https"), https_connector)
256256
}
257257

258-
/// Create a client with a TLS connection to the server using OpenSSL.
258+
/// Create a client with a TLS connection to the server using OpenSSL via swagger.
259259
///
260260
/// # Arguments
261261
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"
@@ -269,7 +269,7 @@ impl<C> Client<
269269
Self::try_new_with_connector(base_path, Some("https"), https_connector)
270270
}
271271

272-
/// Create a client with a TLS connection to the server using a pinned certificate
272+
/// Create a client with a TLS connection to the server using a pinned certificate.
273273
///
274274
/// # Arguments
275275
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "Unlicense"
88
edition = "2018"
99

1010
[features]
11-
default = ["client", "server"]
11+
default = ["client", "server", "client-tls"]
1212
client = [
1313
"multipart", "multipart/client", "swagger/multipart_form",
1414
"mime_multipart", "swagger/multipart_related",
@@ -105,13 +105,15 @@ clap = "4.5"
105105
env_logger = "0.11"
106106
tokio = { version = "1.49", features = ["full"] }
107107
native-tls = "0.2"
108-
openssl = "0.10"
109-
tokio-openssl = "0.6"
110108
pin-project = "1.1.10"
111109

112110
# Bearer authentication, used in examples
113111
jsonwebtoken = {version = "10.0.0", features = ["rust_crypto"]}
114112

113+
[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dev-dependencies]
114+
openssl = "0.10"
115+
tokio-openssl = "0.6"
116+
115117
[[example]]
116118
name = "client"
117119
required-features = ["client"]

samples/server/petstore/rust-server/output/multipart-v3/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ The generated library has a few optional features that can be activated through
124124
* This defaults to disabled and allows JSON Schema validation of received data using `MakeService::set_validation` or `Service::set_validation`.
125125
* Note, enabling validation will have a performance penalty, especially if the API heavily uses regex based checks.
126126

127-
### Enabling HTTPS/TLS Support
127+
### HTTPS/TLS Support
128128

129-
By default, only HTTP support is included. To enable HTTPS, add the `client-tls` feature:
129+
HTTPS support is included by default. To disable it (for example, to reduce dependencies), you can:
130130

131131
```toml
132132
[dependencies]
133-
multipart-v3 = { version = "1.0.7", features = ["client-tls"] }
133+
multipart-v3 = { version = "1.0.7", default-features = false, features = ["client", "server"] }
134134
```
135135

136136
**For server with callbacks that need HTTPS:**
@@ -143,8 +143,6 @@ The TLS backend is automatically selected based on your target platform:
143143
- **macOS, Windows, iOS**: Uses `native-tls` (system TLS libraries)
144144
- **Linux, Unix, other platforms**: Uses `openssl`
145145

146-
This ensures the best compatibility and native integration on each platform.
147-
148146
See https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section for how to use features in your `Cargo.toml`.
149147

150148
## Documentation for API Endpoints

samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl<C> Client<
283283
> where
284284
C: Clone + Send + Sync + 'static
285285
{
286-
/// Create a client with a TLS connection to the server using native-tls.
286+
/// Create a client with a TLS connection to the server.
287287
///
288288
/// # Arguments
289289
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"
@@ -297,7 +297,7 @@ impl<C> Client<
297297
Self::try_new_with_connector(base_path, Some("https"), https_connector)
298298
}
299299

300-
/// Create a client with a TLS connection to the server using OpenSSL.
300+
/// Create a client with a TLS connection to the server using OpenSSL via swagger.
301301
///
302302
/// # Arguments
303303
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"
@@ -311,7 +311,7 @@ impl<C> Client<
311311
Self::try_new_with_connector(base_path, Some("https"), https_connector)
312312
}
313313

314-
/// Create a client with a TLS connection to the server using a pinned certificate
314+
/// Create a client with a TLS connection to the server using a pinned certificate.
315315
///
316316
/// # Arguments
317317
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"

samples/server/petstore/rust-server/output/no-example-v3/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "Unlicense"
88
edition = "2018"
99

1010
[features]
11-
default = ["client", "server"]
11+
default = ["client", "server", "client-tls"]
1212
client = [
1313
"hyper", "percent-encoding", "hyper-util/http1", "hyper-util/http2", "url"
1414
]
@@ -99,13 +99,15 @@ clap = "4.5"
9999
env_logger = "0.11"
100100
tokio = { version = "1.49", features = ["full"] }
101101
native-tls = "0.2"
102-
openssl = "0.10"
103-
tokio-openssl = "0.6"
104102
pin-project = "1.1.10"
105103

106104
# Bearer authentication, used in examples
107105
jsonwebtoken = {version = "10.0.0", features = ["rust_crypto"]}
108106

107+
[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dev-dependencies]
108+
openssl = "0.10"
109+
tokio-openssl = "0.6"
110+
109111
[[example]]
110112
name = "client"
111113
required-features = ["client"]

samples/server/petstore/rust-server/output/no-example-v3/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ The generated library has a few optional features that can be activated through
121121
* This defaults to disabled and allows JSON Schema validation of received data using `MakeService::set_validation` or `Service::set_validation`.
122122
* Note, enabling validation will have a performance penalty, especially if the API heavily uses regex based checks.
123123

124-
### Enabling HTTPS/TLS Support
124+
### HTTPS/TLS Support
125125

126-
By default, only HTTP support is included. To enable HTTPS, add the `client-tls` feature:
126+
HTTPS support is included by default. To disable it (for example, to reduce dependencies), you can:
127127

128128
```toml
129129
[dependencies]
130-
no-example-v3 = { version = "0.0.1", features = ["client-tls"] }
130+
no-example-v3 = { version = "0.0.1", default-features = false, features = ["client", "server"] }
131131
```
132132

133133
**For server with callbacks that need HTTPS:**
@@ -140,8 +140,6 @@ The TLS backend is automatically selected based on your target platform:
140140
- **macOS, Windows, iOS**: Uses `native-tls` (system TLS libraries)
141141
- **Linux, Unix, other platforms**: Uses `openssl`
142142

143-
This ensures the best compatibility and native integration on each platform.
144-
145143
See https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section for how to use features in your `Cargo.toml`.
146144

147145
## Documentation for API Endpoints

samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<C> Client<
276276
> where
277277
C: Clone + Send + Sync + 'static
278278
{
279-
/// Create a client with a TLS connection to the server using native-tls.
279+
/// Create a client with a TLS connection to the server.
280280
///
281281
/// # Arguments
282282
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"
@@ -290,7 +290,7 @@ impl<C> Client<
290290
Self::try_new_with_connector(base_path, Some("https"), https_connector)
291291
}
292292

293-
/// Create a client with a TLS connection to the server using OpenSSL.
293+
/// Create a client with a TLS connection to the server using OpenSSL via swagger.
294294
///
295295
/// # Arguments
296296
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"
@@ -304,7 +304,7 @@ impl<C> Client<
304304
Self::try_new_with_connector(base_path, Some("https"), https_connector)
305305
}
306306

307-
/// Create a client with a TLS connection to the server using a pinned certificate
307+
/// Create a client with a TLS connection to the server using a pinned certificate.
308308
///
309309
/// # Arguments
310310
/// * `base_path` - base path of the client API, i.e. "<https://www.my-api-implementation.com>"

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "Unlicense"
88
edition = "2018"
99

1010
[features]
11-
default = ["client", "server"]
11+
default = ["client", "server", "client-tls"]
1212
client = [
1313
"serde_urlencoded",
1414
"serde_ignored", "percent-encoding",
@@ -104,13 +104,15 @@ clap = "4.5"
104104
env_logger = "0.11"
105105
tokio = { version = "1.49", features = ["full"] }
106106
native-tls = "0.2"
107-
openssl = "0.10"
108-
tokio-openssl = "0.6"
109107
pin-project = "1.1.10"
110108

111109
# Bearer authentication, used in examples
112110
jsonwebtoken = {version = "10.0.0", features = ["rust_crypto"]}
113111

112+
[target.'cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))'.dev-dependencies]
113+
openssl = "0.10"
114+
tokio-openssl = "0.6"
115+
114116
[[example]]
115117
name = "client"
116118
required-features = ["client"]

0 commit comments

Comments
 (0)