Skip to content

Commit

Permalink
Revert "[Rust] Support formParams and fix list-params." (OpenAPITools…
Browse files Browse the repository at this point in the history
…#1732)

* Revert "Disable rust-reqwest petstore test"

This reverts commit 9e1cce2.

* Revert "Fix various CI issues (OpenAPITools#1722)"

This reverts commit 77270a0.

* Revert "[Rust] Support formParams and fix list-params. (OpenAPITools#1678)"

This reverts commit 4a494b4.
  • Loading branch information
wing328 authored Dec 22, 2018
1 parent a869d66 commit 76784f2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl {{{classname}}}Client {
pub trait {{{classname}}} {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isListContainer}}Vec<{{/isListContainer}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#isListContainer}}>{{/isListContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
{{/operation}}
{{/operations}}
}
Expand All @@ -30,23 +30,16 @@ pub trait {{{classname}}} {
impl {{{classname}}} for {{{classname}}}Client {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isListContainer}}Vec<{{/isListContainer}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#isListContainer}}>{{/isListContainer}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
{{#hasFormParams}}
let form = [
{{#formParams}}
("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string()),
{{/formParams}}
];
{{/hasFormParams}}
let query_string = {
let mut query = ::url::form_urlencoded::Serializer::new(String::new());
{{#queryParams}}
{{#queryParams}}
query.append_pair("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(","){{/isListContainer}}.to_string());
{{/queryParams}}
{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}
{{/queryParams}}
{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let val = match apikey.prefix {
Expand All @@ -55,7 +48,7 @@ impl {{{classname}}} for {{{classname}}}Client {
};
query.append_pair("{{{keyParamName}}}".to_owned(), val);
}
{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}}
{{/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}});
Expand Down Expand Up @@ -103,10 +96,6 @@ impl {{{classname}}} for {{{classname}}}Client {
{{/bodyParams}}
{{/hasBodyParam}}

{{#hasFormParams}}
req_builder = req_builder.form(&form);
{{/hasFormParams}}

// send request
let req = req_builder.build()?;

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0-SNAPSHOT
3.3.4-SNAPSHOT
42 changes: 12 additions & 30 deletions samples/client/petstore/rust-reqwest/src/apis/pet_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ impl PetApiClient {
pub trait PetApi {
fn add_pet(&self, pet: ::models::Pet) -> Result<(), Error>;
fn delete_pet(&self, pet_id: i64, api_key: &str) -> Result<(), Error>;
fn find_pets_by_status(&self, status: Vec<Vec<String>>) -> Result<Vec<::models::Pet>, Error>;
fn find_pets_by_tags(&self, tags: Vec<Vec<String>>) -> Result<Vec<::models::Pet>, Error>;
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<::models::Pet>, Error>;
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<::models::Pet>, 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_with_form(&self, pet_id: i64, name: &str, status: &str) -> Result<(), Error>;
Expand All @@ -46,7 +46,7 @@ impl PetApi for PetApiClient {

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);
Expand All @@ -65,7 +65,6 @@ impl PetApi for PetApiClient {

req_builder = req_builder.json(&pet);


// send request
let req = req_builder.build()?;

Expand All @@ -79,7 +78,7 @@ impl PetApi for PetApiClient {

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);
Expand All @@ -98,22 +97,21 @@ impl PetApi for PetApiClient {
};



// send request
let req = req_builder.build()?;

client.execute(req)?.error_for_status()?;
Ok(())
}

fn find_pets_by_status(&self, status: Vec<Vec<String>>) -> Result<Vec<::models::Pet>, Error> {
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<::models::Pet>, 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.append_pair("status", &status.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());

query.finish()
};
let uri_str = format!("{}/pet/findByStatus?{}", configuration.base_path, query_string);
Expand All @@ -131,21 +129,20 @@ impl PetApi for PetApiClient {
};



// send request
let req = req_builder.build()?;

Ok(client.execute(req)?.error_for_status()?.json()?)
}

fn find_pets_by_tags(&self, tags: Vec<Vec<String>>) -> Result<Vec<::models::Pet>, Error> {
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<::models::Pet>, 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.append_pair("tags", &tags.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string());

query.finish()
};
let uri_str = format!("{}/pet/findByTags?{}", configuration.base_path, query_string);
Expand All @@ -163,7 +160,6 @@ impl PetApi for PetApiClient {
};



// send request
let req = req_builder.build()?;

Expand All @@ -176,7 +172,7 @@ impl PetApi for PetApiClient {

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);
Expand All @@ -200,7 +196,6 @@ impl PetApi for PetApiClient {




// send request
let req = req_builder.build()?;

Expand All @@ -213,7 +208,7 @@ impl PetApi for PetApiClient {

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);
Expand All @@ -232,7 +227,6 @@ impl PetApi for PetApiClient {

req_builder = req_builder.json(&pet);


// send request
let req = req_builder.build()?;

Expand All @@ -244,13 +238,9 @@ impl PetApi for PetApiClient {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;

let form = [
("name", &name.to_string()),
("status", &status.to_string()),
];
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);
Expand All @@ -268,8 +258,6 @@ impl PetApi for PetApiClient {
};


req_builder = req_builder.form(&form);

// send request
let req = req_builder.build()?;

Expand All @@ -281,13 +269,9 @@ impl PetApi for PetApiClient {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;

let form = [
("additionalMetadata", &additional_metadata.to_string()),
("file", &file.to_string()),
];
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);
Expand All @@ -305,8 +289,6 @@ impl PetApi for PetApiClient {
};


req_builder = req_builder.form(&form);

// send request
let req = req_builder.build()?;

Expand Down
12 changes: 4 additions & 8 deletions samples/client/petstore/rust-reqwest/src/apis/store_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl StoreApi for StoreApiClient {

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);
Expand All @@ -56,7 +56,6 @@ impl StoreApi for StoreApiClient {




// send request
let req = req_builder.build()?;

Expand All @@ -70,7 +69,7 @@ impl StoreApi for StoreApiClient {

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);
Expand All @@ -94,7 +93,6 @@ impl StoreApi for StoreApiClient {




// send request
let req = req_builder.build()?;

Expand All @@ -107,7 +105,7 @@ impl StoreApi for StoreApiClient {

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);
Expand All @@ -121,7 +119,6 @@ impl StoreApi for StoreApiClient {




// send request
let req = req_builder.build()?;

Expand All @@ -134,7 +131,7 @@ impl StoreApi for StoreApiClient {

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);
Expand All @@ -149,7 +146,6 @@ impl StoreApi for StoreApiClient {

req_builder = req_builder.json(&order);


// send request
let req = req_builder.build()?;

Expand Down
Loading

0 comments on commit 76784f2

Please sign in to comment.