From 0ed087be71b02d9279bd3b131131eae672580d71 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 May 2018 21:17:09 -0700 Subject: tweak openapi schema --- rust/fatcat-api/src/client.rs | 50 +++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'rust/fatcat-api/src/client.rs') diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 06633ad9..6666d6f4 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -277,18 +277,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn container_post(&self, param_body: Option, context: &Context) -> Box + Send> { + fn container_post(&self, param_body: models::ContainerEntity, context: &Context) -> Box + Send> { let url = format!("{}/v0/container", self.base_path); - let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); - let request = match body { - Some(ref body) => request.body(body), - None => request, - }; + let request = request.body(&body); custom_headers.set(ContentType(mimetypes::requests::CONTAINER_POST.clone())); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -453,18 +451,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn creator_post(&self, param_body: Option, context: &Context) -> Box + Send> { + fn creator_post(&self, param_body: models::CreatorEntity, context: &Context) -> Box + Send> { let url = format!("{}/v0/creator", self.base_path); - let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); - let request = match body { - Some(ref body) => request.body(body), - None => request, - }; + let request = request.body(&body); custom_headers.set(ContentType(mimetypes::requests::CREATOR_POST.clone())); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -909,18 +905,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn file_post(&self, param_body: Option, context: &Context) -> Box + Send> { + fn file_post(&self, param_body: models::FileEntity, context: &Context) -> Box + Send> { let url = format!("{}/v0/file", self.base_path); - let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); - let request = match body { - Some(ref body) => request.body(body), - None => request, - }; + let request = request.body(&body); custom_headers.set(ContentType(mimetypes::requests::FILE_POST.clone())); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -1085,18 +1079,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn release_post(&self, param_body: Option, context: &Context) -> Box + Send> { + fn release_post(&self, param_body: models::ReleaseEntity, context: &Context) -> Box + Send> { let url = format!("{}/v0/release", self.base_path); - let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); - let request = match body { - Some(ref body) => request.body(body), - None => request, - }; + let request = request.body(&body); custom_headers.set(ContentType(mimetypes::requests::RELEASE_POST.clone())); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -1198,18 +1190,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn work_post(&self, param_body: Option, context: &Context) -> Box + Send> { + fn work_post(&self, param_body: models::WorkEntity, context: &Context) -> Box + Send> { let url = format!("{}/v0/work", self.base_path); - let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); - let request = match body { - Some(ref body) => request.body(body), - None => request, - }; + let request = request.body(&body); custom_headers.set(ContentType(mimetypes::requests::WORK_POST.clone())); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); -- cgit v1.2.3