Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ client = [
"serde_urlencoded",
{{/usesUrlEncodedForm}}
{{#hasCallbacks}}
"serde_ignored", "percent-encoding", {{^apiUsesByteArray}}"lazy_static", "regex"{{/apiUsesByteArray}}
"serde_ignored", "percent-encoding", {{^apiUsesByteArray}}"lazy_static", "regex",{{/apiUsesByteArray}}
{{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list below }}
"hyper", "hyper-util/http1", "hyper-util/http2", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let (body_string, multipart_header) = {
let (body_bytes, multipart_header) = {
let mut multipart = Multipart::new();
{{#exts}}
Expand Down Expand Up @@ -43,9 +43,9 @@
Err(err) => return Err(ApiError(format!("Unable to build request: {err}"))),
};

let mut body_string = String::new();
let mut body_bytes = Vec::new();

match fields.read_to_string(&mut body_string) {
match fields.read_to_end(&mut body_bytes) {
Ok(_) => (),
Err(err) => return Err(ApiError(format!("Unable to build body: {err}"))),
}
Expand All @@ -54,10 +54,10 @@

let multipart_header = format!("multipart/form-data;boundary={boundary}");

(body_string, multipart_header)
};
(body_bytes, multipart_header)
};

*request.body_mut() = body_from_string(body_string);
*request.body_mut() = BoxBody::new(Full::new(Bytes::from(body_bytes)));

request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(&multipart_header) {
Ok(h) => h,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{{/x-produces-json}}
{{#x-produces-bytes}}
// Binary Body
let body = String::from_utf8(body.0).expect("Error converting octet stream to string");
*response.body_mut() = BoxBody::new(Full::new(Bytes::from(body.0)));
{{/x-produces-bytes}}
{{#x-produces-plain-text}}
// Plain text Body
Expand All @@ -42,7 +42,12 @@
&["multipart/related; boundary=".as_bytes(), &boundary].concat())
.expect("Unable to create Content-Type header for multipart/related"));
{{/formParams}}
*response.body_mut() = BoxBody::new(Full::new(Bytes::from(body.0)));
{{/x-produces-multipart-related}}
{{/exts}}
{{^x-produces-bytes}}
{{^x-produces-multipart-related}}
*response.body_mut() = body_from_string(body);
{{/x-produces-multipart-related}}
{{/x-produces-bytes}}
{{/exts}}
{{/dataType}}
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ impl<S, C, B> Api<C> for Client<S, C> where
};

// Consumes multipart/form body
let (body_string, multipart_header) = {
let (body_bytes, multipart_header) = {
let mut multipart = Multipart::new();

// For each parameter, encode as appropriate and add to the multipart body as a stream.
Expand Down Expand Up @@ -649,9 +649,9 @@ impl<S, C, B> Api<C> for Client<S, C> where
Err(err) => return Err(ApiError(format!("Unable to build request: {err}"))),
};

let mut body_string = String::new();
let mut body_bytes = Vec::new();

match fields.read_to_string(&mut body_string) {
match fields.read_to_end(&mut body_bytes) {
Ok(_) => (),
Err(err) => return Err(ApiError(format!("Unable to build body: {err}"))),
}
Expand All @@ -660,10 +660,10 @@ impl<S, C, B> Api<C> for Client<S, C> where

let multipart_header = format!("multipart/form-data;boundary={boundary}");

(body_string, multipart_header)
};
(body_bytes, multipart_header)
};

*request.body_mut() = body_from_string(body_string);
*request.body_mut() = BoxBody::new(Full::new(Bytes::from(body_bytes)));

request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(&multipart_header) {
Ok(h) => h,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,7 @@ impl<T, C, ReqBody> hyper::service::Service<(Request<ReqBody>, C)> for Service<T
CONTENT_TYPE,
HeaderValue::from_static("application/octet-stream"));
// Binary Body
let body = String::from_utf8(body.0).expect("Error converting octet stream to string");
*response.body_mut() = body_from_string(body);
*response.body_mut() = BoxBody::new(Full::new(Bytes::from(body.0)));

},
MultigetGetResponse::StringRsp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2650,7 +2650,7 @@ impl<S, C, B> Api<C> for Client<S, C> where
};

// Consumes multipart/form body
let (body_string, multipart_header) = {
let (body_bytes, multipart_header) = {
let mut multipart = Multipart::new();

// For each parameter, encode as appropriate and add to the multipart body as a stream.
Expand Down Expand Up @@ -2684,9 +2684,9 @@ impl<S, C, B> Api<C> for Client<S, C> where
Err(err) => return Err(ApiError(format!("Unable to build request: {err}"))),
};

let mut body_string = String::new();
let mut body_bytes = Vec::new();

match fields.read_to_string(&mut body_string) {
match fields.read_to_end(&mut body_bytes) {
Ok(_) => (),
Err(err) => return Err(ApiError(format!("Unable to build body: {err}"))),
}
Expand All @@ -2695,10 +2695,10 @@ impl<S, C, B> Api<C> for Client<S, C> where

let multipart_header = format!("multipart/form-data;boundary={boundary}");

(body_string, multipart_header)
};
(body_bytes, multipart_header)
};

*request.body_mut() = body_from_string(body_string);
*request.body_mut() = BoxBody::new(Full::new(Bytes::from(body_bytes)));

request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(&multipart_header) {
Ok(h) => h,
Expand Down
Loading