Skip to content

Commit

Permalink
Merge branch 'upstream_master' into feature/swift6-general-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
4brunu committed Oct 1, 2024
2 parents 152e1ce + 8ef3118 commit f70c863
Show file tree
Hide file tree
Showing 109 changed files with 4,555 additions and 500 deletions.
11 changes: 11 additions & 0 deletions bin/configs/rust-reqwest-petstore-async-tokensource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
generatorName: rust
outputDir: samples/client/petstore/rust/reqwest/petstore-async-tokensource
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: true
supportTokenSource: true
supportMultipleResponses: true
packageName: petstore-reqwest-async-tokensource
useSingleRequestParameter: true
1 change: 1 addition & 0 deletions docs/generators/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|supportAsync|If set, generate async function call instead. This option is for 'reqwest' library only| |true|
|supportMiddleware|If set, add support for reqwest-middleware. This option is for 'reqwest' library only| |false|
|supportMultipleResponses|If set, return type wraps an enum of all possible 2xx schemas. This option is for 'reqwest' library only| |false|
|supportTokenSource|If set, add support for google-cloud-token. This option is for 'reqwest' library only and requires the 'supportAsync' option| |false|
|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|
|withAWSV4Signature|whether to include AWS v4 signature support| |false|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
@Setter(AccessLevel.PRIVATE) private boolean useSingleRequestParameter = false;
@Setter(AccessLevel.PRIVATE) private boolean supportAsync = true;
@Setter(AccessLevel.PRIVATE) private boolean supportMiddleware = false;
@Setter(AccessLevel.PRIVATE) private boolean supportTokenSource = false;
private boolean supportMultipleResponses = false;
private boolean withAWSV4Signature = false;
@Setter private boolean preferUnsignedInt = false;
Expand All @@ -62,6 +63,7 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
public static final String REQWEST_LIBRARY = "reqwest";
public static final String SUPPORT_ASYNC = "supportAsync";
public static final String SUPPORT_MIDDLEWARE = "supportMiddleware";
public static final String SUPPORT_TOKEN_SOURCE = "supportTokenSource";
public static final String SUPPORT_MULTIPLE_RESPONSES = "supportMultipleResponses";
public static final String PREFER_UNSIGNED_INT = "preferUnsignedInt";
public static final String BEST_FIT_INT = "bestFitInt";
Expand Down Expand Up @@ -192,6 +194,8 @@ public RustClientCodegen() {
.defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(SUPPORT_MIDDLEWARE, "If set, add support for reqwest-middleware. This option is for 'reqwest' library only", SchemaTypeUtil.BOOLEAN_TYPE)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(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)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(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)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix));
Expand Down Expand Up @@ -346,6 +350,11 @@ public void processOpts() {
}
writePropertyBack(SUPPORT_MIDDLEWARE, getSupportMiddleware());

if (additionalProperties.containsKey(SUPPORT_TOKEN_SOURCE)) {
this.setSupportTokenSource(convertPropertyToBoolean(SUPPORT_TOKEN_SOURCE));
}
writePropertyBack(SUPPORT_TOKEN_SOURCE, getSupportTokenSource());

if (additionalProperties.containsKey(SUPPORT_MULTIPLE_RESPONSES)) {
this.setSupportMultipleReturns(convertPropertyToBoolean(SUPPORT_MULTIPLE_RESPONSES));
}
Expand Down Expand Up @@ -437,6 +446,10 @@ private boolean getSupportAsync() {
private boolean getSupportMiddleware() {
return supportMiddleware;
}

private boolean getSupportTokenSource() {
return supportTokenSource;
}

public boolean getSupportMultipleReturns() {
return supportMultipleResponses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#ifndef {{prefix}}Helpers_H_
#define {{prefix}}Helpers_H_

#include <cstdint>
#include <ctime>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

namespace {{helpersNamespace}}
{
Expand Down
Loading

0 comments on commit f70c863

Please sign in to comment.