diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-27 14:45:07 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-27 14:45:18 -0700 |
commit | 19eb1641eece9f03ca193417cdf244efc1a9da8a (patch) | |
tree | 78545c8e2117bcb0b46680de10d9a49b8f01d75f /rust/fatcat-api/src | |
parent | 29e02c4321762e9c0efcbd2129885ff0af661b34 (diff) | |
download | fatcat-19eb1641eece9f03ca193417cdf244efc1a9da8a.tar.gz fatcat-19eb1641eece9f03ca193417cdf244efc1a9da8a.zip |
swagger spec: body -> entity
Diffstat (limited to 'rust/fatcat-api/src')
-rw-r--r-- | rust/fatcat-api/src/client.rs | 24 | ||||
-rw-r--r-- | rust/fatcat-api/src/lib.rs | 48 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 38 | ||||
-rw-r--r-- | rust/fatcat-api/src/server.rs | 128 |
4 files changed, 121 insertions, 117 deletions
diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 23f6dd21..d81d251f 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -284,10 +284,10 @@ impl Api for Client { Box::new(futures::done(result)) } - fn container_post(&self, param_body: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> { + fn container_post(&self, param_entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> { let url = format!("{}/v0/container", self.base_path); - let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); @@ -472,10 +472,10 @@ impl Api for Client { Box::new(futures::done(result)) } - fn creator_post(&self, param_body: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> { + fn creator_post(&self, param_entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> { let url = format!("{}/v0/creator", self.base_path); - let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); @@ -657,10 +657,10 @@ impl Api for Client { Box::new(futures::done(result)) } - fn editgroup_post(&self, param_body: models::Editgroup, context: &Context) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> { + fn editgroup_post(&self, param_entity: models::Editgroup, context: &Context) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> { let url = format!("{}/v0/editgroup", self.base_path); - let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); @@ -952,10 +952,10 @@ impl Api for Client { Box::new(futures::done(result)) } - fn file_post(&self, param_body: models::FileEntity, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> { + fn file_post(&self, param_entity: models::FileEntity, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> { let url = format!("{}/v0/file", self.base_path); - let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); @@ -1140,10 +1140,10 @@ impl Api for Client { Box::new(futures::done(result)) } - fn release_post(&self, param_body: models::ReleaseEntity, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> { + fn release_post(&self, param_entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> { let url = format!("{}/v0/release", self.base_path); - let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); @@ -1265,10 +1265,10 @@ impl Api for Client { Box::new(futures::done(result)) } - fn work_post(&self, param_body: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> { + fn work_post(&self, param_entity: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> { let url = format!("{}/v0/work", self.base_path); - let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize"); + let body = serde_json::to_string(¶m_entity).expect("impossible to fail to serialize"); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs index a21a0751..dca1aa35 100644 --- a/rust/fatcat-api/src/lib.rs +++ b/rust/fatcat-api/src/lib.rs @@ -260,19 +260,19 @@ pub trait Api { fn container_lookup_get(&self, issnl: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; - fn container_post(&self, body: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>; + fn container_post(&self, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>; fn creator_id_get(&self, id: String, context: &Context) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send>; fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send>; - fn creator_post(&self, body: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>; + fn creator_post(&self, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>; fn editgroup_id_accept_post(&self, id: i64, context: &Context) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send>; fn editgroup_id_get(&self, id: i64, context: &Context) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send>; - fn editgroup_post(&self, body: models::Editgroup, context: &Context) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send>; + fn editgroup_post(&self, entity: models::Editgroup, context: &Context) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send>; fn editor_username_changelog_get(&self, username: String, context: &Context) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send>; @@ -282,17 +282,17 @@ pub trait Api { fn file_lookup_get(&self, sha1: String, context: &Context) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send>; - fn file_post(&self, body: models::FileEntity, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>; + fn file_post(&self, entity: models::FileEntity, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>; fn release_id_get(&self, id: String, context: &Context) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send>; fn release_lookup_get(&self, doi: String, context: &Context) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send>; - fn release_post(&self, body: models::ReleaseEntity, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>; + fn release_post(&self, entity: models::ReleaseEntity, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>; fn work_id_get(&self, id: String, context: &Context) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send>; - fn work_post(&self, body: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>; + fn work_post(&self, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>; } /// API without a `Context` @@ -301,19 +301,19 @@ pub trait ApiNoContext { fn container_lookup_get(&self, issnl: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; - fn container_post(&self, body: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>; + fn container_post(&self, entity: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>; fn creator_id_get(&self, id: String) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send>; fn creator_lookup_get(&self, orcid: String) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError> + Send>; - fn creator_post(&self, body: models::CreatorEntity) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>; + fn creator_post(&self, entity: models::CreatorEntity) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>; fn editgroup_id_accept_post(&self, id: i64) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send>; fn editgroup_id_get(&self, id: i64) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError> + Send>; - fn editgroup_post(&self, body: models::Editgroup) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send>; + fn editgroup_post(&self, entity: models::Editgroup) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send>; fn editor_username_changelog_get(&self, username: String) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send>; @@ -323,17 +323,17 @@ pub trait ApiNoContext { fn file_lookup_get(&self, sha1: String) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send>; - fn file_post(&self, body: models::FileEntity) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>; + fn file_post(&self, entity: models::FileEntity) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>; fn release_id_get(&self, id: String) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send>; fn release_lookup_get(&self, doi: String) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError> + Send>; - fn release_post(&self, body: models::ReleaseEntity) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>; + fn release_post(&self, entity: models::ReleaseEntity) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>; fn work_id_get(&self, id: String) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send>; - fn work_post(&self, body: models::WorkEntity) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>; + fn work_post(&self, entity: models::WorkEntity) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>; } /// Trait to extend an API to make it easy to bind it to a context. @@ -360,8 +360,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().container_lookup_get(issnl, &self.context()) } - fn container_post(&self, body: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> { - self.api().container_post(body, &self.context()) + fn container_post(&self, entity: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> { + self.api().container_post(entity, &self.context()) } fn creator_id_get(&self, id: String) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError> + Send> { @@ -372,8 +372,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().creator_lookup_get(orcid, &self.context()) } - fn creator_post(&self, body: models::CreatorEntity) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> { - self.api().creator_post(body, &self.context()) + fn creator_post(&self, entity: models::CreatorEntity) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> { + self.api().creator_post(entity, &self.context()) } fn editgroup_id_accept_post(&self, id: i64) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send> { @@ -384,8 +384,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().editgroup_id_get(id, &self.context()) } - fn editgroup_post(&self, body: models::Editgroup) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> { - self.api().editgroup_post(body, &self.context()) + fn editgroup_post(&self, entity: models::Editgroup) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError> + Send> { + self.api().editgroup_post(entity, &self.context()) } fn editor_username_changelog_get(&self, username: String) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError> + Send> { @@ -404,8 +404,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().file_lookup_get(sha1, &self.context()) } - fn file_post(&self, body: models::FileEntity) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> { - self.api().file_post(body, &self.context()) + fn file_post(&self, entity: models::FileEntity) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> { + self.api().file_post(entity, &self.context()) } fn release_id_get(&self, id: String) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError> + Send> { @@ -416,16 +416,16 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().release_lookup_get(doi, &self.context()) } - fn release_post(&self, body: models::ReleaseEntity) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> { - self.api().release_post(body, &self.context()) + fn release_post(&self, entity: models::ReleaseEntity) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> { + self.api().release_post(entity, &self.context()) } fn work_id_get(&self, id: String) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError> + Send> { self.api().work_id_get(id, &self.context()) } - fn work_post(&self, body: models::WorkEntity) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> { - self.api().work_post(body, &self.context()) + fn work_post(&self, entity: models::WorkEntity) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> { + self.api().work_post(entity, &self.context()) } } diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs index b05c0fc1..24c66f6b 100644 --- a/rust/fatcat-api/src/models.rs +++ b/rust/fatcat-api/src/models.rs @@ -290,37 +290,37 @@ impl Editor { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct EntityEdit { - #[serde(rename = "extra")] - #[serde(skip_serializing_if = "Option::is_none")] - pub extra: Option<serde_json::Value>, - - #[serde(rename = "editgroup_id")] - pub editgroup_id: i64, + #[serde(rename = "edit_id")] + pub edit_id: i64, - #[serde(rename = "redirect_ident")] - #[serde(skip_serializing_if = "Option::is_none")] - pub redirect_ident: Option<String>, + #[serde(rename = "ident")] + pub ident: String, #[serde(rename = "revision")] #[serde(skip_serializing_if = "Option::is_none")] pub revision: Option<i64>, - #[serde(rename = "ident")] - pub ident: String, + #[serde(rename = "redirect_ident")] + #[serde(skip_serializing_if = "Option::is_none")] + pub redirect_ident: Option<String>, - #[serde(rename = "edit_id")] - pub edit_id: i64, + #[serde(rename = "editgroup_id")] + pub editgroup_id: i64, + + #[serde(rename = "extra")] + #[serde(skip_serializing_if = "Option::is_none")] + pub extra: Option<serde_json::Value>, } impl EntityEdit { - pub fn new(editgroup_id: i64, ident: String, edit_id: i64) -> EntityEdit { + pub fn new(edit_id: i64, ident: String, editgroup_id: i64) -> EntityEdit { EntityEdit { - extra: None, - editgroup_id: editgroup_id, - redirect_ident: None, - revision: None, - ident: ident, edit_id: edit_id, + ident: ident, + revision: None, + redirect_ident: None, + editgroup_id: editgroup_id, + extra: None, } } } diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs index ed012478..7fdc5d2a 100644 --- a/rust/fatcat-api/src/server.rs +++ b/rust/fatcat-api/src/server.rs @@ -276,27 +276,27 @@ where // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. - let param_body = req.get::<bodyparser::Raw>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - not valid UTF-8: {}", e))))?; + let param_entity = req.get::<bodyparser::Raw>() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; let mut unused_elements = Vec::new(); - let param_body = if let Some(param_body_raw) = param_body { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_body_raw); + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_body: Option<models::ContainerEntity> = + let param_entity: Option<models::ContainerEntity> = serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?; + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - param_body + param_entity } else { None }; - let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?; + let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.container_post(param_body, context).wait() { + match api.container_post(param_entity, context).wait() { Ok(rsp) => match rsp { ContainerPostResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -554,26 +554,27 @@ where // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. - let param_body = req.get::<bodyparser::Raw>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - not valid UTF-8: {}", e))))?; + let param_entity = req.get::<bodyparser::Raw>() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; let mut unused_elements = Vec::new(); - let param_body = if let Some(param_body_raw) = param_body { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_body_raw); + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_body: Option<models::CreatorEntity> = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?; + let param_entity: Option<models::CreatorEntity> = + serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - param_body + param_entity } else { None }; - let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?; + let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.creator_post(param_body, context).wait() { + match api.creator_post(param_entity, context).wait() { Ok(rsp) => match rsp { CreatorPostResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -835,26 +836,26 @@ where // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. - let param_body = req.get::<bodyparser::Raw>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - not valid UTF-8: {}", e))))?; + let param_entity = req.get::<bodyparser::Raw>() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; let mut unused_elements = Vec::new(); - let param_body = if let Some(param_body_raw) = param_body { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_body_raw); + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_body: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| { + let param_entity: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?; + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - param_body + param_entity } else { None }; - let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?; + let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.editgroup_post(param_body, context).wait() { + match api.editgroup_post(param_entity, context).wait() { Ok(rsp) => match rsp { EditgroupPostResponse::SuccessfullyCreated(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -1256,26 +1257,27 @@ where // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. - let param_body = req.get::<bodyparser::Raw>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - not valid UTF-8: {}", e))))?; + let param_entity = req.get::<bodyparser::Raw>() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; let mut unused_elements = Vec::new(); - let param_body = if let Some(param_body_raw) = param_body { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_body_raw); + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_body: Option<models::FileEntity> = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?; + let param_entity: Option<models::FileEntity> = + serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - param_body + param_entity } else { None }; - let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?; + let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.file_post(param_body, context).wait() { + match api.file_post(param_entity, context).wait() { Ok(rsp) => match rsp { FilePostResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -1533,26 +1535,27 @@ where // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. - let param_body = req.get::<bodyparser::Raw>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - not valid UTF-8: {}", e))))?; + let param_entity = req.get::<bodyparser::Raw>() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; let mut unused_elements = Vec::new(); - let param_body = if let Some(param_body_raw) = param_body { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_body_raw); + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_body: Option<models::ReleaseEntity> = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?; + let param_entity: Option<models::ReleaseEntity> = + serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - param_body + param_entity } else { None }; - let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?; + let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.release_post(param_body, context).wait() { + match api.release_post(param_entity, context).wait() { Ok(rsp) => match rsp { ReleasePostResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -1726,26 +1729,27 @@ where // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. - let param_body = req.get::<bodyparser::Raw>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - not valid UTF-8: {}", e))))?; + let param_entity = req.get::<bodyparser::Raw>() + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?; let mut unused_elements = Vec::new(); - let param_body = if let Some(param_body_raw) = param_body { - let deserializer = &mut serde_json::Deserializer::from_str(¶m_body_raw); + let param_entity = if let Some(param_entity_raw) = param_entity { + let deserializer = &mut serde_json::Deserializer::from_str(¶m_entity_raw); - let param_body: Option<models::WorkEntity> = serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?; + let param_entity: Option<models::WorkEntity> = + serde_ignored::deserialize(deserializer, |path| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; - param_body + param_entity } else { None }; - let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?; + let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?; - match api.work_post(param_body, context).wait() { + match api.work_post(param_entity, context).wait() { Ok(rsp) => match rsp { WorkPostResponse::CreatedEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); |