From bf63870c88b5a62a2aad08929465b37d8be474dc Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 9 May 2019 00:05:29 -0700 Subject: rust codegen --- rust/fatcat-api-spec/README.md | 2 +- rust/fatcat-api-spec/api.yaml | 41 +++++++++++- rust/fatcat-api-spec/api/swagger.yaml | 75 +++++++++++++++++++++- rust/fatcat-api-spec/examples/client.rs | 2 + rust/fatcat-api-spec/examples/server_lib/server.rs | 6 +- rust/fatcat-api-spec/src/client.rs | 8 ++- rust/fatcat-api-spec/src/lib.rs | 8 ++- rust/fatcat-api-spec/src/models.rs | 67 ++++++++++++++++++- rust/fatcat-api-spec/src/server.rs | 4 ++ 9 files changed, 203 insertions(+), 10 deletions(-) (limited to 'rust') diff --git a/rust/fatcat-api-spec/README.md b/rust/fatcat-api-spec/README.md index 5730bf18..60ead2e5 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-04-10T04:59:58.690Z +- Build date: 2019-05-09T06:57:24.103Z 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 4d3443de..6fd73deb 100644 --- a/rust/fatcat-api-spec/api.yaml +++ b/rust/fatcat-api-spec/api.yaml @@ -281,10 +281,17 @@ definitions: type: integer example: 200 format: int64 + size_bytes: + type: integer + example: 1235 + format: int64 sha1: <<: *FATCATSHA1 sha256: <<: *FATCATSHA256 + extra: + type: object + additionalProperties: {} archive_urls: type: array items: @@ -320,6 +327,9 @@ definitions: title: type: string description: "Required for valid entities. The title used in citations and for display; usually English" + subtitle: + type: string + description: "Avoid this field if possible, and merge with title; usually English" original_title: type: string description: "Title in original language (or, the language of the full text of this release)" @@ -350,7 +360,7 @@ definitions: release_type: type: string example: "book" - release_status: + release_stage: type: string example: "preprint, retracted" release_date: @@ -360,6 +370,15 @@ definitions: type: integer example: 2014 format: int64 + withdrawn_state: + type: string + withdrawn_date: + type: string + format: date + withdrawn_year: + type: integer + example: 2014 + format: int64 doi: type: string #format: custom @@ -380,6 +399,10 @@ definitions: type: string jstor_id: type: string + ark_id: + type: string + mag_id: + type: string volume: type: string issue: @@ -387,6 +410,10 @@ definitions: example: "12" pages: type: string + number: + type: string + version: + type: string publisher: type: string language: @@ -603,6 +630,10 @@ definitions: description: "Optional; GET-only" raw_name: type: string + given_name: + type: string + surname: + type: string role: type: string raw_affiliation: @@ -2269,6 +2300,14 @@ paths: in: query type: string required: false + - name: ark_id + in: query + type: string + required: false + - name: mag_id + in: query + type: string + required: false - name: expand in: query type: string diff --git a/rust/fatcat-api-spec/api/swagger.yaml b/rust/fatcat-api-spec/api/swagger.yaml index f70b434c..c73c5c07 100644 --- a/rust/fatcat-api-spec/api/swagger.yaml +++ b/rust/fatcat-api-spec/api/swagger.yaml @@ -5155,6 +5155,18 @@ paths: type: "string" formatString: "{:?}" example: "Some(\"jstor_id_example\".to_string())" + - name: "ark_id" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"ark_id_example\".to_string())" + - name: "mag_id" + in: "query" + required: false + type: "string" + formatString: "{:?}" + example: "Some(\"mag_id_example\".to_string())" - name: "expand" in: "query" description: "List of sub-entities to expand in response." @@ -7780,14 +7792,18 @@ definitions: - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" surt: "org,asheesh)/apus/ch1/node15.html" status_code: 200 + size_bytes: 1235 sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" + extra: "{}" mimetype: "text/html" url: "http://www.asheesh.org:80/APUS/ch1/node15.html" timestamp: "2016-09-19T17:20:24Z" - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" surt: "org,asheesh)/apus/ch1/node15.html" status_code: 200 + size_bytes: 1235 sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" + extra: "{}" mimetype: "text/html" url: "http://www.asheesh.org:80/APUS/ch1/node15.html" timestamp: "2016-09-19T17:20:24Z" @@ -7824,6 +7840,10 @@ definitions: description: "Two-letter RFC1766/ISO639-1 language code, with extensions" publisher: type: "string" + version: + type: "string" + number: + type: "string" pages: type: "string" issue: @@ -7831,6 +7851,10 @@ definitions: example: "12" volume: type: "string" + mag_id: + type: "string" + ark_id: + type: "string" jstor_id: type: "string" arxiv_id: @@ -7848,6 +7872,15 @@ definitions: doi: type: "string" example: "10.1234/abcde.789" + withdrawn_year: + type: "integer" + format: "int64" + example: 2014 + withdrawn_date: + type: "string" + format: "date" + withdrawn_state: + type: "string" release_year: type: "integer" format: "int64" @@ -7855,7 +7888,7 @@ definitions: release_date: type: "string" format: "date" - release_status: + release_stage: type: "string" example: "preprint, retracted" release_type: @@ -7889,6 +7922,10 @@ definitions: type: "string" description: "Title in original language (or, the language of the full text\ \ of this release)" + subtitle: + type: "string" + description: "Avoid this field if possible, and merge with title; usually\ + \ English" title: type: "string" description: "Required for valid entities. The title used in citations and\ @@ -7926,6 +7963,7 @@ definitions: edit_extra: type: "object" example: + mag_id: "mag_id" container: redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" ident: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -7950,14 +7988,18 @@ definitions: - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" surt: "org,asheesh)/apus/ch1/node15.html" status_code: 200 + size_bytes: 1235 sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" + extra: "{}" mimetype: "text/html" url: "http://www.asheesh.org:80/APUS/ch1/node15.html" timestamp: "2016-09-19T17:20:24Z" - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" surt: "org,asheesh)/apus/ch1/node15.html" status_code: 200 + size_bytes: 1235 sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" + extra: "{}" mimetype: "text/html" url: "http://www.asheesh.org:80/APUS/ch1/node15.html" timestamp: "2016-09-19T17:20:24Z" @@ -7981,14 +8023,18 @@ definitions: - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" surt: "org,asheesh)/apus/ch1/node15.html" status_code: 200 + size_bytes: 1235 sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" + extra: "{}" mimetype: "text/html" url: "http://www.asheesh.org:80/APUS/ch1/node15.html" timestamp: "2016-09-19T17:20:24Z" - sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" surt: "org,asheesh)/apus/ch1/node15.html" status_code: 200 + size_bytes: 1235 sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" + extra: "{}" mimetype: "text/html" url: "http://www.asheesh.org:80/APUS/ch1/node15.html" timestamp: "2016-09-19T17:20:24Z" @@ -8004,6 +8050,7 @@ definitions: ident: "q3nouwy3nnbsvo3h5klxsx4a7y" language: "language" title: "title" + withdrawn_state: "withdrawn_state" contribs: - raw_affiliation: "raw_affiliation" creator: @@ -8020,9 +8067,11 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" raw_name: "raw_name" role: "role" + surname: "surname" extra: "{}" creator_id: "q3nouwy3nnbsvo3h5klxsx4a7y" index: 1 + given_name: "given_name" - raw_affiliation: "raw_affiliation" creator: redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -8038,14 +8087,19 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" raw_name: "raw_name" role: "role" + surname: "surname" extra: "{}" creator_id: "q3nouwy3nnbsvo3h5klxsx4a7y" index: 1 + 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" @@ -8064,10 +8118,12 @@ definitions: release_type: "book" wikidata_qid: "wikidata_qid" pmid: "pmid" - release_status: "preprint, retracted" + version: "version" revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" volume: "volume" + release_stage: "preprint, retracted" license_slug: "license_slug" + withdrawn_date: "2000-01-23" refs: - target_release_id: "q3nouwy3nnbsvo3h5klxsx4a7y" container_name: "container_name" @@ -8087,6 +8143,7 @@ definitions: key: "key" release_date: "2000-01-23" isbn13: "isbn13" + subtitle: "subtitle" publisher: "publisher" files: - redirect: "q3nouwy3nnbsvo3h5klxsx4a7y" @@ -9083,6 +9140,10 @@ definitions: $ref: "#/definitions/creator_entity" raw_name: type: "string" + given_name: + type: "string" + surname: + type: "string" role: type: "string" raw_affiliation: @@ -9106,9 +9167,11 @@ definitions: revision: "86daea5b-1b6b-432a-bb67-ea97795f80fe" raw_name: "raw_name" role: "role" + surname: "surname" extra: "{}" creator_id: "q3nouwy3nnbsvo3h5klxsx4a7y" index: 1 + given_name: "given_name" upperCaseName: "RELEASE_CONTRIB" auth_oidc: type: "object" @@ -9243,6 +9306,10 @@ definitions: type: "integer" format: "int64" example: 200 + size_bytes: + type: "integer" + format: "int64" + example: 1235 sha1: type: "string" example: "e9dd75237c94b209dc3ccd52722de6931a310ba3" @@ -9255,11 +9322,15 @@ definitions: minLength: 64 maxLength: 64 pattern: "[a-f0-9]{64}" + extra: + type: "object" example: sha1: "e9dd75237c94b209dc3ccd52722de6931a310ba3" surt: "org,asheesh)/apus/ch1/node15.html" status_code: 200 + size_bytes: 1235 sha256: "cb1c378f464d5935ddaa8de28446d82638396c61f042295d7fb85e3cccc9e452" + extra: "{}" mimetype: "text/html" url: "http://www.asheesh.org:80/APUS/ch1/node15.html" timestamp: "2016-09-19T17:20:24Z" diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index 40a5a3ab..0cb4a920 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -596,6 +596,8 @@ fn main() { 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("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 98f31485..2c67079f 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -848,13 +848,15 @@ impl Api for Server { core_id: Option, arxiv_id: Option, jstor_id: Option, + ark_id: Option, + mag_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, @@ -863,6 +865,8 @@ impl Api for Server { core_id, arxiv_id, jstor_id, + ark_id, + mag_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 6d654146..c4d6b687 100644 --- a/rust/fatcat-api-spec/src/client.rs +++ b/rust/fatcat-api-spec/src/client.rs @@ -6020,6 +6020,8 @@ impl Api for Client { param_core_id: Option, param_arxiv_id: Option, param_jstor_id: Option, + param_ark_id: Option, + param_mag_id: Option, param_expand: Option, param_hide: Option, context: &Context, @@ -6033,11 +6035,13 @@ impl Api for Client { 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_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}{expand}{hide}", + "{}/v0/release/lookup?{doi}{wikidata_qid}{isbn13}{pmid}{pmcid}{core_id}{arxiv_id}{jstor_id}{ark_id}{mag_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), @@ -6047,6 +6051,8 @@ impl Api for Client { 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), 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 59129869..06d3cfdb 100644 --- a/rust/fatcat-api-spec/src/lib.rs +++ b/rust/fatcat-api-spec/src/lib.rs @@ -1580,6 +1580,8 @@ pub trait Api { core_id: Option, arxiv_id: Option, jstor_id: Option, + ark_id: Option, + mag_id: Option, expand: Option, hide: Option, context: &Context, @@ -1866,6 +1868,8 @@ pub trait ApiNoContext { core_id: Option, arxiv_id: Option, jstor_id: Option, + ark_id: Option, + mag_id: Option, expand: Option, hide: Option, ) -> Box + Send>; @@ -2307,11 +2311,13 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { core_id: Option, arxiv_id: Option, jstor_id: Option, + ark_id: Option, + mag_id: Option, expand: Option, hide: Option, ) -> Box + Send> { self.api() - .lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id, expand, hide, &self.context()) + .lookup_release(doi, wikidata_qid, isbn13, pmid, pmcid, core_id, arxiv_id, jstor_id, ark_id, mag_id, 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 f1b657c2..cd418d99 100644 --- a/rust/fatcat-api-spec/src/models.rs +++ b/rust/fatcat-api-spec/src/models.rs @@ -706,6 +706,14 @@ pub struct ReleaseContrib { #[serde(skip_serializing_if = "Option::is_none")] pub raw_name: Option, + #[serde(rename = "given_name")] + #[serde(skip_serializing_if = "Option::is_none")] + pub given_name: Option, + + #[serde(rename = "surname")] + #[serde(skip_serializing_if = "Option::is_none")] + pub surname: Option, + #[serde(rename = "role")] #[serde(skip_serializing_if = "Option::is_none")] pub role: Option, @@ -727,6 +735,8 @@ impl ReleaseContrib { creator_id: None, creator: None, raw_name: None, + given_name: None, + surname: None, role: None, raw_affiliation: None, extra: None, @@ -762,6 +772,14 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub publisher: Option, + #[serde(rename = "version")] + #[serde(skip_serializing_if = "Option::is_none")] + pub version: Option, + + #[serde(rename = "number")] + #[serde(skip_serializing_if = "Option::is_none")] + pub number: Option, + #[serde(rename = "pages")] #[serde(skip_serializing_if = "Option::is_none")] pub pages: Option, @@ -774,6 +792,14 @@ 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, @@ -806,6 +832,18 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub doi: Option, + #[serde(rename = "withdrawn_year")] + #[serde(skip_serializing_if = "Option::is_none")] + pub withdrawn_year: Option, + + #[serde(rename = "withdrawn_date")] + #[serde(skip_serializing_if = "Option::is_none")] + pub withdrawn_date: Option, + + #[serde(rename = "withdrawn_state")] + #[serde(skip_serializing_if = "Option::is_none")] + pub withdrawn_state: Option, + #[serde(rename = "release_year")] #[serde(skip_serializing_if = "Option::is_none")] pub release_year: Option, @@ -814,9 +852,9 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub release_date: Option, - #[serde(rename = "release_status")] + #[serde(rename = "release_stage")] #[serde(skip_serializing_if = "Option::is_none")] - pub release_status: Option, + pub release_stage: Option, #[serde(rename = "release_type")] #[serde(skip_serializing_if = "Option::is_none")] @@ -855,6 +893,11 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub original_title: Option, + /// Avoid this field if possible, and merge with title; usually English + #[serde(rename = "subtitle")] + #[serde(skip_serializing_if = "Option::is_none")] + pub subtitle: Option, + /// Required for valid entities. The title used in citations and for display; usually English #[serde(rename = "title")] #[serde(skip_serializing_if = "Option::is_none")] @@ -898,9 +941,13 @@ impl ReleaseEntity { license_slug: None, language: None, publisher: None, + version: None, + number: None, pages: None, issue: None, volume: None, + mag_id: None, + ark_id: None, jstor_id: None, arxiv_id: None, core_id: None, @@ -909,9 +956,12 @@ impl ReleaseEntity { isbn13: None, wikidata_qid: None, doi: None, + withdrawn_year: None, + withdrawn_date: None, + withdrawn_state: None, release_year: None, release_date: None, - release_status: None, + release_stage: None, release_type: None, container_id: None, webcaptures: None, @@ -920,6 +970,7 @@ impl ReleaseEntity { container: None, work_id: None, original_title: None, + subtitle: None, title: None, state: None, ident: None, @@ -1132,12 +1183,20 @@ pub struct WebcaptureEntityCdx { #[serde(skip_serializing_if = "Option::is_none")] pub status_code: Option, + #[serde(rename = "size_bytes")] + #[serde(skip_serializing_if = "Option::is_none")] + pub size_bytes: Option, + #[serde(rename = "sha1")] pub sha1: String, #[serde(rename = "sha256")] #[serde(skip_serializing_if = "Option::is_none")] pub sha256: Option, + + #[serde(rename = "extra")] + #[serde(skip_serializing_if = "Option::is_none")] + pub extra: Option, } impl WebcaptureEntityCdx { @@ -1148,8 +1207,10 @@ impl WebcaptureEntityCdx { url: url, mimetype: None, status_code: None, + size_bytes: None, sha1: sha1, sha256: None, + extra: None, } } } diff --git a/rust/fatcat-api-spec/src/server.rs b/rust/fatcat-api-spec/src/server.rs index 90b4d19a..7379aed9 100644 --- a/rust/fatcat-api-spec/src/server.rs +++ b/rust/fatcat-api-spec/src/server.rs @@ -8281,6 +8281,8 @@ where 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_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()); @@ -8294,6 +8296,8 @@ where param_core_id, param_arxiv_id, param_jstor_id, + param_ark_id, + param_mag_id, param_expand, param_hide, context, -- cgit v1.2.3