From 888068d122fbfae7b50f962caa542129cd4d5f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Courtine?= Date: Fri, 1 Feb 2019 08:02:16 +0100 Subject: [PATCH] Rust reqwest improve (#1890) * Resolves #525 for Rust client generator with reqwest library. * Use Reqwest "query" method to generate query URL. * urlencode URL string parameters. * Generate rust-reqwest client, and verify it compiles and work as intended. * Map file params (to "&std::path::Path") and support multipart operations (with file params) in Reqwest library. * Cleanup: template compression to remove unecessary blank lines in generated code. --- .../codegen/languages/RustClientCodegen.java | 11 +- .../main/resources/rust/reqwest/api.mustache | 81 ++++---- .../resources/rust/reqwest/api_mod.mustache | 11 ++ .../rust-reqwest/.openapi-generator/VERSION | 2 +- .../petstore/rust-reqwest/docs/PetApi.md | 10 +- .../petstore/rust-reqwest/docs/StoreApi.md | 4 +- .../petstore/rust-reqwest/docs/UserApi.md | 16 +- .../petstore/rust-reqwest/src/apis/mod.rs | 11 ++ .../petstore/rust-reqwest/src/apis/pet_api.rs | 180 +++++++++--------- .../rust-reqwest/src/apis/store_api.rs | 79 ++++---- .../rust-reqwest/src/apis/user_api.rs | 171 ++++++++--------- .../petstore/rust/.openapi-generator/VERSION | 2 +- samples/client/petstore/rust/docs/PetApi.md | 10 +- samples/client/petstore/rust/docs/StoreApi.md | 4 +- samples/client/petstore/rust/docs/UserApi.md | 16 +- .../client/petstore/rust/src/apis/pet_api.rs | 16 +- .../petstore/rust/src/apis/store_api.rs | 6 +- .../client/petstore/rust/src/apis/user_api.rs | 24 +-- 18 files changed, 324 insertions(+), 330 deletions(-) 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 c6f9da87a6c..c3636e215d6 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 @@ -119,8 +119,11 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("date", "string"); typeMapping.put("DateTime", "String"); typeMapping.put("password", "String"); - // TODO(farcaller): map file - typeMapping.put("file", "::models::File"); + // TODO(bcourtine): review file mapping. + // I tried to map as "std::io::File", but Reqwest multipart file requires a "AsRef" param. + // Getting a file from a Path is simple, but the opposite is difficult. So I map as "std::path::Path". + // Reference is required here because Path does not implement the "Sized" trait. + typeMapping.put("file", "&std::path::Path"); typeMapping.put("binary", "::models::File"); typeMapping.put("ByteArray", "String"); typeMapping.put("object", "Value"); @@ -379,7 +382,6 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { Map objectMap = (Map) objs.get("operations"); @SuppressWarnings("unchecked") List operations = (List) objectMap.get("operation"); - Set headerKeys = new HashSet<>(); for (CodegenOperation operation : operations) { // http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put) if (HYPER_LIBRARY.equals(getLibrary())) { @@ -439,9 +441,6 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig { }*/ } - additionalProperties.put("headerKeys", headerKeys); - additionalProperties.putIfAbsent("authHeaderKey", "api-key"); - return objs; } 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 091c40fe625..41cbe20f041 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -4,7 +4,7 @@ use std::borrow::Borrow; use reqwest; -use super::{Error, configuration}; +use super::{Error, configuration, urlencode}; pub struct {{{classname}}}Client { configuration: Rc, @@ -26,7 +26,6 @@ pub trait {{{classname}}} { {{/operations}} } - impl {{{classname}}} for {{{classname}}}Client { {{#operations}} {{#operation}} @@ -34,39 +33,29 @@ impl {{{classname}}} for {{{classname}}}Client { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); -{{#queryParams}} - query.append_pair("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string()); -{{/queryParams}} -{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}} - if let Some(ref apikey) = configuration.api_key { - let key = apikey.key.clone(); - let val = match apikey.prefix { - Some(ref prefix) => format!("{} {}", prefix, key), - None => key, - }; - query.append_pair("{{{keyParamName}}}".to_owned(), val); - } -{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}} - query.finish() - }; - let uri_str = format!("{}{{{path}}}?{}", configuration.base_path, query_string{{#pathParams}}, {{{baseName}}}={{{paramName}}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{/pathParams}}); - + let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}urlencode({{/isString}}{{{paramName}}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{#isString}}){{/isString}}{{/pathParams}}); let mut req_builder = client.{{{httpMethod}}}(uri_str.as_str()); + {{#queryParams}} + req_builder = req_builder.query(&[("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string())]); + {{/queryParams}} + {{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}} + if let Some(ref apikey) = configuration.api_key { + let key = apikey.key.clone(); + let val = match apikey.prefix { + Some(ref prefix) => format!("{} {}", prefix, key), + None => key, + }; + req_builder = req_builder.query(&[("{{{keyParamName}}}", val)]); + } + {{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}} if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - {{#hasHeaderParams}} - {{#headerParams}} + {{#hasHeaderParams}}{{#headerParams}} req_builder = req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); - {{/headerParams}} - {{/hasHeaderParams}} - - {{#hasAuthMethods}} - {{#authMethods}} + {{/headerParams}}{{/hasHeaderParams}} + {{#hasAuthMethods}}{{#authMethods}} {{#isApiKey}}{{#isKeyInHeader}} if let Some(ref apikey) = configuration.api_key { let key = apikey.key.clone(); @@ -87,14 +76,34 @@ impl {{{classname}}} for {{{classname}}}Client { req_builder = req_builder.bearer_auth(token.to_owned()); }; {{/isOAuth}} - {{/authMethods}} - {{/hasAuthMethods}} - - {{#hasBodyParam}} - {{#bodyParams}} + {{/authMethods}}{{/hasAuthMethods}} + {{#isMultipart}}{{#hasFormParams}} + let form = reqwest::multipart::Form::new() + {{#formParams}} + {{#isFile}} + .file("{{{baseName}}}", {{{paramName}}})?{{#-last}};{{/-last}} + {{/isFile}} + {{^isFile}} + .text("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()){{#-last}};{{/-last}} + {{/isFile}} + {{/formParams}} + req_builder = req_builder.multipart(form); + {{/hasFormParams}}{{/isMultipart}} + {{^isMultipart}}{{#hasFormParams}} + let mut form_params = std::collections::HashMap::new(); + {{#formParams}} + {{#isFile}} + form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); + {{/isFile}} + {{^isFile}} + form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string()); + {{/isFile}} + {{/formParams}} + req_builder = req_builder.form(&form_params); + {{/hasFormParams}}{{/isMultipart}} + {{#hasBodyParam}}{{#bodyParams}} req_builder = req_builder.json(&{{{paramName}}}); - {{/bodyParams}} - {{/hasBodyParam}} + {{/bodyParams}}{{/hasBodyParam}} // send request let req = req_builder.build()?; diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache index 483e2c388f8..80c30e7dcb6 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache @@ -5,6 +5,7 @@ use serde_json; pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), + Io(std::io::Error), } impl From for Error { @@ -19,6 +20,16 @@ impl From for Error { } } +impl From for Error { + fn from(e: std::io::Error) -> Self { + return Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + use super::models::*; {{#apiInfo}} diff --git a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION b/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION index d077ffb477a..afa63656064 100644 --- a/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION +++ b/samples/client/petstore/rust-reqwest/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.4-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust-reqwest/docs/PetApi.md b/samples/client/petstore/rust-reqwest/docs/PetApi.md index ea3b5825627..89a95eebaf1 100644 --- a/samples/client/petstore/rust-reqwest/docs/PetApi.md +++ b/samples/client/petstore/rust-reqwest/docs/PetApi.md @@ -15,7 +15,7 @@ Method | HTTP request | Description # **add_pet** -> add_pet(ctx, pet) +> add_pet(ctx, body) Add a new pet to the store ### Required Parameters @@ -23,7 +23,7 @@ Add a new pet to the store Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context containing the authentication | nil if no authentication - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -160,7 +160,7 @@ Name | Type | Description | Notes [[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) # **update_pet** -> update_pet(ctx, pet) +> update_pet(ctx, body) Update an existing pet ### Required Parameters @@ -168,7 +168,7 @@ Update an existing pet Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context containing the authentication | nil if no authentication - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -240,7 +240,7 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **pet_id** | **i64**| ID of pet to update | **additional_metadata** | **String**| Additional data to pass to server | - **file** | **::models::File**| file to upload | + **file** | **&std::path::Path**| file to upload | ### Return type diff --git a/samples/client/petstore/rust-reqwest/docs/StoreApi.md b/samples/client/petstore/rust-reqwest/docs/StoreApi.md index a4555a25565..7451dacfd6d 100644 --- a/samples/client/petstore/rust-reqwest/docs/StoreApi.md +++ b/samples/client/petstore/rust-reqwest/docs/StoreApi.md @@ -89,14 +89,14 @@ No authorization required [[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) # **place_order** -> ::models::Order place_order(order) +> ::models::Order place_order(body) Place an order for a pet ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/rust-reqwest/docs/UserApi.md b/samples/client/petstore/rust-reqwest/docs/UserApi.md index 05d2aeccaa3..c6353d423e3 100644 --- a/samples/client/petstore/rust-reqwest/docs/UserApi.md +++ b/samples/client/petstore/rust-reqwest/docs/UserApi.md @@ -15,7 +15,7 @@ Method | HTTP request | Description # **create_user** -> create_user(user) +> create_user(body) Create user This can only be done by the logged in user. @@ -24,7 +24,7 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -42,14 +42,14 @@ No authorization required [[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) # **create_users_with_array_input** -> create_users_with_array_input(user) +> create_users_with_array_input(body) Creates list of users with given input array ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**Vec<::models::User>**](array.md)| List of user object | + **body** | [**Vec<::models::User>**](array.md)| List of user object | ### Return type @@ -67,14 +67,14 @@ No authorization required [[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) # **create_users_with_list_input** -> create_users_with_list_input(user) +> create_users_with_list_input(body) Creates list of users with given input array ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**Vec<::models::User>**](array.md)| List of user object | + **body** | [**Vec<::models::User>**](array.md)| List of user object | ### Return type @@ -192,7 +192,7 @@ No authorization required [[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) # **update_user** -> update_user(username, user) +> update_user(username, body) Updated user This can only be done by the logged in user. @@ -202,7 +202,7 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/rust-reqwest/src/apis/mod.rs b/samples/client/petstore/rust-reqwest/src/apis/mod.rs index 7494e25ce9e..99d5b323764 100644 --- a/samples/client/petstore/rust-reqwest/src/apis/mod.rs +++ b/samples/client/petstore/rust-reqwest/src/apis/mod.rs @@ -5,6 +5,7 @@ use serde_json; pub enum Error { Reqwest(reqwest::Error), Serde(serde_json::Error), + Io(std::io::Error), } impl From for Error { @@ -19,6 +20,16 @@ impl From for Error { } } +impl From for Error { + fn from(e: std::io::Error) -> Self { + return Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + use super::models::*; mod pet_api; diff --git a/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs b/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs index 7771c6568d6..1f1e9095ce6 100644 --- a/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs +++ b/samples/client/petstore/rust-reqwest/src/apis/pet_api.rs @@ -13,7 +13,7 @@ use std::borrow::Borrow; use reqwest; -use super::{Error, configuration}; +use super::{Error, configuration, urlencode}; pub struct PetApiClient { configuration: Rc, @@ -28,42 +28,40 @@ impl PetApiClient { } pub trait PetApi { - fn add_pet(&self, pet: ::models::Pet) -> Result<(), Error>; + fn add_pet(&self, body: ::models::Pet) -> Result<(), Error>; fn delete_pet(&self, pet_id: i64, api_key: &str) -> Result<(), Error>; fn find_pets_by_status(&self, status: Vec) -> Result, Error>; fn find_pets_by_tags(&self, tags: Vec) -> Result, Error>; fn get_pet_by_id(&self, pet_id: i64) -> Result<::models::Pet, Error>; - fn update_pet(&self, pet: ::models::Pet) -> Result<(), Error>; + fn update_pet(&self, body: ::models::Pet) -> Result<(), Error>; fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Result<(), Error>; - fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Result<::models::ApiResponse, Error>; + fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: &std::path::Path) -> Result<::models::ApiResponse, Error>; } - impl PetApi for PetApiClient { - fn add_pet(&self, pet: ::models::Pet) -> Result<(), Error> { + fn add_pet(&self, body: ::models::Pet) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/pet?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/pet", configuration.base_path); let mut req_builder = client.post(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - - req_builder = req_builder.json(&pet); + + + + + req_builder = req_builder.json(&body); + // send request let req = req_builder.build()?; @@ -76,26 +74,25 @@ impl PetApi for PetApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id); - + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); let mut req_builder = client.delete(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - + req_builder = req_builder.header("api_key", api_key.to_string()); - + + if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - + + + + // send request let req = req_builder.build()?; @@ -108,26 +105,24 @@ impl PetApi for PetApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - query.append_pair("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string()); - - query.finish() - }; - let uri_str = format!("{}/pet/findByStatus?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/pet/findByStatus", configuration.base_path); let mut req_builder = client.get(uri_str.as_str()); + req_builder = req_builder.query(&[("status", &status.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - + + + + // send request let req = req_builder.build()?; @@ -139,26 +134,24 @@ impl PetApi for PetApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - query.append_pair("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string()); - - query.finish() - }; - let uri_str = format!("{}/pet/findByTags?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/pet/findByTags", configuration.base_path); let mut req_builder = client.get(uri_str.as_str()); + req_builder = req_builder.query(&[("tags", &tags.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - + + + + // send request let req = req_builder.build()?; @@ -170,20 +163,15 @@ impl PetApi for PetApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id); - + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); let mut req_builder = client.get(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref apikey) = configuration.api_key { let key = apikey.key.clone(); @@ -194,7 +182,10 @@ impl PetApi for PetApiClient { req_builder = req_builder.header("api_key", val); }; - + + + + // send request let req = req_builder.build()?; @@ -202,30 +193,29 @@ impl PetApi for PetApiClient { Ok(client.execute(req)?.error_for_status()?.json()?) } - fn update_pet(&self, pet: ::models::Pet) -> Result<(), Error> { + fn update_pet(&self, body: ::models::Pet) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/pet?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/pet", configuration.base_path); let mut req_builder = client.put(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - - req_builder = req_builder.json(&pet); + + + + + req_builder = req_builder.json(&body); + // send request let req = req_builder.build()?; @@ -238,25 +228,28 @@ impl PetApi for PetApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/pet/{petId}?{}", configuration.base_path, query_string, petId=pet_id); - + let uri_str = format!("{}/pet/{petId}", configuration.base_path, petId=pet_id); let mut req_builder = client.post(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - + + + + let mut form_params = std::collections::HashMap::new(); + form_params.insert("name", name.to_string()); + form_params.insert("status", status.to_string()); + req_builder = req_builder.form(&form_params); + + // send request let req = req_builder.build()?; @@ -265,29 +258,32 @@ impl PetApi for PetApiClient { Ok(()) } - fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Result<::models::ApiResponse, Error> { + fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: &std::path::Path) -> Result<::models::ApiResponse, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/pet/{petId}/uploadImage?{}", configuration.base_path, query_string, petId=pet_id); - + let uri_str = format!("{}/pet/{petId}/uploadImage", configuration.base_path, petId=pet_id); let mut req_builder = client.post(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref token) = configuration.oauth_access_token { req_builder = req_builder.bearer_auth(token.to_owned()); }; - + + + + let mut form_params = std::collections::HashMap::new(); + form_params.insert("additionalMetadata", additional_metadata.to_string()); + form_params.insert("file", unimplemented!("File form param not supported with x-www-form-urlencoded content")); + req_builder = req_builder.form(&form_params); + + // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust-reqwest/src/apis/store_api.rs b/samples/client/petstore/rust-reqwest/src/apis/store_api.rs index 90a719df929..d6cec820256 100644 --- a/samples/client/petstore/rust-reqwest/src/apis/store_api.rs +++ b/samples/client/petstore/rust-reqwest/src/apis/store_api.rs @@ -13,7 +13,7 @@ use std::borrow::Borrow; use reqwest; -use super::{Error, configuration}; +use super::{Error, configuration, urlencode}; pub struct StoreApiClient { configuration: Rc, @@ -31,30 +31,26 @@ pub trait StoreApi { fn delete_order(&self, order_id: &str) -> Result<(), Error>; fn get_inventory(&self, ) -> Result<::std::collections::HashMap, Error>; fn get_order_by_id(&self, order_id: i64) -> Result<::models::Order, Error>; - fn place_order(&self, order: ::models::Order) -> Result<::models::Order, Error>; + fn place_order(&self, body: ::models::Order) -> Result<::models::Order, Error>; } - impl StoreApi for StoreApiClient { fn delete_order(&self, order_id: &str) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id); - + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=urlencode(order_id)); let mut req_builder = client.delete(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - + + + + + // send request let req = req_builder.build()?; @@ -67,20 +63,15 @@ impl StoreApi for StoreApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/store/inventory?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/store/inventory", configuration.base_path); let mut req_builder = client.get(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - + + if let Some(ref apikey) = configuration.api_key { let key = apikey.key.clone(); @@ -91,7 +82,10 @@ impl StoreApi for StoreApiClient { req_builder = req_builder.header("api_key", val); }; - + + + + // send request let req = req_builder.build()?; @@ -103,21 +97,18 @@ impl StoreApi for StoreApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/store/order/{orderId}?{}", configuration.base_path, query_string, orderId=order_id); - + let uri_str = format!("{}/store/order/{orderId}", configuration.base_path, orderId=order_id); let mut req_builder = client.get(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - + + + + + // send request let req = req_builder.build()?; @@ -125,26 +116,24 @@ impl StoreApi for StoreApiClient { Ok(client.execute(req)?.error_for_status()?.json()?) } - fn place_order(&self, order: ::models::Order) -> Result<::models::Order, Error> { + fn place_order(&self, body: ::models::Order) -> Result<::models::Order, Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/store/order?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/store/order", configuration.base_path); let mut req_builder = client.post(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - - req_builder = req_builder.json(&order); + + + + + + req_builder = req_builder.json(&body); + // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust-reqwest/src/apis/user_api.rs b/samples/client/petstore/rust-reqwest/src/apis/user_api.rs index 8d14e2dc5ce..43fa8c6f804 100644 --- a/samples/client/petstore/rust-reqwest/src/apis/user_api.rs +++ b/samples/client/petstore/rust-reqwest/src/apis/user_api.rs @@ -13,7 +13,7 @@ use std::borrow::Borrow; use reqwest; -use super::{Error, configuration}; +use super::{Error, configuration, urlencode}; pub struct UserApiClient { configuration: Rc, @@ -28,38 +28,35 @@ impl UserApiClient { } pub trait UserApi { - fn create_user(&self, user: ::models::User) -> Result<(), Error>; - fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Result<(), Error>; - fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Result<(), Error>; + fn create_user(&self, body: ::models::User) -> Result<(), Error>; + fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Result<(), Error>; + fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Result<(), Error>; fn delete_user(&self, username: &str) -> Result<(), Error>; fn get_user_by_name(&self, username: &str) -> Result<::models::User, Error>; fn login_user(&self, username: &str, password: &str) -> Result; fn logout_user(&self, ) -> Result<(), Error>; - fn update_user(&self, username: &str, user: ::models::User) -> Result<(), Error>; + fn update_user(&self, username: &str, body: ::models::User) -> Result<(), Error>; } - impl UserApi for UserApiClient { - fn create_user(&self, user: ::models::User) -> Result<(), Error> { + fn create_user(&self, body: ::models::User) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/user?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/user", configuration.base_path); let mut req_builder = client.post(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - - req_builder = req_builder.json(&user); + + + + + + req_builder = req_builder.json(&body); + // send request let req = req_builder.build()?; @@ -68,26 +65,24 @@ impl UserApi for UserApiClient { Ok(()) } - fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Result<(), Error> { + fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/user/createWithArray?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/user/createWithArray", configuration.base_path); let mut req_builder = client.post(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - - req_builder = req_builder.json(&user); + + + + + + req_builder = req_builder.json(&body); + // send request let req = req_builder.build()?; @@ -96,26 +91,24 @@ impl UserApi for UserApiClient { Ok(()) } - fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Result<(), Error> { + fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/user/createWithList?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/user/createWithList", configuration.base_path); let mut req_builder = client.post(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - - req_builder = req_builder.json(&user); + + + + + + req_builder = req_builder.json(&body); + // send request let req = req_builder.build()?; @@ -128,21 +121,18 @@ impl UserApi for UserApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username); - + let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username)); let mut req_builder = client.delete(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - + + + + + // send request let req = req_builder.build()?; @@ -155,21 +145,18 @@ impl UserApi for UserApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username); - + let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username)); let mut req_builder = client.get(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - + + + + + // send request let req = req_builder.build()?; @@ -181,23 +168,20 @@ impl UserApi for UserApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - query.append_pair("username", &username.to_string()); - query.append_pair("password", &password.to_string()); - - query.finish() - }; - let uri_str = format!("{}/user/login?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/user/login", configuration.base_path); let mut req_builder = client.get(uri_str.as_str()); + req_builder = req_builder.query(&[("username", &username.to_string())]); + req_builder = req_builder.query(&[("password", &password.to_string())]); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - + + + + + // send request let req = req_builder.build()?; @@ -209,21 +193,18 @@ impl UserApi for UserApiClient { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/user/logout?{}", configuration.base_path, query_string); - + let uri_str = format!("{}/user/logout", configuration.base_path); let mut req_builder = client.get(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - + + + + + // send request let req = req_builder.build()?; @@ -232,26 +213,24 @@ impl UserApi for UserApiClient { Ok(()) } - fn update_user(&self, username: &str, user: ::models::User) -> Result<(), Error> { + fn update_user(&self, username: &str, body: ::models::User) -> Result<(), Error> { let configuration: &configuration::Configuration = self.configuration.borrow(); let client = &configuration.client; - let query_string = { - let mut query = ::url::form_urlencoded::Serializer::new(String::new()); - - query.finish() - }; - let uri_str = format!("{}/user/{username}?{}", configuration.base_path, query_string, username=username); - + let uri_str = format!("{}/user/{username}", configuration.base_path, username=urlencode(username)); let mut req_builder = client.put(uri_str.as_str()); + if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); } - - - - req_builder = req_builder.json(&user); + + + + + + req_builder = req_builder.json(&body); + // send request let req = req_builder.build()?; diff --git a/samples/client/petstore/rust/.openapi-generator/VERSION b/samples/client/petstore/rust/.openapi-generator/VERSION index d077ffb477a..afa63656064 100644 --- a/samples/client/petstore/rust/.openapi-generator/VERSION +++ b/samples/client/petstore/rust/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.4-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/rust/docs/PetApi.md b/samples/client/petstore/rust/docs/PetApi.md index 333648af894..1603f57f4ee 100644 --- a/samples/client/petstore/rust/docs/PetApi.md +++ b/samples/client/petstore/rust/docs/PetApi.md @@ -15,7 +15,7 @@ Method | HTTP request | Description # **add_pet** -> add_pet(ctx, pet) +> add_pet(ctx, body) Add a new pet to the store ### Required Parameters @@ -23,7 +23,7 @@ Add a new pet to the store Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context containing the authentication | nil if no authentication - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -160,7 +160,7 @@ Name | Type | Description | Notes [[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) # **update_pet** -> update_pet(ctx, pet) +> update_pet(ctx, body) Update an existing pet ### Required Parameters @@ -168,7 +168,7 @@ Update an existing pet Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context containing the authentication | nil if no authentication - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -240,7 +240,7 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **pet_id** | **i64**| ID of pet to update | **additional_metadata** | **String**| Additional data to pass to server | - **file** | **::models::File**| file to upload | + **file** | **&std::path::Path**| file to upload | ### Return type diff --git a/samples/client/petstore/rust/docs/StoreApi.md b/samples/client/petstore/rust/docs/StoreApi.md index 0563ec09e40..507a0c4300c 100644 --- a/samples/client/petstore/rust/docs/StoreApi.md +++ b/samples/client/petstore/rust/docs/StoreApi.md @@ -89,14 +89,14 @@ No authorization required [[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) # **place_order** -> ::models::Order place_order(order) +> ::models::Order place_order(body) Place an order for a pet ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/rust/docs/UserApi.md b/samples/client/petstore/rust/docs/UserApi.md index ea16bc1218e..69e7bc50627 100644 --- a/samples/client/petstore/rust/docs/UserApi.md +++ b/samples/client/petstore/rust/docs/UserApi.md @@ -15,7 +15,7 @@ Method | HTTP request | Description # **create_user** -> create_user(user) +> create_user(body) Create user This can only be done by the logged in user. @@ -24,7 +24,7 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -42,14 +42,14 @@ No authorization required [[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) # **create_users_with_array_input** -> create_users_with_array_input(user) +> create_users_with_array_input(body) Creates list of users with given input array ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**Vec<::models::User>**](array.md)| List of user object | + **body** | [**Vec<::models::User>**](array.md)| List of user object | ### Return type @@ -67,14 +67,14 @@ No authorization required [[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) # **create_users_with_list_input** -> create_users_with_list_input(user) +> create_users_with_list_input(body) Creates list of users with given input array ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**Vec<::models::User>**](array.md)| List of user object | + **body** | [**Vec<::models::User>**](array.md)| List of user object | ### Return type @@ -192,7 +192,7 @@ No authorization required [[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) # **update_user** -> update_user(username, user) +> update_user(username, body) Updated user This can only be done by the logged in user. @@ -202,7 +202,7 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/rust/src/apis/pet_api.rs b/samples/client/petstore/rust/src/apis/pet_api.rs index 0e8a803c559..b6a9d9c72ac 100644 --- a/samples/client/petstore/rust/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/src/apis/pet_api.rs @@ -31,22 +31,22 @@ impl PetApiClient { } pub trait PetApi { - fn add_pet(&self, pet: ::models::Pet) -> Box>>; + fn add_pet(&self, body: ::models::Pet) -> Box>>; fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box>>; fn find_pets_by_status(&self, status: Vec) -> Box, Error = Error>>; fn find_pets_by_tags(&self, tags: Vec) -> Box, Error = Error>>; fn get_pet_by_id(&self, pet_id: i64) -> Box>>; - fn update_pet(&self, pet: ::models::Pet) -> Box>>; + fn update_pet(&self, body: ::models::Pet) -> Box>>; fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box>>; - fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Box>>; + fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: &std::path::Path) -> Box>>; } implPetApi for PetApiClient { - fn add_pet(&self, pet: ::models::Pet) -> Box>> { + fn add_pet(&self, body: ::models::Pet) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/pet".to_string()) .with_auth(__internal_request::Auth::Oauth) - .with_body_param(pet) + .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } @@ -85,10 +85,10 @@ implPetApi for PetApiClient { .execute(self.configuration.borrow()) } - fn update_pet(&self, pet: ::models::Pet) -> Box>> { + fn update_pet(&self, body: ::models::Pet) -> Box>> { __internal_request::Request::new(hyper::Method::Put, "/pet".to_string()) .with_auth(__internal_request::Auth::Oauth) - .with_body_param(pet) + .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } @@ -103,7 +103,7 @@ implPetApi for PetApiClient { .execute(self.configuration.borrow()) } - fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: ::models::File) -> Box>> { + fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: &std::path::Path) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/pet/{petId}/uploadImage".to_string()) .with_auth(__internal_request::Auth::Oauth) .with_path_param("petId".to_string(), pet_id.to_string()) diff --git a/samples/client/petstore/rust/src/apis/store_api.rs b/samples/client/petstore/rust/src/apis/store_api.rs index dc05931697d..a318fe6e8d5 100644 --- a/samples/client/petstore/rust/src/apis/store_api.rs +++ b/samples/client/petstore/rust/src/apis/store_api.rs @@ -34,7 +34,7 @@ pub trait StoreApi { fn delete_order(&self, order_id: &str) -> Box>>; fn get_inventory(&self, ) -> Box, Error = Error>>; fn get_order_by_id(&self, order_id: i64) -> Box>>; - fn place_order(&self, order: ::models::Order) -> Box>>; + fn place_order(&self, body: ::models::Order) -> Box>>; } @@ -62,9 +62,9 @@ implStoreApi for StoreApiClient { .execute(self.configuration.borrow()) } - fn place_order(&self, order: ::models::Order) -> Box>> { + fn place_order(&self, body: ::models::Order) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/store/order".to_string()) - .with_body_param(order) + .with_body_param(body) .execute(self.configuration.borrow()) } diff --git a/samples/client/petstore/rust/src/apis/user_api.rs b/samples/client/petstore/rust/src/apis/user_api.rs index f0976f80ee1..82ee5749b21 100644 --- a/samples/client/petstore/rust/src/apis/user_api.rs +++ b/samples/client/petstore/rust/src/apis/user_api.rs @@ -31,35 +31,35 @@ impl UserApiClient { } pub trait UserApi { - fn create_user(&self, user: ::models::User) -> Box>>; - fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Box>>; - fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Box>>; + fn create_user(&self, body: ::models::User) -> Box>>; + fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Box>>; + fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Box>>; fn delete_user(&self, username: &str) -> Box>>; fn get_user_by_name(&self, username: &str) -> Box>>; fn login_user(&self, username: &str, password: &str) -> Box>>; fn logout_user(&self, ) -> Box>>; - fn update_user(&self, username: &str, user: ::models::User) -> Box>>; + fn update_user(&self, username: &str, body: ::models::User) -> Box>>; } implUserApi for UserApiClient { - fn create_user(&self, user: ::models::User) -> Box>> { + fn create_user(&self, body: ::models::User) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/user".to_string()) - .with_body_param(user) + .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } - fn create_users_with_array_input(&self, user: Vec<::models::User>) -> Box>> { + fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/user/createWithArray".to_string()) - .with_body_param(user) + .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } - fn create_users_with_list_input(&self, user: Vec<::models::User>) -> Box>> { + fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Box>> { __internal_request::Request::new(hyper::Method::Post, "/user/createWithList".to_string()) - .with_body_param(user) + .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) } @@ -90,10 +90,10 @@ implUserApi for UserApiClient { .execute(self.configuration.borrow()) } - fn update_user(&self, username: &str, user: ::models::User) -> Box>> { + fn update_user(&self, username: &str, body: ::models::User) -> Box>> { __internal_request::Request::new(hyper::Method::Put, "/user/{username}".to_string()) .with_path_param("username".to_string(), username.to_string()) - .with_body_param(user) + .with_body_param(body) .returns_nothing() .execute(self.configuration.borrow()) }