From f2e1399799ad61346bd4edf6089bcf634aac09fa Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Sat, 9 May 2020 15:04:59 +0800 Subject: [PATCH 1/3] add useSingleParameter option --- .../codegen/CodegenConstants.java | 3 +++ .../codegen/languages/RustClientCodegen.java | 27 +++++++++++++++++-- .../TypeScriptFetchClientCodegen.java | 8 +++--- .../main/resources/rust/reqwest/api.mustache | 16 +++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java index 63ba7836430..87d703f43ea 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java @@ -356,4 +356,7 @@ public class CodegenConstants { public static final String LEGACY_DISCRIMINATOR_BEHAVIOR_DESC = "This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. " + "Note to developers supporting a language generator in OpenAPITools; to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}."; + public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter"; + public static final String USE_SINGLE_REQUEST_PARAMETER_DESC = "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter"; + } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index 1f81ba8133b..040c9877923 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -21,6 +21,7 @@ import com.google.common.base.Strings; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.parser.util.SchemaTypeUtil; import org.openapitools.codegen.*; import org.openapitools.codegen.meta.features.*; import org.openapitools.codegen.utils.ModelUtils; @@ -37,6 +38,8 @@ import static org.openapitools.codegen.utils.StringUtils.underscore; public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(RustClientCodegen.class); + private boolean useSingleRequestParameter = true; + public static final String PACKAGE_NAME = "packageName"; public static final String PACKAGE_VERSION = "packageVersion"; @@ -167,6 +170,8 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { .defaultValue("1.0.0")); cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); + cliOptions.add(new CliOption(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, CodegenConstants.USE_SINGLE_REQUEST_PARAMETER_DESC, SchemaTypeUtil.BOOLEAN_TYPE) + .defaultValue(Boolean.TRUE.toString())); supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper."); supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest."); @@ -209,7 +214,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { CodegenModel cm = (CodegenModel) mo.get("model"); if (cm.discriminator != null) { List<Object> discriminatorVars = new ArrayList<>(); - for(CodegenDiscriminator.MappedModel mappedModel: cm.discriminator.getMappedModels()) { + for (CodegenDiscriminator.MappedModel mappedModel : cm.discriminator.getMappedModels()) { CodegenModel model = allModels.get(mappedModel.getModelName()); Map<String, Object> mas = new HashMap<>(); mas.put("modelName", camelize(mappedModel.getModelName())); @@ -247,13 +252,18 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { setPackageVersion("1.0.0"); } + if (additionalProperties.containsKey(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER)) { + this.setUseSingleRequestParameter(convertPropertyToBoolean(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER)); + } + writePropertyBack(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter()); + additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); - if ( HYPER_LIBRARY.equals(getLibrary())){ + if (HYPER_LIBRARY.equals(getLibrary())) { additionalProperties.put(HYPER_LIBRARY, "true"); } else if (REQWEST_LIBRARY.equals(getLibrary())) { additionalProperties.put(REQWEST_LIBRARY, "true"); @@ -283,6 +293,14 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile(getLibrary() + "/api_mod.mustache", apiFolder, "mod.rs")); } + private boolean getUseSingleRequestParameter() { + return useSingleRequestParameter; + } + + private void setUseSingleRequestParameter(boolean useSingleRequestParameter) { + this.useSingleRequestParameter = useSingleRequestParameter; + } + @Override public String escapeReservedWord(String name) { if (this.reservedWordsMappings().containsKey(name)) { @@ -471,6 +489,11 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT); } + // add support for single request parameter using x-group-parameters + if (!operation.vendorExtensions.containsKey("x-group-parameters") && useSingleRequestParameter) { + operation.vendorExtensions.put("x-group-parameters", Boolean.TRUE); + } + // update return type to conform to rust standard /* if (operation.returnType != null) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index 208d42834eb..990c206fca5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -70,7 +70,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege supportModelPropertyNaming(CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.camelCase); this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json")); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); - this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString())); + this.cliOptions.add(new CliOption(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, CodegenConstants.USE_SINGLE_REQUEST_PARAMETER_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString())); this.cliOptions.add(new CliOption(PREFIX_PARAMETER_INTERFACES, "Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(TYPESCRIPT_THREE_PLUS, "Setting this property to true will generate TypeScript 3.6+ compatible code.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); } @@ -118,10 +118,10 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege supportingFiles.add(new SupportingFile("index.mustache", sourceDir, "index.ts")); supportingFiles.add(new SupportingFile("runtime.mustache", sourceDir, "runtime.ts")); - if (additionalProperties.containsKey(USE_SINGLE_REQUEST_PARAMETER)) { - this.setUseSingleRequestParameter(convertPropertyToBoolean(USE_SINGLE_REQUEST_PARAMETER)); + if (additionalProperties.containsKey(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER)) { + this.setUseSingleRequestParameter(convertPropertyToBoolean(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER)); } - writePropertyBack(USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter()); + writePropertyBack(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, getUseSingleRequestParameter()); if (additionalProperties.containsKey(PREFIX_PARAMETER_INTERFACES)) { this.setPrefixParameterInterfaces(convertPropertyToBoolean(PREFIX_PARAMETER_INTERFACES)); diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index dc2a9edb488..bc380ff74ac 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -31,7 +31,23 @@ pub trait {{{classname}}} { impl {{{classname}}} for {{{classname}}}Client { {{#operations}} {{#operation}} + {{#vendorExtensions.x-group-parameters}} + #[derive(Default)] + struct {{{operationIdCamelCase}}}Params { + {{#allParams}} + {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}} + {{/allParams}} + } + + fn {{{operationId}}}(&self, params: {{{operationIdCamelCase}}}Params) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + {{#allParams}} + let {{paramName}} = params.{{paramName}}; + {{/allParams}} + + {{/vendorExtensions.x-group-parameters}} + {{^vendorExtensions.x-group-parameters}} fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + {{/vendorExtensions.x-group-parameters}} let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; -- GitLab From 687d2dca5ccf605037102c09b80d0267897a8f58 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Sat, 9 May 2020 17:20:04 +0800 Subject: [PATCH 2/3] fix group parameter in rust reqwest --- .../main/resources/rust/reqwest/api.mustache | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index bc380ff74ac..5f1c79b91b8 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -20,10 +20,33 @@ impl {{{classname}}}Client { } } +{{#operations}} +{{#operation}} + {{#vendorExtensions.x-group-parameters}} + /// struct for passing parameters to the method `{{operationdId}}` + #[derive(Clone, Debug)] + struct {{{operationIdCamelCase}}}Params { + {{#allParams}} + {{#description}} + /// {{{.}}} + {{/description}} + {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}String{{/isString}}{{#isUuid}}String{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}} + {{/allParams}} + } + + {{/vendorExtensions.x-group-parameters}} +{{/operation}} +{{/operations}} + pub trait {{{classname}}} { {{#operations}} {{#operation}} + {{#vendorExtensions.x-group-parameters}} + fn {{{operationId}}}(&self, params: {{{operationIdCamelCase}}}Params) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; + {{/vendorExtensions.x-group-parameters}} + {{^vendorExtensions.x-group-parameters}} fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; + {{/vendorExtensions.x-group-parameters}} {{/operation}} {{/operations}} } @@ -32,13 +55,6 @@ impl {{{classname}}} for {{{classname}}}Client { {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} - #[derive(Default)] - struct {{{operationIdCamelCase}}}Params { - {{#allParams}} - {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}} - {{/allParams}} - } - fn {{{operationId}}}(&self, params: {{{operationIdCamelCase}}}Params) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { {{#allParams}} let {{paramName}} = params.{{paramName}}; -- GitLab From e68448104e7df172dabf5476486adc3113c37748 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Sat, 9 May 2020 18:05:31 +0800 Subject: [PATCH 3/3] rust-single-param --- docs/generators/rust.md | 1 + .../openapitools/codegen/CodegenConstants.java | 2 +- .../codegen/languages/RustClientCodegen.java | 4 ++-- .../src/main/resources/rust/reqwest/api.mustache | 15 ++++++++++----- .../fileResponseTest/.openapi-generator/VERSION | 2 +- .../hyper/petstore/.openapi-generator/VERSION | 2 +- .../hyper/rust-test/.openapi-generator/VERSION | 2 +- .../fileResponseTest/.openapi-generator/VERSION | 2 +- .../fileResponseTest/src/apis/default_api.rs | 1 + .../reqwest/petstore/.openapi-generator/VERSION | 2 +- .../rust/reqwest/petstore/src/apis/pet_api.rs | 1 + .../rust/reqwest/petstore/src/apis/store_api.rs | 1 + .../rust/reqwest/petstore/src/apis/user_api.rs | 1 + .../reqwest/rust-test/.openapi-generator/VERSION | 2 +- .../reqwest/rust-test/src/apis/default_api.rs | 1 + 15 files changed, 25 insertions(+), 14 deletions(-) diff --git a/docs/generators/rust.md b/docs/generators/rust.md index 221c6114561..cea41866744 100644 --- a/docs/generators/rust.md +++ b/docs/generators/rust.md @@ -9,6 +9,7 @@ sidebar_label: rust |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| |packageName|Rust package name (convention: lowercase).| |openapi| |packageVersion|Rust package version.| |1.0.0| +|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| ## IMPORT MAPPING diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java index 87d703f43ea..1bda56c2694 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java @@ -357,6 +357,6 @@ public class CodegenConstants { "Note to developers supporting a language generator in OpenAPITools; to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}."; public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter"; - public static final String USE_SINGLE_REQUEST_PARAMETER_DESC = "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter"; + public static final String USE_SINGLE_REQUEST_PARAMETER_DESC = "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter."; } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index 040c9877923..706083b50dc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -38,7 +38,7 @@ import static org.openapitools.codegen.utils.StringUtils.underscore; public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(RustClientCodegen.class); - private boolean useSingleRequestParameter = true; + private boolean useSingleRequestParameter = false; public static final String PACKAGE_NAME = "packageName"; public static final String PACKAGE_VERSION = "packageVersion"; @@ -171,7 +171,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, CodegenConstants.USE_SINGLE_REQUEST_PARAMETER_DESC, SchemaTypeUtil.BOOLEAN_TYPE) - .defaultValue(Boolean.TRUE.toString())); + .defaultValue(Boolean.FALSE.toString())); supportedLibraries.put(HYPER_LIBRARY, "HTTP client: Hyper."); supportedLibraries.put(REQWEST_LIBRARY, "HTTP client: Reqwest."); diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index 5f1c79b91b8..18602ce77ab 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -23,17 +23,21 @@ impl {{{classname}}}Client { {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} - /// struct for passing parameters to the method `{{operationdId}}` + {{#allParams}} + {{#-first}} + /// struct for passing parameters to the method `{{operationId}}` #[derive(Clone, Debug)] struct {{{operationIdCamelCase}}}Params { - {{#allParams}} + {{/-first}} {{#description}} /// {{{.}}} {{/description}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}String{{/isString}}{{#isUuid}}String{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}} - {{/allParams}} + {{#-last}} } + {{/-last}} + {{/allParams}} {{/vendorExtensions.x-group-parameters}} {{/operation}} {{/operations}} @@ -42,7 +46,7 @@ pub trait {{{classname}}} { {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} - fn {{{operationId}}}(&self, params: {{{operationIdCamelCase}}}Params) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; + fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; {{/vendorExtensions.x-group-parameters}} {{^vendorExtensions.x-group-parameters}} fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>; @@ -55,7 +59,8 @@ impl {{{classname}}} for {{{classname}}}Client { {{#operations}} {{#operation}} {{#vendorExtensions.x-group-parameters}} - fn {{{operationId}}}(&self, params: {{{operationIdCamelCase}}}Params) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + fn {{{operationId}}}(&self{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> { + // unbox the parameters {{#allParams}} let {{paramName}} = params.{{paramName}}; {{/allParams}} diff --git a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION index c3a2c7076fa..d99e7162d01 100644 --- a/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/hyper/fileResponseTest/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION index c3a2c7076fa..d99e7162d01 100644 --- a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION index c3a2c7076fa..d99e7162d01 100644 --- a/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/hyper/rust-test/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION index c3a2c7076fa..d99e7162d01 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs index b12bf1e4985..407215f0c7b 100644 --- a/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/default_api.rs @@ -29,6 +29,7 @@ impl DefaultApiClient { } } + pub trait DefaultApi { fn fileresponsetest(&self, ) -> Result<std::path::PathBuf, Error>; } diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION index c3a2c7076fa..d99e7162d01 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs index 2412f13002e..be122c14b7e 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/pet_api.rs @@ -29,6 +29,7 @@ impl PetApiClient { } } + pub trait PetApi { fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error>; fn delete_pet(&self, pet_id: i64, api_key: Option<&str>) -> Result<(), Error>; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs index 11b427c47f5..8856e2d9f05 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/store_api.rs @@ -29,6 +29,7 @@ impl StoreApiClient { } } + pub trait StoreApi { fn delete_order(&self, order_id: &str) -> Result<(), Error>; fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error>; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs index f0d39ed235a..0ae10985297 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/user_api.rs @@ -29,6 +29,7 @@ impl UserApiClient { } } + pub trait UserApi { fn create_user(&self, body: crate::models::User) -> Result<(), Error>; fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error>; diff --git a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION index c3a2c7076fa..d99e7162d01 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/reqwest/rust-test/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs index f154a6998c3..697d250b540 100644 --- a/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs +++ b/samples/client/petstore/rust/reqwest/rust-test/src/apis/default_api.rs @@ -29,6 +29,7 @@ impl DefaultApiClient { } } + pub trait DefaultApi { fn dummy_get(&self, ) -> Result<(), Error>; } -- GitLab