From f6b7f0afbee988f46ee8f23c8c81224c65407679 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 14 Dec 2018 17:36:08 +0800 Subject: rust codegen --- rust/fatcat-api-spec/README.md | 2 +- rust/fatcat-api-spec/api.yaml | 32 ++++++++-- rust/fatcat-api-spec/api/swagger.yaml | 40 +++++++++++- rust/fatcat-api-spec/examples/client.rs | 29 +++++++-- rust/fatcat-api-spec/examples/server_lib/mod.rs | 2 +- rust/fatcat-api-spec/examples/server_lib/server.rs | 34 +++++++++-- rust/fatcat-api-spec/src/client.rs | 23 +++++-- rust/fatcat-api-spec/src/lib.rs | 71 ++++++++++++++++++---- rust/fatcat-api-spec/src/models.rs | 16 ++--- rust/fatcat-api-spec/src/server.rs | 64 +++++++++++++------ 10 files changed, 248 insertions(+), 65 deletions(-) (limited to 'rust') diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index f0466320..c399bb9c 100644 --- a/rust/fatcat-api-spec/README.md +++ b/rust/fatcat-api-spec/README.md @@ -13,7 +13,7 @@ To see how to make this your own, look here: [README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) - API version: 0.1.0 -- Build date: 2018-12-13T11:34:47.140Z +- Build date: 2018-12-14T09:17:12.171Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. diff --git a/rust/fatcat-api-spec/api.yaml b/rust/fatcat-api-spec/api.yaml index e452e945..a30bb55e 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -205,18 +205,18 @@ definitions: type: string #format: custom example: "10.1234/abcde.789" - isbn13: + wikidata_qid: type: string - #format: custom - core_id: + isbn13: type: string #format: custom pmid: type: string pmcid: type: string - wikidata_qid: + core_id: type: string + #format: custom volume: type: string issue: @@ -631,6 +631,11 @@ paths: - name: wikidata_qid in: query required: false + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response." - name: hide in: query type: string @@ -895,6 +900,11 @@ paths: - name: wikidata_qid in: query required: false + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response." - name: hide in: query type: string @@ -1141,6 +1151,11 @@ paths: in: query type: string required: false + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response." - name: hide in: query type: string @@ -1418,6 +1433,15 @@ paths: in: query type: string required: false + - name: core_id + in: query + type: string + required: false + - name: expand + in: query + type: string + required: false + description: "List of sub-entities to expand in response." - name: hide in: query type: string diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index 5891a24e..98474f13 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -576,6 +576,13 @@ paths: required: false formatString: "{:?}" example: "Some(\"wikidata_qid_example\".to_string())" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" - name: "hide" in: "query" description: "List of entity fields to elide in response. For container, none\ @@ -1354,6 +1361,13 @@ paths: required: false formatString: "{:?}" example: "Some(\"wikidata_qid_example\".to_string())" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" - name: "hide" in: "query" description: "List of entity fields to elide in response. For creator, none\ @@ -2072,6 +2086,13 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"sha256_example\".to_string())" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" - name: "hide" in: "query" description: "List of entity fields to elide in response. For files, none\ @@ -2866,6 +2887,19 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"pmcid_example\".to_string())" + - name: "core_id" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"core_id_example\".to_string())" + - name: "expand" + in: "query" + description: "List of sub-entities to expand in response." + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"expand_example\".to_string())" - name: "hide" in: "query" description: "List of entity fields to elide in response. For releases, 'abstracts',\ @@ -4395,16 +4429,16 @@ definitions: example: "12" volume: type: "string" - wikidata_qid: + core_id: type: "string" pmcid: type: "string" pmid: type: "string" - core_id: - type: "string" isbn13: type: "string" + wikidata_qid: + type: "string" doi: type: "string" example: "10.1234/abcde.789" diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index f2d7a859..91ac7a4e 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -85,9 +85,11 @@ fn main() { "GetWorkRedirects", "GetWorkReleases", "GetWorkRevision", - ]).required(true) + ]) + .required(true) .index(1), - ).arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")) + ) + .arg(Arg::with_name("https").long("https").help("Whether to use HTTPS or not")) .arg(Arg::with_name("host").long("host").takes_value(true).default_value("api.fatcat.wiki").help("Hostname to contact")) .arg(Arg::with_name("port").long("port").takes_value(true).default_value("8080").help("Port to contact")) .get_matches(); @@ -162,7 +164,12 @@ fn main() { Some("LookupContainer") => { let result = client - .lookup_container(Some("issnl_example".to_string()), Some("wikidata_qid_example".to_string()), Some("hide_example".to_string())) + .lookup_container( + Some("issnl_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + ) .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -229,7 +236,12 @@ fn main() { Some("LookupCreator") => { let result = client - .lookup_creator(Some("orcid_example".to_string()), Some("wikidata_qid_example".to_string()), Some("hide_example".to_string())) + .lookup_creator( + Some("orcid_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + ) .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -332,8 +344,10 @@ fn main() { Some("md5_example".to_string()), Some("sha1_example".to_string()), Some("sha256_example".to_string()), + Some("expand_example".to_string()), Some("hide_example".to_string()), - ).wait(); + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -410,8 +424,11 @@ fn main() { Some("isbn13_example".to_string()), Some("pmid_example".to_string()), Some("pmcid_example".to_string()), + Some("core_id_example".to_string()), + Some("expand_example".to_string()), Some("hide_example".to_string()), - ).wait(); + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } diff --git a/rust/fatcat-api-spec/examples/server_lib/mod.rs b/rust/fatcat-api-spec/examples/server_lib/mod.rs index 5291637e..bf404d49 100644 --- a/rust/fatcat-api-spec/examples/server_lib/mod.rs +++ b/rust/fatcat-api-spec/examples/server_lib/mod.rs @@ -3,7 +3,7 @@ mod server; mod errors { - error_chain!{} + error_chain! {} } pub use self::errors::*; diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index 7341e528..98358657 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -119,12 +119,20 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send> { + fn lookup_container( + &self, + issnl: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + context: &Context, + ) -> Box + Send> { let context = context.clone(); println!( - "lookup_container({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", issnl, wikidata_qid, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -247,12 +255,20 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send> { + fn lookup_creator( + &self, + orcid: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + context: &Context, + ) -> Box + Send> { let context = context.clone(); println!( - "lookup_creator({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_creator({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", orcid, wikidata_qid, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -417,15 +433,17 @@ impl Api for Server { md5: Option, sha1: Option, sha256: Option, + expand: Option, hide: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "lookup_file({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_file({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", md5, sha1, sha256, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -566,17 +584,21 @@ impl Api for Server { isbn13: Option, pmid: Option, pmcid: Option, + core_id: Option, + expand: Option, hide: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", doi, wikidata_qid, isbn13, pmid, pmcid, + core_id, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); diff --git a/rust/fatcat-api-spec/src/client.rs b/rust/fatcat-api-spec/src/client.rs index 5a5f4693..b3b1a922 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -795,19 +795,22 @@ impl Api for Client { &self, param_issnl: Option, param_wikidata_qid: Option, + param_expand: Option, param_hide: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_issnl = param_issnl.map_or_else(String::new, |query| format!("issnl={issnl}&", issnl = query.to_string())); let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/container/lookup?{issnl}{wikidata_qid}{hide}", + "{}/v0/container/lookup?{issnl}{wikidata_qid}{expand}{hide}", self.base_path, issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET), wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -1637,19 +1640,22 @@ impl Api for Client { &self, param_orcid: Option, param_wikidata_qid: Option, + param_expand: Option, param_hide: Option, context: &Context, ) -> Box + Send> { // Query parameters let query_orcid = param_orcid.map_or_else(String::new, |query| format!("orcid={orcid}&", orcid = query.to_string())); let query_wikidata_qid = param_wikidata_qid.map_or_else(String::new, |query| format!("wikidata_qid={wikidata_qid}&", wikidata_qid = query.to_string())); + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/creator/lookup?{orcid}{wikidata_qid}{hide}", + "{}/v0/creator/lookup?{orcid}{wikidata_qid}{expand}{hide}", self.base_path, orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET), wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -2862,6 +2868,7 @@ impl Api for Client { param_md5: Option, param_sha1: Option, param_sha256: Option, + param_expand: Option, param_hide: Option, context: &Context, ) -> Box + Send> { @@ -2869,14 +2876,16 @@ impl Api for Client { let query_md5 = param_md5.map_or_else(String::new, |query| format!("md5={md5}&", md5 = query.to_string())); let query_sha1 = param_sha1.map_or_else(String::new, |query| format!("sha1={sha1}&", sha1 = query.to_string())); let query_sha256 = param_sha256.map_or_else(String::new, |query| format!("sha256={sha256}&", sha256 = query.to_string())); + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/file/lookup?{md5}{sha1}{sha256}{hide}", + "{}/v0/file/lookup?{md5}{sha1}{sha256}{expand}{hide}", self.base_path, md5 = utf8_percent_encode(&query_md5, QUERY_ENCODE_SET), sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET), sha256 = utf8_percent_encode(&query_sha256, QUERY_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); @@ -3771,6 +3780,8 @@ impl Api for Client { param_isbn13: Option, param_pmid: Option, param_pmcid: Option, + param_core_id: Option, + param_expand: Option, param_hide: Option, context: &Context, ) -> Box + Send> { @@ -3780,16 +3791,20 @@ impl Api for Client { let query_isbn13 = param_isbn13.map_or_else(String::new, |query| format!("isbn13={isbn13}&", isbn13 = query.to_string())); let query_pmid = param_pmid.map_or_else(String::new, |query| format!("pmid={pmid}&", pmid = query.to_string())); let query_pmcid = param_pmcid.map_or_else(String::new, |query| format!("pmcid={pmcid}&", pmcid = query.to_string())); + let query_core_id = param_core_id.map_or_else(String::new, |query| format!("core_id={core_id}&", core_id = query.to_string())); + let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); let query_hide = param_hide.map_or_else(String::new, |query| format!("hide={hide}&", hide = query.to_string())); let url = format!( - "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{hide}", + "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{core_id}{expand}{hide}", self.base_path, doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET), wikidata_qid = utf8_percent_encode(&query_wikidata_qid, QUERY_ENCODE_SET), isbn13 = utf8_percent_encode(&query_isbn13, QUERY_ENCODE_SET), pmid = utf8_percent_encode(&query_pmid, QUERY_ENCODE_SET), pmcid = utf8_percent_encode(&query_pmcid, QUERY_ENCODE_SET), + core_id = utf8_percent_encode(&query_core_id, QUERY_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET), hide = utf8_percent_encode(&query_hide, QUERY_ENCODE_SET) ); diff --git a/rust/fatcat-api-spec/src/lib.rs b/rust/fatcat-api-spec/src/lib.rs index dcc6e813..4e06616f 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -828,7 +828,14 @@ pub trait Api { fn get_container_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send>; + fn lookup_container( + &self, + issnl: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + context: &Context, + ) -> Box + Send>; fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option, context: &Context) -> Box + Send>; @@ -858,7 +865,14 @@ pub trait Api { fn get_creator_revision(&self, id: String, expand: Option, hide: Option, context: &Context) -> Box + Send>; - fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send>; + fn lookup_creator( + &self, + orcid: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + context: &Context, + ) -> Box + Send>; fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option, context: &Context) -> Box + Send>; @@ -907,6 +921,7 @@ pub trait Api { md5: Option, sha1: Option, sha256: Option, + expand: Option, hide: Option, context: &Context, ) -> Box + Send>; @@ -948,6 +963,8 @@ pub trait Api { isbn13: Option, pmid: Option, pmcid: Option, + core_id: Option, + expand: Option, hide: Option, context: &Context, ) -> Box + Send>; @@ -1006,7 +1023,13 @@ pub trait ApiNoContext { fn get_container_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; - fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option) -> Box + Send>; + fn lookup_container( + &self, + issnl: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + ) -> Box + Send>; fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option) -> Box + Send>; @@ -1035,7 +1058,7 @@ pub trait ApiNoContext { fn get_creator_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; - fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option) -> Box + Send>; + fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, expand: Option, hide: Option) -> Box + Send>; fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option) -> Box + Send>; @@ -1073,7 +1096,14 @@ pub trait ApiNoContext { fn get_file_revision(&self, id: String, expand: Option, hide: Option) -> Box + Send>; - fn lookup_file(&self, md5: Option, sha1: Option, sha256: Option, hide: Option) -> Box + Send>; + fn lookup_file( + &self, + md5: Option, + sha1: Option, + sha256: Option, + expand: Option, + hide: Option, + ) -> Box + Send>; fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option) -> Box + Send>; @@ -1111,6 +1141,8 @@ pub trait ApiNoContext { isbn13: Option, pmid: Option, pmcid: Option, + core_id: Option, + expand: Option, hide: Option, ) -> Box + Send>; @@ -1194,8 +1226,14 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_container_revision(id, expand, hide, &self.context()) } - fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option) -> Box + Send> { - self.api().lookup_container(issnl, wikidata_qid, hide, &self.context()) + fn lookup_container( + &self, + issnl: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + ) -> Box + Send> { + self.api().lookup_container(issnl, wikidata_qid, expand, hide, &self.context()) } fn update_container(&self, id: String, entity: models::ContainerEntity, editgroup: Option) -> Box + Send> { @@ -1247,8 +1285,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_creator_revision(id, expand, hide, &self.context()) } - fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option) -> Box + Send> { - self.api().lookup_creator(orcid, wikidata_qid, hide, &self.context()) + fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, expand: Option, hide: Option) -> Box + Send> { + self.api().lookup_creator(orcid, wikidata_qid, expand, hide, &self.context()) } fn update_creator(&self, id: String, entity: models::CreatorEntity, editgroup: Option) -> Box + Send> { @@ -1323,8 +1361,15 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().get_file_revision(id, expand, hide, &self.context()) } - fn lookup_file(&self, md5: Option, sha1: Option, sha256: Option, hide: Option) -> Box + Send> { - self.api().lookup_file(md5, sha1, sha256, hide, &self.context()) + fn lookup_file( + &self, + md5: Option, + sha1: Option, + sha256: Option, + expand: Option, + hide: Option, + ) -> Box + Send> { + self.api().lookup_file(md5, sha1, sha256, expand, hide, &self.context()) } fn update_file(&self, id: String, entity: models::FileEntity, editgroup: Option) -> Box + Send> { @@ -1387,9 +1432,11 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { isbn13: Option, pmid: Option, pmcid: Option, + core_id: Option, + expand: Option, hide: Option, ) -> Box + Send> { - self.api().lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, hide, &self.context()) + self.api().lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core_id, expand, hide, &self.context()) } fn update_release(&self, id: String, entity: models::ReleaseEntity, editgroup: Option) -> Box + Send> { diff --git a/rust/fatcat-api-spec/src/models.rs b/rust/fatcat-api-spec/src/models.rs index 6e374746..5b9010cd 100644 --- a/rust/fatcat-api-spec/src/models.rs +++ b/rust/fatcat-api-spec/src/models.rs @@ -514,9 +514,9 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub volume: Option, - #[serde(rename = "wikidata_qid")] + #[serde(rename = "core_id")] #[serde(skip_serializing_if = "Option::is_none")] - pub wikidata_qid: Option, + pub core_id: Option, #[serde(rename = "pmcid")] #[serde(skip_serializing_if = "Option::is_none")] @@ -526,14 +526,14 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub pmid: Option, - #[serde(rename = "core_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub core_id: Option, - #[serde(rename = "isbn13")] #[serde(skip_serializing_if = "Option::is_none")] pub isbn13: Option, + #[serde(rename = "wikidata_qid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub wikidata_qid: Option, + #[serde(rename = "doi")] #[serde(skip_serializing_if = "Option::is_none")] pub doi: Option, @@ -613,11 +613,11 @@ impl ReleaseEntity { pages: None, issue: None, volume: None, - wikidata_qid: None, + core_id: None, pmcid: None, pmid: None, - core_id: None, isbn13: None, + wikidata_qid: None, doi: None, release_date: None, release_status: None, diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index e8d8e1eb..84c691ef 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -128,7 +128,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -239,7 +240,8 @@ where let param_entity_list: Option> = 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_list - doesn't match schema: {}", e))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; param_entity_list } else { @@ -974,9 +976,10 @@ where let query_params = req.get::().unwrap_or_default(); let param_issnl = query_params.get("issnl").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.lookup_container(param_issnl, param_wikidata_qid, param_hide, context).wait() { + match api.lookup_container(param_issnl, param_wikidata_qid, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { LookupContainerResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -1085,7 +1088,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -1195,7 +1199,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -1306,7 +1311,8 @@ where let param_entity_list: Option> = 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_list - doesn't match schema: {}", e))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; param_entity_list } else { @@ -2134,9 +2140,10 @@ where let query_params = req.get::().unwrap_or_default(); let param_orcid = query_params.get("orcid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_wikidata_qid = query_params.get("wikidata_qid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.lookup_creator(param_orcid, param_wikidata_qid, param_hide, context).wait() { + match api.lookup_creator(param_orcid, param_wikidata_qid, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { LookupCreatorResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -2245,7 +2252,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -2686,7 +2694,8 @@ where let param_editgroup: Option = 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 editgroup - doesn't match schema: {}", e))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?; param_editgroup } else { @@ -3010,7 +3019,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -3121,7 +3131,8 @@ where let param_entity_list: Option> = 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_list - doesn't match schema: {}", e))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; param_entity_list } else { @@ -3857,9 +3868,10 @@ where let param_md5 = query_params.get("md5").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_sha1 = query_params.get("sha1").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_sha256 = query_params.get("sha256").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.lookup_file(param_md5, param_sha1, param_sha256, param_hide, context).wait() { + match api.lookup_file(param_md5, param_sha1, param_sha256, param_expand, param_hide, context).wait() { Ok(rsp) => match rsp { LookupFileResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -3968,7 +3980,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -4078,7 +4091,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -4189,7 +4203,8 @@ where let param_entity_list: Option> = 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_list - doesn't match schema: {}", e))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; param_entity_list } else { @@ -4299,7 +4314,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -5130,9 +5146,14 @@ where let param_isbn13 = query_params.get("isbn13").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_pmid = query_params.get("pmid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_pmcid = query_params.get("pmcid").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_core_id = query_params.get("core_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); let param_hide = query_params.get("hide").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - match api.lookup_release(param_doi, param_wikidata_qid, param_isbn13, param_pmid, param_pmcid, param_hide, context).wait() { + match api + .lookup_release(param_doi, param_wikidata_qid, param_isbn13, param_pmid, param_pmcid, param_core_id, param_expand, param_hide, context) + .wait() + { Ok(rsp) => match rsp { LookupReleaseResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); @@ -5241,7 +5262,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { @@ -5352,7 +5374,8 @@ where let param_entity_list: Option> = 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_list - doesn't match schema: {}", e))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity_list - doesn't match schema: {}", e))))?; param_entity_list } else { @@ -6211,7 +6234,8 @@ where let param_entity: Option = 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))))?; + }) + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?; param_entity } else { -- cgit v1.2.3