Skip to content

Commit d2c3308

Browse files
committed
Add CLI option
1 parent fd72d4d commit d2c3308

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

docs/generators/rust.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
3030
|reqwestDefaultFeatures|Default features for the reqwest dependency (comma-separated). Use empty for no defaults. This option is for 'reqwest' and 'reqwest-trait' library only.| |native-tls|
3131
|supportAsync|If set, generate async function call instead. This option is for 'reqwest' library only| |true|
3232
|supportMiddleware|If set, add support for reqwest-middleware. This option is for 'reqwest' and 'reqwest-trait' library only| |false|
33+
|useSerdePathToError|If set, use the serde_path_to_error library to enhance serde error messages. This option is for 'reqwest' and 'reqwest-trait' library only| |false|
3334
|supportMultipleResponses|If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' and 'reqwest-trait' library only| |false|
3435
|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|
3536
|topLevelApiClient|Creates a top level `Api` trait and `ApiClient` struct that contain all Apis. This option is for 'reqwest-trait' library only| |false|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
5252
@Setter(AccessLevel.PRIVATE) private boolean useSingleRequestParameter = false;
5353
@Setter(AccessLevel.PRIVATE) private boolean supportAsync = true;
5454
@Setter(AccessLevel.PRIVATE) private boolean supportMiddleware = false;
55+
@Setter(AccessLevel.PRIVATE) private boolean useSerdePathToError = false;
5556
@Setter(AccessLevel.PRIVATE) private boolean supportTokenSource = false;
5657
private boolean supportMultipleResponses = false;
5758
private boolean withAWSV4Signature = false;
@@ -70,6 +71,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
7071
public static final String REQWEST_TRAIT_LIBRARY_ATTR = "reqwestTrait";
7172
public static final String SUPPORT_ASYNC = "supportAsync";
7273
public static final String SUPPORT_MIDDLEWARE = "supportMiddleware";
74+
public static final String USE_SERDE_PATH_TO_ERROR = "useSerdePathToError";
7375
public static final String SUPPORT_TOKEN_SOURCE = "supportTokenSource";
7476
public static final String SUPPORT_MULTIPLE_RESPONSES = "supportMultipleResponses";
7577
public static final String PREFER_UNSIGNED_INT = "preferUnsignedInt";
@@ -410,6 +412,11 @@ public void processOpts() {
410412
}
411413
writePropertyBack(SUPPORT_MIDDLEWARE, getSupportMiddleware());
412414

415+
if (additionalProperties.containsKey(USE_SERDE_PATH_TO_ERROR)) {
416+
this.setUseSerdePathToError(convertPropertyToBoolean(USE_SERDE_PATH_TO_ERROR));
417+
}
418+
writePropertyBack(USE_SERDE_PATH_TO_ERROR, getUseSerdePathToError());
419+
413420
if (additionalProperties.containsKey(SUPPORT_TOKEN_SOURCE)) {
414421
this.setSupportTokenSource(convertPropertyToBoolean(SUPPORT_TOKEN_SOURCE));
415422
}
@@ -527,6 +534,10 @@ private boolean getSupportMiddleware() {
527534
return supportMiddleware;
528535
}
529536

537+
private boolean getUseSerdePathToError() {
538+
return useSerdePathToError;
539+
}
540+
530541
private boolean getSupportTokenSource() {
531542
return supportTokenSource;
532543
}

0 commit comments

Comments
 (0)