Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit c3ac84c

Browse files
authored
[Rust] set supportAsync to true as the default (OpenAPITools#6480)
* set supportAsync to true * set reqwest as the default lib
1 parent 83bad10 commit c3ac84c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

bin/rust-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ for spec_path in \
4040
--input-spec $spec_path
4141
--generator-name rust
4242
--output samples/client/petstore/rust/$library/$spec
43-
--additional-properties packageName=${spec}-${library}
43+
--additional-properties packageName=${spec}-${library},supportAsync=false
4444
--library=$library $@"
4545
java ${JAVA_OPTS} -jar ${executable} ${args} || exit 1
4646
done

docs/generators/rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ sidebar_label: rust
66
| Option | Description | Values | Default |
77
| ------ | ----------- | ------ | ------- |
88
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
9-
|library|library template (sub-template) to use.|<dl><dt>**hyper**</dt><dd>HTTP client: Hyper.</dd><dt>**reqwest**</dt><dd>HTTP client: Reqwest.</dd></dl>|hyper|
9+
|library|library template (sub-template) to use.|<dl><dt>**hyper**</dt><dd>HTTP client: Hyper.</dd><dt>**reqwest**</dt><dd>HTTP client: Reqwest.</dd></dl>|reqwest|
1010
|packageName|Rust package name (convention: lowercase).| |openapi|
1111
|packageVersion|Rust package version.| |1.0.0|
12-
|supportAsync|If set, generate async function call instead| |false|
12+
|supportAsync|If set, generate async function call instead. This option is for 'reqwest' library only| |true|
1313
|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|
1414

1515
## IMPORT MAPPING

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
4040
private static final Logger LOGGER = LoggerFactory.getLogger(RustClientCodegen.class);
4141
private boolean useSingleRequestParameter = false;
42-
private boolean supportAsync = false;
42+
private boolean supportAsync = true;
4343

4444
public static final String PACKAGE_NAME = "packageName";
4545
public static final String PACKAGE_VERSION = "packageVersion";
@@ -173,18 +173,18 @@ public RustClientCodegen() {
173173
.defaultValue(Boolean.TRUE.toString()));
174174
cliOptions.add(new CliOption(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, CodegenConstants.USE_SINGLE_REQUEST_PARAMETER_DESC, SchemaTypeUtil.BOOLEAN_TYPE)
175175
.defaultValue(Boolean.FALSE.toString()));
176-
cliOptions.add(new CliOption(SUPPORT_ASYNC, "If set, generate async function call instead", SchemaTypeUtil.BOOLEAN_TYPE)
177-
.defaultValue(Boolean.FALSE.toString()));
176+
cliOptions.add(new CliOption(SUPPORT_ASYNC, "If set, generate async function call instead. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE)
177+
.defaultValue(Boolean.TRUE.toString()));
178178

179179
supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper.");
180180
supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest.");
181181

182182
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use.");
183183
libraryOption.setEnum(supportedLibraries);
184-
// set hyper as the default
185-
libraryOption.setDefault(HYPER_LIBRARY);
184+
// set reqwest as the default
185+
libraryOption.setDefault(REQWEST_LIBRARY);
186186
cliOptions.add(libraryOption);
187-
setLibrary(HYPER_LIBRARY);
187+
setLibrary(REQWEST_LIBRARY);
188188
}
189189

190190
@Override

0 commit comments

Comments
 (0)