From aa6545c4125d800765fa2673a6b4a534cee54aad Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 10 May 2019 15:05:21 -0700 Subject: codegen extid changes (rust) --- rust/fatcat-api-spec/README.md | 2 +- rust/fatcat-api-spec/api.yaml | 63 ++++++------ rust/fatcat-api-spec/api/swagger.yaml | 101 ++++++++++-------- rust/fatcat-api-spec/examples/client.rs | 10 +- rust/fatcat-api-spec/examples/server_lib/server.rs | 20 ++-- rust/fatcat-api-spec/src/client.rs | 32 +++--- rust/fatcat-api-spec/src/lib.rs | 32 +++--- rust/fatcat-api-spec/src/models.rs | 114 ++++++++++++--------- rust/fatcat-api-spec/src/server.rs | 20 ++-- 9 files changed, 216 insertions(+), 178 deletions(-) (limited to 'rust') diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index 4a23371e..fa2a6361 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.2.0 -- Build date: 2019-05-10T18:47:50.409Z +- Build date: 2019-05-10T21:23:45.364Z 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 389ba24e..696d8495 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -319,6 +319,8 @@ definitions: release_entity: type: object # required for creation: title + required: + - ext_ids properties: <<: *ENTITYPROPS title: @@ -376,30 +378,33 @@ definitions: type: integer example: 2014 format: int64 - doi: - type: string - #format: custom - example: "10.1234/abcde.789" - wikidata_qid: - type: string - isbn13: - type: string - #format: custom - pmid: - type: string - pmcid: - type: string - core_id: - type: string - #format: custom - arxiv_id: - type: string - jstor_id: - type: string - ark_id: - type: string - mag_id: - type: string + ext_ids: + type: object + properties: + doi: + type: string + #format: custom + example: "10.1234/abcde.789" + wikidata_qid: + type: string + isbn13: + type: string + #format: custom + pmid: + type: string + pmcid: + type: string + core: + type: string + #format: custom + arxiv: + type: string + jstor: + type: string + ark: + type: string + mag: + type: string volume: type: string issue: @@ -2285,23 +2290,23 @@ paths: in: query type: string required: false - - name: core_id + - name: core in: query type: string required: false - - name: arxiv_id + - name: arxiv in: query type: string required: false - - name: jstor_id + - name: jstor in: query type: string required: false - - name: ark_id + - name: ark in: query type: string required: false - - name: mag_id + - name: mag in: query type: string required: false diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index a3fb7053..6c8ce50b 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -5137,36 +5137,36 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"pmcid_example\".to_string())" - - name: "core_id" + - name: "core" in: "query" required: false type: "string" formatString: "{:?}" - example: "Some(\"core_id_example\".to_string())" - - name: "arxiv_id" + example: "Some(\"core_example\".to_string())" + - name: "arxiv" in: "query" required: false type: "string" formatString: "{:?}" - example: "Some(\"arxiv_id_example\".to_string())" - - name: "jstor_id" + example: "Some(\"arxiv_example\".to_string())" + - name: "jstor" in: "query" required: false type: "string" formatString: "{:?}" - example: "Some(\"jstor_id_example\".to_string())" - - name: "ark_id" + example: "Some(\"jstor_example\".to_string())" + - name: "ark" in: "query" required: false type: "string" formatString: "{:?}" - example: "Some(\"ark_id_example\".to_string())" - - name: "mag_id" + example: "Some(\"ark_example\".to_string())" + - name: "mag" in: "query" required: false type: "string" formatString: "{:?}" - example: "Some(\"mag_id_example\".to_string())" + example: "Some(\"mag_example\".to_string())" - name: "expand" in: "query" description: "List of sub-entities to expand in response." @@ -7817,6 +7817,8 @@ definitions: upperCaseName: "WEBCAPTURE_ENTITY" release_entity: type: "object" + required: + - "ext_ids" properties: abstracts: type: "array" @@ -7849,27 +7851,8 @@ definitions: example: "12" volume: type: "string" - mag_id: - type: "string" - ark_id: - type: "string" - jstor_id: - type: "string" - arxiv_id: - type: "string" - core_id: - type: "string" - pmcid: - type: "string" - pmid: - type: "string" - isbn13: - type: "string" - wikidata_qid: - type: "string" - doi: - type: "string" - example: "10.1234/abcde.789" + ext_ids: + $ref: "#/definitions/release_entity_ext_ids" withdrawn_year: type: "integer" format: "int64" @@ -7961,7 +7944,6 @@ definitions: edit_extra: type: "object" example: - mag_id: "mag_id" container: redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -8088,13 +8070,10 @@ definitions: given_name: "given_name" number: "number" pages: "pages" - core_id: "core_id" extra: "{}" state: "wip" edit_extra: "{}" - ark_id: "ark_id" withdrawn_year: 2014 - jstor_id: "jstor_id" redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" work_id: "q3nouwy3nnbsvo3h5klxsx4a7y" issue: "12" @@ -8110,11 +8089,20 @@ definitions: content: "Some abstract thing goes here" release_year: 2014 release_type: "book" - wikidata_qid: "wikidata_qid" - pmid: "pmid" version: "version" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" volume: "volume" + ext_ids: + core: "core" + mag: "mag" + jstor: "jstor" + isbn13: "isbn13" + arxiv: "arxiv" + wikidata_qid: "wikidata_qid" + ark: "ark" + pmid: "pmid" + pmcid: "pmcid" + doi: "10.1234/abcde.789" release_stage: "preprint, retracted" license_slug: "license_slug" withdrawn_date: "2000-01-23" @@ -8136,7 +8124,6 @@ definitions: locator: "p123" key: "key" release_date: "2000-01-23" - isbn13: "isbn13" subtitle: "subtitle" publisher: "publisher" files: @@ -8178,7 +8165,6 @@ definitions: - "q3nouwy3nnbsvo3h5klxsx4a7y" edit_extra: "{}" md5: "1b39813549077b2347c0f370c3864b40" - arxiv_id: "arxiv_id" filesets: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" urls: @@ -8234,9 +8220,7 @@ definitions: - "q3nouwy3nnbsvo3h5klxsx4a7y" edit_extra: "{}" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" - pmcid: "pmcid" container_id: "q3nouwy3nnbsvo3h5klxsx4a7y" - doi: "10.1234/abcde.789" upperCaseName: "RELEASE_ENTITY" work_entity: type: "object" @@ -9349,6 +9333,41 @@ definitions: lang: "en" content: "Some abstract thing goes here" upperCaseName: "RELEASE_ENTITY_ABSTRACTS" + release_entity_ext_ids: + properties: + doi: + type: "string" + example: "10.1234/abcde.789" + wikidata_qid: + type: "string" + isbn13: + type: "string" + pmid: + type: "string" + pmcid: + type: "string" + core: + type: "string" + arxiv: + type: "string" + jstor: + type: "string" + ark: + type: "string" + mag: + type: "string" + example: + core: "core" + mag: "mag" + jstor: "jstor" + isbn13: "isbn13" + arxiv: "arxiv" + wikidata_qid: "wikidata_qid" + ark: "ark" + pmid: "pmid" + pmcid: "pmcid" + doi: "10.1234/abcde.789" + upperCaseName: "RELEASE_ENTITY_EXT_IDS" editgroup_edits: properties: containers: diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index 0cb4a920..371d6ae2 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -593,11 +593,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("arxiv_id_example".to_string()), - Some("jstor_id_example".to_string()), - Some("ark_id_example".to_string()), - Some("mag_id_example".to_string()), + Some("core_example".to_string()), + Some("arxiv_example".to_string()), + Some("jstor_example".to_string()), + Some("ark_example".to_string()), + Some("mag_example".to_string()), Some("expand_example".to_string()), Some("hide_example".to_string()), ) diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index 2c67079f..378b4285 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -845,11 +845,11 @@ impl Api for Server { isbn13: Option, pmid: Option, pmcid: Option, - core_id: Option, - arxiv_id: Option, - jstor_id: Option, - ark_id: Option, - mag_id: Option, + core: Option, + arxiv: Option, + jstor: Option, + ark: Option, + mag: Option, expand: Option, hide: Option, context: &Context, @@ -862,11 +862,11 @@ impl Api for Server { isbn13, pmid, pmcid, - core_id, - arxiv_id, - jstor_id, - ark_id, - mag_id, + core, + arxiv, + jstor, + ark, + mag, 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 c4d6b687..057f1651 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -6017,11 +6017,11 @@ impl Api for Client { param_isbn13: Option, param_pmid: Option, param_pmcid: Option, - param_core_id: Option, - param_arxiv_id: Option, - param_jstor_id: Option, - param_ark_id: Option, - param_mag_id: Option, + param_core: Option, + param_arxiv: Option, + param_jstor: Option, + param_ark: Option, + param_mag: Option, param_expand: Option, param_hide: Option, context: &Context, @@ -6032,27 +6032,27 @@ 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_arxiv_id = param_arxiv_id.map_or_else(String::new, |query| format!("arxiv_id={arxiv_id}&", arxiv_id = query.to_string())); - let query_jstor_id = param_jstor_id.map_or_else(String::new, |query| format!("jstor_id={jstor_id}&", jstor_id = query.to_string())); - let query_ark_id = param_ark_id.map_or_else(String::new, |query| format!("ark_id={ark_id}&", ark_id = query.to_string())); - let query_mag_id = param_mag_id.map_or_else(String::new, |query| format!("mag_id={mag_id}&", mag_id = query.to_string())); + let query_core = param_core.map_or_else(String::new, |query| format!("core={core}&", core = query.to_string())); + let query_arxiv = param_arxiv.map_or_else(String::new, |query| format!("arxiv={arxiv}&", arxiv = query.to_string())); + let query_jstor = param_jstor.map_or_else(String::new, |query| format!("jstor={jstor}&", jstor = query.to_string())); + let query_ark = param_ark.map_or_else(String::new, |query| format!("ark={ark}&", ark = query.to_string())); + let query_mag = param_mag.map_or_else(String::new, |query| format!("mag={mag}&", mag = 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}{core_id}{arxiv_id}{jstor_id}{ark_id}{mag_id}{expand}{hide}", + "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{core}{arxiv}{jstor}{ark}{mag}{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), - arxiv_id = utf8_percent_encode(&query_arxiv_id, QUERY_ENCODE_SET), - jstor_id = utf8_percent_encode(&query_jstor_id, QUERY_ENCODE_SET), - ark_id = utf8_percent_encode(&query_ark_id, QUERY_ENCODE_SET), - mag_id = utf8_percent_encode(&query_mag_id, QUERY_ENCODE_SET), + core = utf8_percent_encode(&query_core, QUERY_ENCODE_SET), + arxiv = utf8_percent_encode(&query_arxiv, QUERY_ENCODE_SET), + jstor = utf8_percent_encode(&query_jstor, QUERY_ENCODE_SET), + ark = utf8_percent_encode(&query_ark, QUERY_ENCODE_SET), + mag = utf8_percent_encode(&query_mag, 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 06d3cfdb..e01c4fd8 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -1577,11 +1577,11 @@ pub trait Api { isbn13: Option, pmid: Option, pmcid: Option, - core_id: Option, - arxiv_id: Option, - jstor_id: Option, - ark_id: Option, - mag_id: Option, + core: Option, + arxiv: Option, + jstor: Option, + ark: Option, + mag: Option, expand: Option, hide: Option, context: &Context, @@ -1865,11 +1865,11 @@ pub trait ApiNoContext { isbn13: Option, pmid: Option, pmcid: Option, - core_id: Option, - arxiv_id: Option, - jstor_id: Option, - ark_id: Option, - mag_id: Option, + core: Option, + arxiv: Option, + jstor: Option, + ark: Option, + mag: Option, expand: Option, hide: Option, ) -> Box + Send>; @@ -2308,16 +2308,16 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { isbn13: Option, pmid: Option, pmcid: Option, - core_id: Option, - arxiv_id: Option, - jstor_id: Option, - ark_id: Option, - mag_id: Option, + core: Option, + arxiv: Option, + jstor: Option, + ark: Option, + mag: Option, expand: Option, hide: Option, ) -> Box + Send> { self.api() - .lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id, ark_id, mag_id, expand, hide, &self.context()) + .lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core, arxiv, jstor, ark, mag, expand, hide, &self.context()) } fn update_release(&self, ident: String, entity: models::ReleaseEntity, editgroup_id: String) -> Box + Send> { diff --git a/rust/fatcat-api-spec/src/models.rs b/rust/fatcat-api-spec/src/models.rs index bf989b84..1d6b5088 100644 --- a/rust/fatcat-api-spec/src/models.rs +++ b/rust/fatcat-api-spec/src/models.rs @@ -792,45 +792,8 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub volume: Option, - #[serde(rename = "mag_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub mag_id: Option, - - #[serde(rename = "ark_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ark_id: Option, - - #[serde(rename = "jstor_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub jstor_id: Option, - - #[serde(rename = "arxiv_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub arxiv_id: Option, - - #[serde(rename = "core_id")] - #[serde(skip_serializing_if = "Option::is_none")] - pub core_id: Option, - - #[serde(rename = "pmcid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pmcid: Option, - - #[serde(rename = "pmid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub pmid: 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, + #[serde(rename = "ext_ids")] + pub ext_ids: models::ReleaseEntityExtIds, #[serde(rename = "withdrawn_year")] #[serde(skip_serializing_if = "Option::is_none")] @@ -933,7 +896,7 @@ pub struct ReleaseEntity { } impl ReleaseEntity { - pub fn new() -> ReleaseEntity { + pub fn new(ext_ids: models::ReleaseEntityExtIds) -> ReleaseEntity { ReleaseEntity { abstracts: None, refs: None, @@ -946,16 +909,7 @@ impl ReleaseEntity { pages: None, issue: None, volume: None, - mag_id: None, - ark_id: None, - jstor_id: None, - arxiv_id: None, - core_id: None, - pmcid: None, - pmid: None, - isbn13: None, - wikidata_qid: None, - doi: None, + ext_ids: ext_ids, withdrawn_year: None, withdrawn_date: None, withdrawn_status: None, @@ -1012,6 +966,66 @@ impl ReleaseEntityAbstracts { } } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct ReleaseEntityExtIds { + #[serde(rename = "doi")] + #[serde(skip_serializing_if = "Option::is_none")] + pub doi: Option, + + #[serde(rename = "wikidata_qid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub wikidata_qid: Option, + + #[serde(rename = "isbn13")] + #[serde(skip_serializing_if = "Option::is_none")] + pub isbn13: Option, + + #[serde(rename = "pmid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub pmid: Option, + + #[serde(rename = "pmcid")] + #[serde(skip_serializing_if = "Option::is_none")] + pub pmcid: Option, + + #[serde(rename = "core")] + #[serde(skip_serializing_if = "Option::is_none")] + pub core: Option, + + #[serde(rename = "arxiv")] + #[serde(skip_serializing_if = "Option::is_none")] + pub arxiv: Option, + + #[serde(rename = "jstor")] + #[serde(skip_serializing_if = "Option::is_none")] + pub jstor: Option, + + #[serde(rename = "ark")] + #[serde(skip_serializing_if = "Option::is_none")] + pub ark: Option, + + #[serde(rename = "mag")] + #[serde(skip_serializing_if = "Option::is_none")] + pub mag: Option, +} + +impl ReleaseEntityExtIds { + pub fn new() -> ReleaseEntityExtIds { + ReleaseEntityExtIds { + doi: None, + wikidata_qid: None, + isbn13: None, + pmid: None, + pmcid: None, + core: None, + arxiv: None, + jstor: None, + ark: None, + mag: None, + } + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReleaseRef { #[serde(rename = "index")] diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index 7379aed9..ffe3347b 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -8278,11 +8278,11 @@ 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_arxiv_id = query_params.get("arxiv_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_jstor_id = query_params.get("jstor_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_ark_id = query_params.get("ark_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); - let param_mag_id = query_params.get("mag_id").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_core = query_params.get("core").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_arxiv = query_params.get("arxiv").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_jstor = query_params.get("jstor").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_ark = query_params.get("ark").and_then(|list| list.first()).and_then(|x| x.parse::().ok()); + let param_mag = query_params.get("mag").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()); @@ -8293,11 +8293,11 @@ where param_isbn13, param_pmid, param_pmcid, - param_core_id, - param_arxiv_id, - param_jstor_id, - param_ark_id, - param_mag_id, + param_core, + param_arxiv, + param_jstor, + param_ark, + param_mag, param_expand, param_hide, context, -- cgit v1.2.3