diff --git a/bin/configs/rust-reqwest-name-mapping.yaml b/bin/configs/rust-reqwest-name-mapping.yaml
new file mode 100644
index 00000000000..16a9b02ac17
--- /dev/null
+++ b/bin/configs/rust-reqwest-name-mapping.yaml
@@ -0,0 +1,16 @@
+generatorName: rust
+outputDir: samples/client/petstore/rust/reqwest/name-mapping
+library: reqwest
+inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/rust-name-mapping-test.yaml
+templateDir: modules/openapi-generator/src/main/resources/rust
+additionalProperties:
+ supportAsync: false
+ packageName: petstore-name-mapping
+nameMappings:
+ _type: underscore_type
+ type_: type_with_underscore
+ -type: dash_type
+parameterNameMappings:
+ _type: underscore_type
+ type_: type_with_underscore
+ -type: dash_type
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java
index bc5ddd49756..df0c7df1dcc 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java
@@ -42,7 +42,9 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
}
@Override
- public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.RUST; }
+ public GeneratorLanguage generatorLanguage() {
+ return GeneratorLanguage.RUST;
+ }
@Override
public String escapeQuotationMark(String input) {
@@ -65,19 +67,20 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
* Determine the best fitting Rust type for an integer property. This is intended for use when a specific format
* has not been defined in the specification. Where the minimum or maximum is not known then the returned type
* will default to having at least 32 bits.
- * @param minimum The minimum value as set in the specification.
+ *
+ * @param minimum The minimum value as set in the specification.
* @param exclusiveMinimum If the minimum value itself is excluded by the specification.
- * @param maximum The maximum value as set in the specification.
+ * @param maximum The maximum value as set in the specification.
* @param exclusiveMaximum If the maximum value itself is excluded by the specification.
- * @param preferUnsigned Use unsigned types where the effective minimum is greater than or equal to zero.
+ * @param preferUnsigned Use unsigned types where the effective minimum is greater than or equal to zero.
* @return The Rust data type name.
*/
@VisibleForTesting
public String bestFittingIntegerType(@Nullable BigInteger minimum,
- boolean exclusiveMinimum,
- @Nullable BigInteger maximum,
- boolean exclusiveMaximum,
- boolean preferUnsigned) {
+ boolean exclusiveMinimum,
+ @Nullable BigInteger maximum,
+ boolean exclusiveMaximum,
+ boolean preferUnsigned) {
if (exclusiveMinimum) {
minimum = Optional.ofNullable(minimum).map(min -> min.add(BigInteger.ONE)).orElse(null);
}
@@ -127,7 +130,8 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
/**
* Determine if an integer property can be guaranteed to fit into an unsigned data type.
- * @param minimum The minimum value as set in the specification.
+ *
+ * @param minimum The minimum value as set in the specification.
* @param exclusiveMinimum If boundary values are excluded by the specification.
* @return True if the effective minimum is greater than or equal to zero.
*/
@@ -141,7 +145,9 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
}).orElse(false);
}
- public enum CasingType {CAMEL_CASE, SNAKE_CASE};
+ public enum CasingType {CAMEL_CASE, SNAKE_CASE}
+
+ ;
/**
* General purpose sanitizing function for Rust identifiers (fields, variables, structs, parameters, etc.).
@@ -151,10 +157,11 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
*
Cannot use reserved words (but can sometimes prefix with "r#")
* Cannot begin with a number
*
- * @param name The input string
- * @param casingType Which casing type to apply
- * @param escapePrefix Prefix to escape words beginning with numbers or reserved words
- * @param type The type of identifier (used for logging)
+ *
+ * @param name The input string
+ * @param casingType Which casing type to apply
+ * @param escapePrefix Prefix to escape words beginning with numbers or reserved words
+ * @param type The type of identifier (used for logging)
* @param allowRawIdentifiers Raw identifiers can't always be used, because of filename vs import mismatch.
* @return Sanitized string
*/
@@ -214,7 +221,7 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
name = casingFunction.apply(escapePrefix + '_' + name);
} else {
name = "r#" + name;
- };
+ }
}
// If the name had to be modified (not just because of casing), log the change
@@ -227,11 +234,21 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
@Override
public String toVarName(String name) {
+ // obtain the name from nameMapping directly if provided
+ if (nameMapping.containsKey(name)) {
+ return nameMapping.get(name);
+ }
+
return sanitizeIdentifier(name, CasingType.SNAKE_CASE, "param", "field/variable", true);
}
@Override
public String toParamName(String name) {
+ // obtain the name from parameterNameMapping directly if provided
+ if (parameterNameMapping.containsKey(name)) {
+ return parameterNameMapping.get(name);
+ }
+
return sanitizeIdentifier(name, CasingType.SNAKE_CASE, "param", "parameter", true);
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
index 2b309f5dfa7..4ef5f25c7ad 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
@@ -1286,7 +1286,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
if (Objects.equals(property.baseType, "integer")) {
BigInteger minimum = Optional.ofNullable(property.getMinimum()).map(BigInteger::new).orElse(null);
- BigInteger maximum = Optional.ofNullable(property.getMaximum()).map(BigInteger::new).orElse(null);
+ BigInteger maximum = Optional.ofNullable(property.getMaximum()).map(BigInteger::new).orElse(null);
boolean unsigned = canFitIntoUnsigned(minimum, property.getExclusiveMinimum());
@@ -1467,7 +1467,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
}
@Override
- protected void updateParameterForString(CodegenParameter codegenParameter, Schema parameterSchema){
+ protected void updateParameterForString(CodegenParameter codegenParameter, Schema parameterSchema) {
/**
* we have a custom version of this function to set isString to false for uuid
*/
diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
index 3774c8f2095..2471f2080b9 100644
--- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
@@ -39,7 +39,7 @@ serde_with = "^2.0"
{{/serdeWith}}
serde_json = "^1.0"
url = "^2.2"
-uuid = { version = "^1.0", features = ["serde"] }
+uuid = { version = "^1.0", features = ["serde", "v4"] }
{{#hyper}}
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/rust-name-mapping-test.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/rust-name-mapping-test.yaml
new file mode 100644
index 00000000000..77977b2874c
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/rust/rust-name-mapping-test.yaml
@@ -0,0 +1,66 @@
+openapi: 3.0.0
+servers:
+ - url: 'http://petstore.swagger.io/v2'
+info:
+ description: rust name mapping test
+ version: 1.0.0
+ title: rust test
+ license:
+ name: Apache-2.0
+ url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
+paths:
+ /fake/parameter-name-mapping:
+ get:
+ tags:
+ - fake
+ summary: parameter name mapping test
+ operationId: getParameterNameMapping
+ parameters:
+ - name: _type
+ in: header
+ description: _type
+ required: true
+ schema:
+ type: integer
+ format: int64
+ - name: type
+ in: query
+ description: type
+ required: true
+ schema:
+ type: string
+ - name: type_
+ in: header
+ description: type_
+ required: true
+ schema:
+ type: string
+ - name: -type
+ in: header
+ description: -type
+ required: true
+ schema:
+ type: string
+ - name: http_debug_option
+ in: query
+ description: http debug option (to test parameter naming option)
+ required: true
+ schema:
+ type: string
+ responses:
+ 200:
+ description: OK
+components:
+ schemas:
+ PropertyNameMapping:
+ properties:
+ http_debug_operation:
+ type: string
+ _type:
+ type: string
+ type:
+ type: string
+ type_:
+ type: string
+ -type:
+ type: string
diff --git a/samples/client/others/rust/reqwest-regression-16119/Cargo.toml b/samples/client/others/rust/reqwest-regression-16119/Cargo.toml
index 41098da453c..7b07dbb5681 100644
--- a/samples/client/others/rust/reqwest-regression-16119/Cargo.toml
+++ b/samples/client/others/rust/reqwest-regression-16119/Cargo.toml
@@ -12,5 +12,5 @@ serde_derive = "^1.0"
serde_with = "^2.0"
serde_json = "^1.0"
url = "^2.2"
-uuid = { version = "^1.0", features = ["serde"] }
+uuid = { version = "^1.0", features = ["serde", "v4"] }
reqwest = "~0.9"
diff --git a/samples/client/petstore/rust/hyper/petstore/Cargo.toml b/samples/client/petstore/rust/hyper/petstore/Cargo.toml
index 46601e7408e..7edd302b89e 100644
--- a/samples/client/petstore/rust/hyper/petstore/Cargo.toml
+++ b/samples/client/petstore/rust/hyper/petstore/Cargo.toml
@@ -12,7 +12,7 @@ serde_derive = "^1.0"
serde_with = "^2.0"
serde_json = "^1.0"
url = "^2.2"
-uuid = { version = "^1.0", features = ["serde"] }
+uuid = { version = "^1.0", features = ["serde", "v4"] }
hyper = { version = "~0.14", features = ["full"] }
hyper-tls = "~0.5"
http = "~0.2"
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/.gitignore b/samples/client/petstore/rust/reqwest/name-mapping/.gitignore
new file mode 100644
index 00000000000..6aa106405a4
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/.gitignore
@@ -0,0 +1,3 @@
+/target/
+**/*.rs.bk
+Cargo.lock
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator-ignore
new file mode 100644
index 00000000000..7484ee590a3
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator-ignore
@@ -0,0 +1,23 @@
+# OpenAPI Generator Ignore
+# Generated by openapi-generator https://github.com/openapitools/openapi-generator
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator/FILES
new file mode 100644
index 00000000000..31b2b40ccf3
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator/FILES
@@ -0,0 +1,13 @@
+.gitignore
+.travis.yml
+Cargo.toml
+README.md
+docs/FakeApi.md
+docs/PropertyNameMapping.md
+git_push.sh
+src/apis/configuration.rs
+src/apis/fake_api.rs
+src/apis/mod.rs
+src/lib.rs
+src/models/mod.rs
+src/models/property_name_mapping.rs
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator/VERSION b/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator/VERSION
new file mode 100644
index 00000000000..757e6740040
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/.openapi-generator/VERSION
@@ -0,0 +1 @@
+7.0.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/.travis.yml b/samples/client/petstore/rust/reqwest/name-mapping/.travis.yml
new file mode 100644
index 00000000000..22761ba7ee1
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/.travis.yml
@@ -0,0 +1 @@
+language: rust
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/Cargo.toml b/samples/client/petstore/rust/reqwest/name-mapping/Cargo.toml
new file mode 100644
index 00000000000..5e7f18223f5
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+name = "petstore-name-mapping"
+version = "1.0.0"
+authors = ["OpenAPI Generator team and contributors"]
+description = "rust name mapping test"
+license = "Apache-2.0"
+edition = "2018"
+
+[dependencies]
+serde = "^1.0"
+serde_derive = "^1.0"
+serde_json = "^1.0"
+url = "^2.2"
+uuid = { version = "^1.0", features = ["serde", "v4"] }
+reqwest = "~0.9"
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/README.md b/samples/client/petstore/rust/reqwest/name-mapping/README.md
new file mode 100644
index 00000000000..c3b8b66edd7
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/README.md
@@ -0,0 +1,45 @@
+# Rust API client for petstore-name-mapping
+
+rust name mapping test
+
+
+## Overview
+
+This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
+
+- API version: 1.0.0
+- Package version: 1.0.0
+- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
+
+## Installation
+
+Put the package under your project folder in a directory named `petstore-name-mapping` and add the following to `Cargo.toml` under `[dependencies]`:
+
+```
+petstore-name-mapping = { path = "./petstore-name-mapping" }
+```
+
+## Documentation for API Endpoints
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+*FakeApi* | [**get_parameter_name_mapping**](docs/FakeApi.md#get_parameter_name_mapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
+
+
+## Documentation For Models
+
+ - [PropertyNameMapping](docs/PropertyNameMapping.md)
+
+
+To get access to the crate's generated documentation, use:
+
+```
+cargo doc --open
+```
+
+## Author
+
+
+
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/docs/FakeApi.md b/samples/client/petstore/rust/reqwest/name-mapping/docs/FakeApi.md
new file mode 100644
index 00000000000..2b99c691775
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/docs/FakeApi.md
@@ -0,0 +1,41 @@
+# \FakeApi
+
+All URIs are relative to *http://petstore.swagger.io/v2*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**get_parameter_name_mapping**](FakeApi.md#get_parameter_name_mapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
+
+
+
+## get_parameter_name_mapping
+
+> get_parameter_name_mapping(underscore_type, r#type, type_with_underscore, dash_type, http_debug_option)
+parameter name mapping test
+
+### Parameters
+
+
+Name | Type | Description | Required | Notes
+------------- | ------------- | ------------- | ------------- | -------------
+**underscore_type** | **i64** | _type | [required] |
+**r#type** | **String** | type | [required] |
+**type_with_underscore** | **String** | type_ | [required] |
+**dash_type** | **String** | -type | [required] |
+**http_debug_option** | **String** | http debug option (to test parameter naming option) | [required] |
+
+### Return type
+
+ (empty response body)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+- **Content-Type**: Not defined
+- **Accept**: Not defined
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/docs/PropertyNameMapping.md b/samples/client/petstore/rust/reqwest/name-mapping/docs/PropertyNameMapping.md
new file mode 100644
index 00000000000..5d2d9272bc8
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/docs/PropertyNameMapping.md
@@ -0,0 +1,15 @@
+# PropertyNameMapping
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**http_debug_operation** | Option<**String**> | | [optional]
+**underscore_type** | Option<**String**> | | [optional]
+**r#type** | Option<**String**> | | [optional]
+**type_with_underscore** | Option<**String**> | | [optional]
+**dash_type** | Option<**String**> | | [optional]
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/git_push.sh b/samples/client/petstore/rust/reqwest/name-mapping/git_push.sh
new file mode 100644
index 00000000000..f53a75d4fab
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/git_push.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
+#
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
+
+git_user_id=$1
+git_repo_id=$2
+release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="github.com"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
+
+if [ "$git_user_id" = "" ]; then
+ git_user_id="GIT_USER_ID"
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
+fi
+
+if [ "$git_repo_id" = "" ]; then
+ git_repo_id="GIT_REPO_ID"
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
+fi
+
+if [ "$release_note" = "" ]; then
+ release_note="Minor update"
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
+fi
+
+# Initialize the local directory as a Git repository
+git init
+
+# Adds the files in the local repository and stages them for commit.
+git add .
+
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
+git commit -m "$release_note"
+
+# Sets the new remote
+git_remote=$(git remote)
+if [ "$git_remote" = "" ]; then # git remote not defined
+
+ if [ "$GIT_TOKEN" = "" ]; then
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
+ else
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
+ fi
+
+fi
+
+git pull origin master
+
+# Pushes (Forces) the changes in the local repository up to the remote repository
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
+git push origin master 2>&1 | grep -v 'To https'
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs
new file mode 100644
index 00000000000..76cc4bf042b
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs
@@ -0,0 +1,53 @@
+/*
+ * rust test
+ *
+ * rust name mapping test
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+
+
+#[derive(Debug, Clone)]
+pub struct Configuration {
+ pub base_path: String,
+ pub user_agent: Option,
+ pub client: reqwest::Client,
+ pub basic_auth: Option,
+ pub oauth_access_token: Option,
+ pub bearer_access_token: Option,
+ pub api_key: Option,
+ // TODO: take an oauth2 token source, similar to the go one
+}
+
+pub type BasicAuth = (String, Option);
+
+#[derive(Debug, Clone)]
+pub struct ApiKey {
+ pub prefix: Option,
+ pub key: String,
+}
+
+
+impl Configuration {
+ pub fn new() -> Configuration {
+ Configuration::default()
+ }
+}
+
+impl Default for Configuration {
+ fn default() -> Self {
+ Configuration {
+ base_path: "http://petstore.swagger.io/v2".to_owned(),
+ user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
+ client: reqwest::Client::new(),
+ basic_auth: None,
+ oauth_access_token: None,
+ bearer_access_token: None,
+ api_key: None,
+
+ }
+ }
+}
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/fake_api.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/fake_api.rs
new file mode 100644
index 00000000000..ccb58f77afc
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/fake_api.rs
@@ -0,0 +1,57 @@
+/*
+ * rust test
+ *
+ * rust name mapping test
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+
+use reqwest;
+
+use crate::apis::ResponseContent;
+use super::{Error, configuration};
+
+
+/// struct for typed errors of method [`get_parameter_name_mapping`]
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum GetParameterNameMappingError {
+ UnknownValue(serde_json::Value),
+}
+
+
+pub fn get_parameter_name_mapping(configuration: &configuration::Configuration, underscore_type: i64, r#type: &str, type_with_underscore: &str, dash_type: &str, http_debug_option: &str) -> Result<(), Error> {
+ let local_var_configuration = configuration;
+
+ let local_var_client = &local_var_configuration.client;
+
+ let local_var_uri_str = format!("{}/fake/parameter-name-mapping", local_var_configuration.base_path);
+ let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
+
+ local_var_req_builder = local_var_req_builder.query(&[("type", &r#type.to_string())]);
+ local_var_req_builder = local_var_req_builder.query(&[("http_debug_option", &http_debug_option.to_string())]);
+ if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
+ local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
+ }
+ local_var_req_builder = local_var_req_builder.header("_type", underscore_type.to_string());
+ local_var_req_builder = local_var_req_builder.header("type_", type_with_underscore.to_string());
+ local_var_req_builder = local_var_req_builder.header("-type", dash_type.to_string());
+
+ let local_var_req = local_var_req_builder.build()?;
+ let mut local_var_resp = local_var_client.execute(local_var_req)?;
+
+ let local_var_status = local_var_resp.status();
+ let local_var_content = local_var_resp.text()?;
+
+ if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
+ Ok(())
+ } else {
+ let local_var_entity: Option = serde_json::from_str(&local_var_content).ok();
+ let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
+ Err(Error::ResponseError(local_var_error))
+ }
+}
+
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/mod.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/mod.rs
new file mode 100644
index 00000000000..006006c1ad1
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/mod.rs
@@ -0,0 +1,95 @@
+use std::error;
+use std::fmt;
+
+#[derive(Debug, Clone)]
+pub struct ResponseContent {
+ pub status: reqwest::StatusCode,
+ pub content: String,
+ pub entity: Option,
+}
+
+#[derive(Debug)]
+pub enum Error {
+ Reqwest(reqwest::Error),
+ Serde(serde_json::Error),
+ Io(std::io::Error),
+ ResponseError(ResponseContent),
+}
+
+impl fmt::Display for Error {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let (module, e) = match self {
+ Error::Reqwest(e) => ("reqwest", e.to_string()),
+ Error::Serde(e) => ("serde", e.to_string()),
+ Error::Io(e) => ("IO", e.to_string()),
+ Error::ResponseError(e) => ("response", format!("status code {}", e.status)),
+ };
+ write!(f, "error in {}: {}", module, e)
+ }
+}
+
+impl error::Error for Error {
+ fn source(&self) -> Option<&(dyn error::Error + 'static)> {
+ Some(match self {
+ Error::Reqwest(e) => e,
+ Error::Serde(e) => e,
+ Error::Io(e) => e,
+ Error::ResponseError(_) => return None,
+ })
+ }
+}
+
+impl From for Error {
+ fn from(e: reqwest::Error) -> Self {
+ Error::Reqwest(e)
+ }
+}
+
+impl From for Error {
+ fn from(e: serde_json::Error) -> Self {
+ Error::Serde(e)
+ }
+}
+
+impl From for Error {
+ fn from(e: std::io::Error) -> Self {
+ Error::Io(e)
+ }
+}
+
+pub fn urlencode>(s: T) -> String {
+ ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
+}
+
+pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
+ if let serde_json::Value::Object(object) = value {
+ let mut params = vec![];
+
+ for (key, value) in object {
+ match value {
+ serde_json::Value::Object(_) => params.append(&mut parse_deep_object(
+ &format!("{}[{}]", prefix, key),
+ value,
+ )),
+ serde_json::Value::Array(array) => {
+ for (i, value) in array.iter().enumerate() {
+ params.append(&mut parse_deep_object(
+ &format!("{}[{}][{}]", prefix, key, i),
+ value,
+ ));
+ }
+ },
+ serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
+ _ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
+ }
+ }
+
+ return params;
+ }
+
+ unimplemented!("Only objects are supported with style=deepObject")
+}
+
+pub mod fake_api;
+
+pub mod configuration;
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/lib.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/lib.rs
new file mode 100644
index 00000000000..c1dd666f795
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/src/lib.rs
@@ -0,0 +1,10 @@
+#[macro_use]
+extern crate serde_derive;
+
+extern crate serde;
+extern crate serde_json;
+extern crate url;
+extern crate reqwest;
+
+pub mod apis;
+pub mod models;
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/models/mod.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/models/mod.rs
new file mode 100644
index 00000000000..05467d60624
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/src/models/mod.rs
@@ -0,0 +1,2 @@
+pub mod property_name_mapping;
+pub use self::property_name_mapping::PropertyNameMapping;
diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/models/property_name_mapping.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/models/property_name_mapping.rs
new file mode 100644
index 00000000000..6466e39c00a
--- /dev/null
+++ b/samples/client/petstore/rust/reqwest/name-mapping/src/models/property_name_mapping.rs
@@ -0,0 +1,40 @@
+/*
+ * rust test
+ *
+ * rust name mapping test
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ * Generated by: https://openapi-generator.tech
+ */
+
+
+
+
+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+pub struct PropertyNameMapping {
+ #[serde(rename = "http_debug_operation", skip_serializing_if = "Option::is_none")]
+ pub http_debug_operation: Option,
+ #[serde(rename = "_type", skip_serializing_if = "Option::is_none")]
+ pub underscore_type: Option,
+ #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
+ pub r#type: Option,
+ #[serde(rename = "type_", skip_serializing_if = "Option::is_none")]
+ pub type_with_underscore: Option,
+ #[serde(rename = "-type", skip_serializing_if = "Option::is_none")]
+ pub dash_type: Option,
+}
+
+impl PropertyNameMapping {
+ pub fn new() -> PropertyNameMapping {
+ PropertyNameMapping {
+ http_debug_operation: None,
+ underscore_type: None,
+ r#type: None,
+ type_with_underscore: None,
+ dash_type: None,
+ }
+ }
+}
+
+
diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml
index 57fb938994a..1c262d99332 100644
--- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml
+++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/Cargo.toml
@@ -12,7 +12,7 @@ serde_derive = "^1.0"
serde_with = "^2.0"
serde_json = "^1.0"
url = "^2.2"
-uuid = { version = "^1.0", features = ["serde"] }
+uuid = { version = "^1.0", features = ["serde", "v4"] }
reqwest-middleware = "0.2.0"
[dependencies.reqwest]
version = "^0.11"
diff --git a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml
index 5bae0367117..a9086df17e0 100644
--- a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml
+++ b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml
@@ -12,7 +12,7 @@ serde_derive = "^1.0"
serde_with = "^2.0"
serde_json = "^1.0"
url = "^2.2"
-uuid = { version = "^1.0", features = ["serde"] }
+uuid = { version = "^1.0", features = ["serde", "v4"] }
[dependencies.reqwest]
version = "^0.11"
features = ["json", "multipart"]
diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml
index beef9b801cf..031c64aab0f 100644
--- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml
+++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/Cargo.toml
@@ -12,7 +12,7 @@ serde_derive = "^1.0"
serde_with = "^2.0"
serde_json = "^1.0"
url = "^2.2"
-uuid = { version = "^1.0", features = ["serde"] }
+uuid = { version = "^1.0", features = ["serde", "v4"] }
aws-sigv4 = "0.3.0"
http = "0.2.5"
secrecy = "0.8.0"
diff --git a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml
index ca255dfed88..ae0098206eb 100644
--- a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml
+++ b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml
@@ -12,5 +12,5 @@ serde_derive = "^1.0"
serde_with = "^2.0"
serde_json = "^1.0"
url = "^2.2"
-uuid = { version = "^1.0", features = ["serde"] }
+uuid = { version = "^1.0", features = ["serde", "v4"] }
reqwest = "~0.9"