You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added support for a trait based reqwest Rust client (#19788)
* Added Rust Reqwest trait based client
* Fixed Cargo imports for reqwest trait template
* Added support for mockall to Rust reqwest trait library
* Added MockApiClient when mockall and topLevelClient are enabled
* Added missing flags to Rust generator documentation
* feat: add support for single argument and bon builder
Adds support for single argument and bon building for the new
reqwest-trait generator
* Rebuilt rust samples
---------
Co-authored-by: Troy Benson <[email protected]>
|mockall|Adds `#[automock]` from the mockall crate to api traits. This option is for 'reqwest-trait' library only||false|
26
27
|packageName|Rust package name (convention: lowercase).||openapi|
27
28
|packageVersion|Rust package version.||1.0.0|
28
29
|preferUnsignedInt|Prefer unsigned integers where minimum value is >= 0||false|
29
30
|supportAsync|If set, generate async function call instead. This option is for 'reqwest' library only||true|
30
-
|supportMiddleware|If set, add support for reqwest-middleware. This option is for 'reqwest' library only||false|
31
-
|supportMultipleResponses|If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only||false|
32
-
|supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' library only and requires the 'supportAsync' option||false|
31
+
|supportMiddleware|If set, add support for reqwest-middleware. This option is for 'reqwest' and 'reqwest-trait' library only||false|
32
+
|supportMultipleResponses|If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only||false|
33
+
|supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option||false|
34
+
|topLevelApiClient|Creates a top level `Api` trait and `ApiClient` struct that contain all Apis. This option is for 'reqwest-trait' library only||false|
35
+
|useBonBuilder|Use the bon crate for building parameter types. This option is for the 'reqwest-trait' library only||false|
33
36
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.||false|
34
37
|withAWSV4Signature|whether to include AWS v4 signature support||false|
@@ -192,11 +221,11 @@ public RustClientCodegen() {
192
221
.defaultValue(Boolean.FALSE.toString()));
193
222
cliOptions.add(newCliOption(SUPPORT_ASYNC, "If set, generate async function call instead. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE)
194
223
.defaultValue(Boolean.TRUE.toString()));
195
-
cliOptions.add(newCliOption(SUPPORT_MIDDLEWARE, "If set, add support for reqwest-middleware. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE)
224
+
cliOptions.add(newCliOption(SUPPORT_MIDDLEWARE, "If set, add support for reqwest-middleware. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
196
225
.defaultValue(Boolean.FALSE.toString()));
197
-
cliOptions.add(newCliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE)
226
+
cliOptions.add(newCliOption(SUPPORT_TOKEN_SOURCE, "If set, add support for google-cloud-token. This option is for 'reqwest' and 'reqwest-trait' library only and requires the 'supportAsync' option", SchemaTypeUtil.BOOLEAN_TYPE)
198
227
.defaultValue(Boolean.FALSE.toString()));
199
-
cliOptions.add(newCliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE)
228
+
cliOptions.add(newCliOption(SUPPORT_MULTIPLE_RESPONSES, "If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
@@ -207,10 +236,17 @@ public RustClientCodegen() {
207
236
.defaultValue(Boolean.FALSE.toString()));
208
237
cliOptions.add(newCliOption(AVOID_BOXED_MODELS, "If set, `Box<T>` will not be used for models", SchemaTypeUtil.BOOLEAN_TYPE)
209
238
.defaultValue(Boolean.FALSE.toString()));
239
+
cliOptions.add(newCliOption(MOCKALL, "Adds `#[automock]` from the mockall crate to api traits. This option is for 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
240
+
.defaultValue(Boolean.FALSE.toString()));
241
+
cliOptions.add(newCliOption(TOP_LEVEL_API_CLIENT, "Creates a top level `Api` trait and `ApiClient` struct that contain all Apis. This option is for 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
242
+
.defaultValue(Boolean.FALSE.toString()));
243
+
cliOptions.add(newCliOption(BON_BUILDER, "Use the bon crate for building parameter types. This option is for the 'reqwest-trait' library only", SchemaTypeUtil.BOOLEAN_TYPE)
0 commit comments