diff options
Diffstat (limited to 'rust/fatcat-api')
-rw-r--r-- | rust/fatcat-api/README.md | 2 | ||||
-rw-r--r-- | rust/fatcat-api/api.yaml | 23 | ||||
-rw-r--r-- | rust/fatcat-api/api/swagger.yaml | 42 | ||||
-rw-r--r-- | rust/fatcat-api/examples/client.rs | 2 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server_lib/server.rs | 4 | ||||
-rw-r--r-- | rust/fatcat-api/src/client.rs | 6 | ||||
-rw-r--r-- | rust/fatcat-api/src/lib.rs | 8 | ||||
-rw-r--r-- | rust/fatcat-api/src/models.rs | 45 | ||||
-rw-r--r-- | rust/fatcat-api/src/server.rs | 12 |
9 files changed, 99 insertions, 45 deletions
diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md index 146758fb..1c409076 100644 --- a/rust/fatcat-api/README.md +++ b/rust/fatcat-api/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-05-26T02:33:00.709Z +- Build date: 2018-05-27T00:04:18.431Z This autogenerated project defines an API crate `fatcat` which contains: * An `Api` trait defining the API in Rust. diff --git a/rust/fatcat-api/api.yaml b/rust/fatcat-api/api.yaml index 146c11dd..585932b3 100644 --- a/rust/fatcat-api/api.yaml +++ b/rust/fatcat-api/api.yaml @@ -83,10 +83,10 @@ definitions: creator_entity: type: object required: - - name + - full_name properties: <<: *ENTITYPROPS - name: + full_name: type: string example: "Grace Hopper" orcid: @@ -105,10 +105,14 @@ definitions: publisher: type: string example: "Society of Curious Students" - issn: + issnl: type: string #format: custom example: "1234-5678" + abbrev: + type: string + coden: + type: string file_entity: type: object properties: @@ -121,6 +125,10 @@ definitions: type: string #format: custom example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" + md5: + type: string + #format: custom + example: "d41efcc592d1e40ac13905377399eb9b" url: type: string format: url @@ -155,6 +163,9 @@ definitions: type: string #format: custom example: "10.1234/abcde.789" + isbn13: + type: string + #format: custom volume: type: string pages: @@ -162,6 +173,8 @@ definitions: issue: type: string example: "12" + publisher: + type: string contribs: type: array items: @@ -271,7 +284,7 @@ definitions: #format: uuid creator_stub: type: string - contrib_type: + role: type: string x-entity-responses: &ENTITYRESPONSES @@ -359,7 +372,7 @@ paths: /container/lookup: get: parameters: - - name: issn + - name: issnl in: query type: string required: true diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml index db7b0e03..e6b4b356 100644 --- a/rust/fatcat-api/api/swagger.yaml +++ b/rust/fatcat-api/api/swagger.yaml @@ -285,12 +285,12 @@ paths: /container/lookup: get: parameters: - - name: "issn" + - name: "issnl" in: "query" required: true type: "string" formatString: "\\\"{}\\\"" - example: "\"issn_example\".to_string()" + example: "\"issnl_example\".to_string()" responses: 200: description: "Found Entity" @@ -1023,12 +1023,12 @@ definitions: creator_entity: type: "object" required: - - "name" + - "full_name" properties: orcid: type: "string" example: "0000-0002-1825-0097" - name: + full_name: type: "string" example: "Grace Hopper" extra: @@ -1056,9 +1056,9 @@ definitions: - "deleted" example: redirect: "f1f046a3-45c9-4b99-adce-000000000002" + full_name: "Grace Hopper" ident: "f1f046a3-45c9-4b99-adce-000000000001" extra: "{}" - name: "Grace Hopper" editgroup_id: 16 orcid: "0000-0002-1825-0097" state: "wip" @@ -1069,7 +1069,11 @@ definitions: required: - "name" properties: - issn: + coden: + type: "string" + abbrev: + type: "string" + issnl: type: "string" example: "1234-5678" publisher: @@ -1103,12 +1107,14 @@ definitions: type: "object" example: redirect: "f1f046a3-45c9-4b99-adce-000000000002" - issn: "1234-5678" + coden: "coden" ident: "f1f046a3-45c9-4b99-adce-000000000001" extra: "{}" name: "Journal of Important Results" publisher: "Society of Curious Students" editgroup_id: 16 + issnl: "1234-5678" + abbrev: "abbrev" state: "wip" revision: 42 upperCaseName: "CONTAINER_ENTITY" @@ -1123,6 +1129,9 @@ definitions: type: "string" format: "url" example: "https://example.edu/~frau/prcding.pdf" + md5: + type: "string" + example: "d41efcc592d1e40ac13905377399eb9b" sha1: type: "string" example: "f013d66c7f6817d08b7eb2a93e6d0440c1f3e7f8" @@ -1165,6 +1174,7 @@ definitions: releases: - "releases" - "releases" + md5: "d41efcc592d1e40ac13905377399eb9b" revision: 42 upperCaseName: "FILE_ENTITY" release_entity: @@ -1181,6 +1191,8 @@ definitions: type: "array" items: $ref: "#/definitions/release_contrib" + publisher: + type: "string" issue: type: "string" example: "12" @@ -1188,6 +1200,8 @@ definitions: type: "string" volume: type: "string" + isbn13: + type: "string" doi: type: "string" example: "10.1234/abcde.789" @@ -1237,14 +1251,14 @@ definitions: release_type: "preprint" title: "title" contribs: - - creator_stub: "creator_stub" + - role: "role" + creator_stub: "creator_stub" creator_id: "creator_id" index: 6 - contrib_type: "contrib_type" - - creator_stub: "creator_stub" + - role: "role" + creator_stub: "creator_stub" creator_id: "creator_id" index: 6 - contrib_type: "contrib_type" revision: 42 volume: "volume" pages: "pages" @@ -1255,7 +1269,9 @@ definitions: - target_release_id: "target_release_id" stub: "stub" index: 0 + isbn13: "isbn13" extra: "{}" + publisher: "publisher" editgroup_id: 16 state: "wip" container_id: "f1f046a3-45c9-4b99-adce-000000000001" @@ -1463,13 +1479,13 @@ definitions: type: "string" creator_stub: type: "string" - contrib_type: + role: type: "string" example: + role: "role" creator_stub: "creator_stub" creator_id: "creator_id" index: 6 - contrib_type: "contrib_type" upperCaseName: "RELEASE_CONTRIB" editgroup_edits: properties: diff --git a/rust/fatcat-api/examples/client.rs b/rust/fatcat-api/examples/client.rs index 396cf3d1..f2eccb9e 100644 --- a/rust/fatcat-api/examples/client.rs +++ b/rust/fatcat-api/examples/client.rs @@ -70,7 +70,7 @@ fn main() { } Some("ContainerLookupGet") => { - let result = client.container_lookup_get("issn_example".to_string()).wait(); + let result = client.container_lookup_get("issnl_example".to_string()).wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); } diff --git a/rust/fatcat-api/examples/server_lib/server.rs b/rust/fatcat-api/examples/server_lib/server.rs index 68670c07..a28b9c72 100644 --- a/rust/fatcat-api/examples/server_lib/server.rs +++ b/rust/fatcat-api/examples/server_lib/server.rs @@ -24,9 +24,9 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { + fn container_lookup_get(&self, issnl: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { let context = context.clone(); - println!("container_lookup_get(\"{}\") - X-Span-ID: {:?}", issn, context.x_span_id.unwrap_or(String::from("<none>")).clone()); + println!("container_lookup_get(\"{}\") - X-Span-ID: {:?}", issnl, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 517d9705..23f6dd21 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -221,11 +221,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn container_lookup_get(&self, param_issn: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { + fn container_lookup_get(&self, param_issnl: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { // Query parameters - let query_issn = format!("issn={issn}&", issn = param_issn.to_string()); + let query_issnl = format!("issnl={issnl}&", issnl = param_issnl.to_string()); - let url = format!("{}/v0/container/lookup?{issn}", self.base_path, issn = utf8_percent_encode(&query_issn, QUERY_ENCODE_SET)); + let url = format!("{}/v0/container/lookup?{issnl}", self.base_path, issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs index 94633e00..a21a0751 100644 --- a/rust/fatcat-api/src/lib.rs +++ b/rust/fatcat-api/src/lib.rs @@ -258,7 +258,7 @@ pub enum WorkPostResponse { pub trait Api { fn container_id_get(&self, id: String, context: &Context) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>; - fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; + 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>; @@ -299,7 +299,7 @@ pub trait Api { pub trait ApiNoContext { fn container_id_get(&self, id: String) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError> + Send>; - fn container_lookup_get(&self, issn: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>; + 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>; @@ -356,8 +356,8 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { self.api().container_id_get(id, &self.context()) } - fn container_lookup_get(&self, issn: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { - self.api().container_lookup_get(issn, &self.context()) + fn container_lookup_get(&self, issnl: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send> { + self.api().container_lookup_get(issnl, &self.context()) } fn container_post(&self, body: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> { diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs index 68242058..b05c0fc1 100644 --- a/rust/fatcat-api/src/models.rs +++ b/rust/fatcat-api/src/models.rs @@ -94,9 +94,17 @@ impl ChangelogentriesInner { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ContainerEntity { - #[serde(rename = "issn")] + #[serde(rename = "coden")] #[serde(skip_serializing_if = "Option::is_none")] - pub issn: Option<String>, + pub coden: Option<String>, + + #[serde(rename = "abbrev")] + #[serde(skip_serializing_if = "Option::is_none")] + pub abbrev: Option<String>, + + #[serde(rename = "issnl")] + #[serde(skip_serializing_if = "Option::is_none")] + pub issnl: Option<String>, #[serde(rename = "publisher")] #[serde(skip_serializing_if = "Option::is_none")] @@ -134,7 +142,9 @@ pub struct ContainerEntity { impl ContainerEntity { pub fn new(name: String) -> ContainerEntity { ContainerEntity { - issn: None, + coden: None, + abbrev: None, + issnl: None, publisher: None, name: name, state: None, @@ -153,8 +163,8 @@ pub struct CreatorEntity { #[serde(skip_serializing_if = "Option::is_none")] pub orcid: Option<String>, - #[serde(rename = "name")] - pub name: String, + #[serde(rename = "full_name")] + pub full_name: String, #[serde(rename = "extra")] #[serde(skip_serializing_if = "Option::is_none")] @@ -183,10 +193,10 @@ pub struct CreatorEntity { } impl CreatorEntity { - pub fn new(name: String) -> CreatorEntity { + pub fn new(full_name: String) -> CreatorEntity { CreatorEntity { orcid: None, - name: name, + full_name: full_name, extra: None, editgroup_id: None, redirect: None, @@ -337,6 +347,10 @@ pub struct FileEntity { #[serde(skip_serializing_if = "Option::is_none")] pub url: Option<String>, + #[serde(rename = "md5")] + #[serde(skip_serializing_if = "Option::is_none")] + pub md5: Option<String>, + #[serde(rename = "sha1")] #[serde(skip_serializing_if = "Option::is_none")] pub sha1: Option<String>, @@ -376,6 +390,7 @@ impl FileEntity { FileEntity { releases: None, url: None, + md5: None, sha1: None, size: None, extra: None, @@ -402,9 +417,9 @@ pub struct ReleaseContrib { #[serde(skip_serializing_if = "Option::is_none")] pub creator_stub: Option<String>, - #[serde(rename = "contrib_type")] + #[serde(rename = "role")] #[serde(skip_serializing_if = "Option::is_none")] - pub contrib_type: Option<String>, + pub role: Option<String>, } impl ReleaseContrib { @@ -413,7 +428,7 @@ impl ReleaseContrib { index: None, creator_id: None, creator_stub: None, - contrib_type: None, + role: None, } } } @@ -428,6 +443,10 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub contribs: Option<Vec<models::ReleaseContrib>>, + #[serde(rename = "publisher")] + #[serde(skip_serializing_if = "Option::is_none")] + pub publisher: Option<String>, + #[serde(rename = "issue")] #[serde(skip_serializing_if = "Option::is_none")] pub issue: Option<String>, @@ -440,6 +459,10 @@ pub struct ReleaseEntity { #[serde(skip_serializing_if = "Option::is_none")] pub volume: Option<String>, + #[serde(rename = "isbn13")] + #[serde(skip_serializing_if = "Option::is_none")] + pub isbn13: Option<String>, + #[serde(rename = "doi")] #[serde(skip_serializing_if = "Option::is_none")] pub doi: Option<String>, @@ -493,9 +516,11 @@ impl ReleaseEntity { ReleaseEntity { refs: None, contribs: None, + publisher: None, issue: None, pages: None, volume: None, + isbn13: None, doi: None, date: None, release_type: None, diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs index 95829602..ed012478 100644 --- a/rust/fatcat-api/src/server.rs +++ b/rust/fatcat-api/src/server.rs @@ -190,15 +190,15 @@ where // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default(); - let param_issn = query_params - .get("issn") - .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter issn".to_string())))? + let param_issnl = query_params + .get("issnl") + .ok_or_else(|| Response::with((status::BadRequest, "Missing required query parameter issnl".to_string())))? .first() - .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter issn was empty".to_string())))? + .ok_or_else(|| Response::with((status::BadRequest, "Required query parameter issnl was empty".to_string())))? .parse::<String>() - .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter issn - doesn't match schema: {}", e))))?; + .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse query parameter issnl - doesn't match schema: {}", e))))?; - match api.container_lookup_get(param_issn, context).wait() { + match api.container_lookup_get(param_issnl, context).wait() { Ok(rsp) => match rsp { ContainerLookupGetResponse::FoundEntity(body) => { let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize"); |