aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-15 21:17:09 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-15 21:17:09 -0700
commit0ed087be71b02d9279bd3b131131eae672580d71 (patch)
treeda4bc59d4db19ae466c86992c1e625bf0797584e /rust
parent9036469324912eae3eed8cb8645f91f1a68c5857 (diff)
downloadfatcat-0ed087be71b02d9279bd3b131131eae672580d71.tar.gz
fatcat-0ed087be71b02d9279bd3b131131eae672580d71.zip
tweak openapi schema
Diffstat (limited to 'rust')
-rw-r--r--rust/fatcat-api/README.md2
-rw-r--r--rust/fatcat-api/api.yaml16
-rw-r--r--rust/fatcat-api/api/swagger.yaml39
-rw-r--r--rust/fatcat-api/examples/client.rs55
-rw-r--r--rust/fatcat-api/examples/server_lib/server.rs10
-rw-r--r--rust/fatcat-api/src/client.rs50
-rw-r--r--rust/fatcat-api/src/lib.rs30
-rw-r--r--rust/fatcat-api/src/models.rs32
-rw-r--r--rust/fatcat-api/src/server.rs37
-rw-r--r--rust/fatcat-openapi2.yml16
10 files changed, 149 insertions, 138 deletions
diff --git a/rust/fatcat-api/README.md b/rust/fatcat-api/README.md
index 01597021..fcbb82f5 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-15T07:25:01.630Z
+- Build date: 2018-05-16T04:14:32.903Z
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 badb17ab..abf09a10 100644
--- a/rust/fatcat-api/api.yaml
+++ b/rust/fatcat-api/api.yaml
@@ -30,7 +30,7 @@ x-entity-props: &ENTITYPROPS
editgroup:
type: integer
x-entity-edit-props: &ENTITYEDITPROPS
- id:
+ edit_id:
type: integer
ident:
type: string
@@ -57,6 +57,8 @@ definitions:
type: string
creator_entity:
type: object
+ required:
+ - name
properties:
<<: *ENTITYPROPS
name:
@@ -66,6 +68,8 @@ definitions:
#format: custom
container_entity:
type: object
+ required:
+ - name
properties:
<<: *ENTITYPROPS
name:
@@ -91,6 +95,8 @@ definitions:
format: url
release_entity:
type: object
+ required:
+ - title
properties:
<<: *ENTITYPROPS
work:
@@ -116,8 +122,6 @@ definitions:
type: object
properties:
<<: *ENTITYPROPS
- title:
- type: string
work_type:
type: string
entity_edit:
@@ -134,7 +138,6 @@ definitions:
editgroup:
type: object
required:
- - id
- editor_id
properties:
id:
@@ -170,6 +173,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/creator_entity"
responses:
@@ -213,6 +217,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/container_entity"
responses:
@@ -256,6 +261,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/file_entity"
responses:
@@ -299,6 +305,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/release_entity"
responses:
@@ -342,6 +349,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/work_entity"
responses:
diff --git a/rust/fatcat-api/api/swagger.yaml b/rust/fatcat-api/api/swagger.yaml
index a24d52f7..8073f18d 100644
--- a/rust/fatcat-api/api/swagger.yaml
+++ b/rust/fatcat-api/api/swagger.yaml
@@ -19,13 +19,13 @@ paths:
parameters:
- in: "body"
name: "body"
- required: false
+ required: true
schema:
$ref: "#/definitions/creator_entity"
uppercase_data_type: "CREATORENTITY"
refName: "creator_entity"
formatString: "{:?}"
- example: "None"
+ example: "???"
model_key: "changelogentry"
uppercase_operation_id: "CREATOR_POST"
consumesJson: true
@@ -62,6 +62,7 @@ paths:
path: "/creator"
HttpMethod: "Post"
httpmethod: "post"
+ noClientExample: true
/creator/{id}:
get:
parameters:
@@ -160,13 +161,13 @@ paths:
parameters:
- in: "body"
name: "body"
- required: false
+ required: true
schema:
$ref: "#/definitions/container_entity"
uppercase_data_type: "CONTAINERENTITY"
refName: "container_entity"
formatString: "{:?}"
- example: "None"
+ example: "???"
model_key: "changelogentry"
uppercase_operation_id: "CONTAINER_POST"
consumesJson: true
@@ -203,6 +204,7 @@ paths:
path: "/container"
HttpMethod: "Post"
httpmethod: "post"
+ noClientExample: true
/container/{id}:
get:
parameters:
@@ -301,13 +303,13 @@ paths:
parameters:
- in: "body"
name: "body"
- required: false
+ required: true
schema:
$ref: "#/definitions/file_entity"
uppercase_data_type: "FILEENTITY"
refName: "file_entity"
formatString: "{:?}"
- example: "None"
+ example: "???"
model_key: "changelogentry"
uppercase_operation_id: "FILE_POST"
consumesJson: true
@@ -344,6 +346,7 @@ paths:
path: "/file"
HttpMethod: "Post"
httpmethod: "post"
+ noClientExample: true
/file/{id}:
get:
parameters:
@@ -442,13 +445,13 @@ paths:
parameters:
- in: "body"
name: "body"
- required: false
+ required: true
schema:
$ref: "#/definitions/release_entity"
uppercase_data_type: "RELEASEENTITY"
refName: "release_entity"
formatString: "{:?}"
- example: "None"
+ example: "???"
model_key: "changelogentry"
uppercase_operation_id: "RELEASE_POST"
consumesJson: true
@@ -485,6 +488,7 @@ paths:
path: "/release"
HttpMethod: "Post"
httpmethod: "post"
+ noClientExample: true
/release/{id}:
get:
parameters:
@@ -583,13 +587,13 @@ paths:
parameters:
- in: "body"
name: "body"
- required: false
+ required: true
schema:
$ref: "#/definitions/work_entity"
uppercase_data_type: "WORKENTITY"
refName: "work_entity"
formatString: "{:?}"
- example: "None"
+ example: "???"
model_key: "changelogentry"
uppercase_operation_id: "WORK_POST"
consumesJson: true
@@ -626,6 +630,7 @@ paths:
path: "/work"
HttpMethod: "Post"
httpmethod: "post"
+ noClientExample: true
/work/{id}:
get:
parameters:
@@ -902,6 +907,8 @@ definitions:
upperCaseName: "SUCCESS"
creator_entity:
type: "object"
+ required:
+ - "name"
properties:
orcid:
type: "string"
@@ -933,6 +940,8 @@ definitions:
upperCaseName: "CREATOR_ENTITY"
container_entity:
type: "object"
+ required:
+ - "name"
properties:
issn:
type: "string"
@@ -1057,8 +1066,6 @@ definitions:
properties:
work_type:
type: "string"
- title:
- type: "string"
editgroup:
type: "integer"
redirect:
@@ -1080,7 +1087,6 @@ definitions:
ident: "ident"
work_type: "work_type"
state: "wip"
- title: "title"
revision: 6
upperCaseName: "WORK_ENTITY"
entity_edit:
@@ -1092,12 +1098,12 @@ definitions:
type: "integer"
ident:
type: "string"
- id:
+ edit_id:
type: "integer"
example:
ident: "ident"
+ edit_id: 1
editgroup_id: 0
- id: 1
revision: 6
upperCaseName: "ENTITY_EDIT"
editor:
@@ -1114,7 +1120,6 @@ definitions:
type: "object"
required:
- "editor_id"
- - "id"
properties:
id:
type: "integer"
@@ -1158,7 +1163,7 @@ x-entity-props:
editgroup:
type: "integer"
x-entity-edit-props:
- id:
+ edit_id:
type: "integer"
ident:
type: "string"
diff --git a/rust/fatcat-api/examples/client.rs b/rust/fatcat-api/examples/client.rs
index 8c1ec930..3302c0cd 100644
--- a/rust/fatcat-api/examples/client.rs
+++ b/rust/fatcat-api/examples/client.rs
@@ -25,10 +25,8 @@ fn main() {
.possible_values(&[
"ContainerIdGet",
"ContainerLookupGet",
- "ContainerPost",
"CreatorIdGet",
"CreatorLookupGet",
- "CreatorPost",
"EditgroupIdAcceptPost",
"EditgroupIdGet",
"EditgroupPost",
@@ -36,12 +34,9 @@ fn main() {
"EditorUsernameGet",
"FileIdGet",
"FileLookupGet",
- "FilePost",
"ReleaseIdGet",
"ReleaseLookupGet",
- "ReleasePost",
"WorkIdGet",
- "WorkPost",
])
.required(true)
.index(1),
@@ -80,11 +75,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
- Some("ContainerPost") => {
- let result = client.container_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
+ // Disabled because there's no example.
+ // Some("ContainerPost") => {
+ // let result = client.container_post(???).wait();
+ // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ // },
Some("CreatorIdGet") => {
let result = client.creator_id_get("id_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
@@ -95,11 +90,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
- Some("CreatorPost") => {
- let result = client.creator_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
+ // Disabled because there's no example.
+ // Some("CreatorPost") => {
+ // let result = client.creator_post(???).wait();
+ // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ // },
Some("EditgroupIdAcceptPost") => {
let result = client.editgroup_id_accept_post(56).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
@@ -135,11 +130,11 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
- Some("FilePost") => {
- let result = client.file_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
+ // Disabled because there's no example.
+ // Some("FilePost") => {
+ // let result = client.file_post(???).wait();
+ // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ // },
Some("ReleaseIdGet") => {
let result = client.release_id_get("id_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
@@ -150,21 +145,21 @@ fn main() {
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
- Some("ReleasePost") => {
- let result = client.release_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
+ // Disabled because there's no example.
+ // Some("ReleasePost") => {
+ // let result = client.release_post(???).wait();
+ // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ // },
Some("WorkIdGet") => {
let result = client.work_id_get("id_example".to_string()).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
- Some("WorkPost") => {
- let result = client.work_post(None).wait();
- println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
- }
-
+ // Disabled because there's no example.
+ // Some("WorkPost") => {
+ // let result = client.work_post(???).wait();
+ // println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
+ // },
_ => panic!("Invalid operation provided"),
}
}
diff --git a/rust/fatcat-api/examples/server_lib/server.rs b/rust/fatcat-api/examples/server_lib/server.rs
index fc0e5174..42b6384f 100644
--- a/rust/fatcat-api/examples/server_lib/server.rs
+++ b/rust/fatcat-api/examples/server_lib/server.rs
@@ -30,7 +30,7 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn container_post(&self, body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
+ fn container_post(&self, body: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("container_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
@@ -48,7 +48,7 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn creator_post(&self, body: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
+ fn creator_post(&self, body: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("creator_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
@@ -100,7 +100,7 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn file_post(&self, body: Option<models::FileEntity>, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
+ fn file_post(&self, body: models::FileEntity, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("file_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
@@ -118,7 +118,7 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn release_post(&self, body: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
+ fn release_post(&self, body: models::ReleaseEntity, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("release_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
@@ -130,7 +130,7 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn work_post(&self, body: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
+ fn work_post(&self, body: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
let context = context.clone();
println!("work_post({:?}) - X-Span-ID: {:?}", body, 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 06633ad9..6666d6f4 100644
--- a/rust/fatcat-api/src/client.rs
+++ b/rust/fatcat-api/src/client.rs
@@ -277,18 +277,16 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn container_post(&self, param_body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
+ fn container_post(&self, param_body: models::ContainerEntity, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
let url = format!("{}/v0/container", self.base_path);
- let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
+ let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
+
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = match body {
- Some(ref body) => request.body(body),
- None => request,
- };
+ let request = request.body(&body);
custom_headers.set(ContentType(mimetypes::requests::CONTAINER_POST.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
@@ -453,18 +451,16 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn creator_post(&self, param_body: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
+ fn creator_post(&self, param_body: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
let url = format!("{}/v0/creator", self.base_path);
- let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
+ let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
+
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = match body {
- Some(ref body) => request.body(body),
- None => request,
- };
+ let request = request.body(&body);
custom_headers.set(ContentType(mimetypes::requests::CREATOR_POST.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
@@ -909,18 +905,16 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn file_post(&self, param_body: Option<models::FileEntity>, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
+ fn file_post(&self, param_body: models::FileEntity, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
let url = format!("{}/v0/file", self.base_path);
- let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
+ let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
+
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = match body {
- Some(ref body) => request.body(body),
- None => request,
- };
+ let request = request.body(&body);
custom_headers.set(ContentType(mimetypes::requests::FILE_POST.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
@@ -1085,18 +1079,16 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn release_post(&self, param_body: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
+ fn release_post(&self, param_body: models::ReleaseEntity, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
let url = format!("{}/v0/release", self.base_path);
- let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
+ let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
+
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = match body {
- Some(ref body) => request.body(body),
- None => request,
- };
+ let request = request.body(&body);
custom_headers.set(ContentType(mimetypes::requests::RELEASE_POST.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
@@ -1198,18 +1190,16 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn work_post(&self, param_body: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
+ fn work_post(&self, param_body: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
let url = format!("{}/v0/work", self.base_path);
- let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize"));
+ let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
+
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = match body {
- Some(ref body) => request.body(body),
- None => request,
- };
+ let request = request.body(&body);
custom_headers.set(ContentType(mimetypes::requests::WORK_POST.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs
index a01189ef..151c3a4a 100644
--- a/rust/fatcat-api/src/lib.rs
+++ b/rust/fatcat-api/src/lib.rs
@@ -238,13 +238,13 @@ pub trait Api {
fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>;
- fn container_post(&self, body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>;
+ fn container_post(&self, body: 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: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>;
+ fn creator_post(&self, body: models::CreatorEntity, context: &Context) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>;
fn editgroup_id_accept_post(&self, id: i32, context: &Context) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send>;
@@ -260,17 +260,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: Option<models::FileEntity>, context: &Context) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>;
+ fn file_post(&self, body: 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: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>;
+ fn release_post(&self, body: 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: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>;
+ fn work_post(&self, body: models::WorkEntity, context: &Context) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>;
}
/// API without a `Context`
@@ -279,13 +279,13 @@ pub trait ApiNoContext {
fn container_lookup_get(&self, issn: String) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError> + Send>;
- fn container_post(&self, body: Option<models::ContainerEntity>) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send>;
+ fn container_post(&self, body: 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: Option<models::CreatorEntity>) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>;
+ fn creator_post(&self, body: models::CreatorEntity) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send>;
fn editgroup_id_accept_post(&self, id: i32) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError> + Send>;
@@ -301,17 +301,17 @@ pub trait ApiNoContext {
fn file_lookup_get(&self, sha1: String) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError> + Send>;
- fn file_post(&self, body: Option<models::FileEntity>) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send>;
+ fn file_post(&self, body: 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: Option<models::ReleaseEntity>) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send>;
+ fn release_post(&self, body: 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: Option<models::WorkEntity>) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>;
+ fn work_post(&self, body: models::WorkEntity) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send>;
}
/// Trait to extend an API to make it easy to bind it to a context.
@@ -338,7 +338,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().container_lookup_get(issn, &self.context())
}
- fn container_post(&self, body: Option<models::ContainerEntity>) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
+ fn container_post(&self, body: models::ContainerEntity) -> Box<Future<Item = ContainerPostResponse, Error = ApiError> + Send> {
self.api().container_post(body, &self.context())
}
@@ -350,7 +350,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().creator_lookup_get(orcid, &self.context())
}
- fn creator_post(&self, body: Option<models::CreatorEntity>) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
+ fn creator_post(&self, body: models::CreatorEntity) -> Box<Future<Item = CreatorPostResponse, Error = ApiError> + Send> {
self.api().creator_post(body, &self.context())
}
@@ -382,7 +382,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().file_lookup_get(sha1, &self.context())
}
- fn file_post(&self, body: Option<models::FileEntity>) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
+ fn file_post(&self, body: models::FileEntity) -> Box<Future<Item = FilePostResponse, Error = ApiError> + Send> {
self.api().file_post(body, &self.context())
}
@@ -394,7 +394,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().release_lookup_get(doi, &self.context())
}
- fn release_post(&self, body: Option<models::ReleaseEntity>) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
+ fn release_post(&self, body: models::ReleaseEntity) -> Box<Future<Item = ReleasePostResponse, Error = ApiError> + Send> {
self.api().release_post(body, &self.context())
}
@@ -402,7 +402,7 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().work_id_get(id, &self.context())
}
- fn work_post(&self, body: Option<models::WorkEntity>) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
+ fn work_post(&self, body: models::WorkEntity) -> Box<Future<Item = WorkPostResponse, Error = ApiError> + Send> {
self.api().work_post(body, &self.context())
}
}
diff --git a/rust/fatcat-api/src/models.rs b/rust/fatcat-api/src/models.rs
index 5e5be35f..b6f450aa 100644
--- a/rust/fatcat-api/src/models.rs
+++ b/rust/fatcat-api/src/models.rs
@@ -47,8 +47,7 @@ pub struct ContainerEntity {
pub parent: Option<String>,
#[serde(rename = "name")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub name: Option<String>,
+ pub name: String,
// Note: inline enums are not fully supported by swagger-codegen
#[serde(rename = "state")]
@@ -73,12 +72,12 @@ pub struct ContainerEntity {
}
impl ContainerEntity {
- pub fn new() -> ContainerEntity {
+ pub fn new(name: String) -> ContainerEntity {
ContainerEntity {
issn: None,
publisher: None,
parent: None,
- name: None,
+ name: name,
state: None,
ident: None,
revision: None,
@@ -95,8 +94,7 @@ pub struct CreatorEntity {
pub orcid: Option<String>,
#[serde(rename = "name")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub name: Option<String>,
+ pub name: String,
#[serde(rename = "editgroup")]
#[serde(skip_serializing_if = "Option::is_none")]
@@ -121,10 +119,10 @@ pub struct CreatorEntity {
}
impl CreatorEntity {
- pub fn new() -> CreatorEntity {
+ pub fn new(name: String) -> CreatorEntity {
CreatorEntity {
orcid: None,
- name: None,
+ name: name,
editgroup: None,
redirect: None,
revision: None,
@@ -137,15 +135,16 @@ impl CreatorEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Editgroup {
#[serde(rename = "id")]
- pub id: isize,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub id: Option<isize>,
#[serde(rename = "editor_id")]
pub editor_id: isize,
}
impl Editgroup {
- pub fn new(id: isize, editor_id: isize) -> Editgroup {
- Editgroup { id: id, editor_id: editor_id }
+ pub fn new(editor_id: isize) -> Editgroup {
+ Editgroup { id: None, editor_id: editor_id }
}
}
@@ -175,9 +174,9 @@ pub struct EntityEdit {
#[serde(skip_serializing_if = "Option::is_none")]
pub ident: Option<String>,
- #[serde(rename = "id")]
+ #[serde(rename = "edit_id")]
#[serde(skip_serializing_if = "Option::is_none")]
- pub id: Option<isize>,
+ pub edit_id: Option<isize>,
}
impl EntityEdit {
@@ -186,7 +185,7 @@ impl EntityEdit {
editgroup_id: None,
revision: None,
ident: None,
- id: None,
+ edit_id: None,
}
}
}
@@ -348,10 +347,6 @@ pub struct WorkEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub work_type: Option<String>,
- #[serde(rename = "title")]
- #[serde(skip_serializing_if = "Option::is_none")]
- pub title: Option<String>,
-
#[serde(rename = "editgroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editgroup: Option<isize>,
@@ -378,7 +373,6 @@ impl WorkEntity {
pub fn new() -> WorkEntity {
WorkEntity {
work_type: None,
- title: None,
editgroup: None,
redirect: None,
revision: None,
diff --git a/rust/fatcat-api/src/server.rs b/rust/fatcat-api/src/server.rs
index 5e799bd4..94668aa9 100644
--- a/rust/fatcat-api/src/server.rs
+++ b/rust/fatcat-api/src/server.rs
@@ -268,22 +268,25 @@ where
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_body = req.get::<bodyparser::Raw>().unwrap_or(None);
+ 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 mut unused_elements = Vec::new();
let param_body = if let Some(param_body_raw) = param_body {
let deserializer = &mut serde_json::Deserializer::from_str(&param_body_raw);
- let param_body: Option<models::ContainerEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- }).unwrap_or(None);
+ let param_body: 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))))?;
param_body
} else {
None
};
+ let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?;
match api.container_post(param_body, context).wait() {
Ok(rsp) => match rsp {
@@ -523,7 +526,8 @@ where
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_body = req.get::<bodyparser::Raw>().unwrap_or(None);
+ 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 mut unused_elements = Vec::new();
@@ -533,12 +537,13 @@ where
let param_body: Option<models::CreatorEntity> = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
- }).unwrap_or(None);
+ }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?;
param_body
} else {
None
};
+ let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?;
match api.creator_post(param_body, context).wait() {
Ok(rsp) => match rsp {
@@ -1168,7 +1173,8 @@ where
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_body = req.get::<bodyparser::Raw>().unwrap_or(None);
+ 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 mut unused_elements = Vec::new();
@@ -1178,12 +1184,13 @@ where
let param_body: Option<models::FileEntity> = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
- }).unwrap_or(None);
+ }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?;
param_body
} else {
None
};
+ let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?;
match api.file_post(param_body, context).wait() {
Ok(rsp) => match rsp {
@@ -1423,7 +1430,8 @@ where
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_body = req.get::<bodyparser::Raw>().unwrap_or(None);
+ 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 mut unused_elements = Vec::new();
@@ -1433,12 +1441,13 @@ where
let param_body: Option<models::ReleaseEntity> = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
- }).unwrap_or(None);
+ }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?;
param_body
} else {
None
};
+ let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?;
match api.release_post(param_body, context).wait() {
Ok(rsp) => match rsp {
@@ -1592,7 +1601,8 @@ where
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_body = req.get::<bodyparser::Raw>().unwrap_or(None);
+ 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 mut unused_elements = Vec::new();
@@ -1602,12 +1612,13 @@ where
let param_body: Option<models::WorkEntity> = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
- }).unwrap_or(None);
+ }).map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter body - doesn't match schema: {}", e))))?;
param_body
} else {
None
};
+ let param_body = param_body.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter body".to_string())))?;
match api.work_post(param_body, context).wait() {
Ok(rsp) => match rsp {
diff --git a/rust/fatcat-openapi2.yml b/rust/fatcat-openapi2.yml
index badb17ab..abf09a10 100644
--- a/rust/fatcat-openapi2.yml
+++ b/rust/fatcat-openapi2.yml
@@ -30,7 +30,7 @@ x-entity-props: &ENTITYPROPS
editgroup:
type: integer
x-entity-edit-props: &ENTITYEDITPROPS
- id:
+ edit_id:
type: integer
ident:
type: string
@@ -57,6 +57,8 @@ definitions:
type: string
creator_entity:
type: object
+ required:
+ - name
properties:
<<: *ENTITYPROPS
name:
@@ -66,6 +68,8 @@ definitions:
#format: custom
container_entity:
type: object
+ required:
+ - name
properties:
<<: *ENTITYPROPS
name:
@@ -91,6 +95,8 @@ definitions:
format: url
release_entity:
type: object
+ required:
+ - title
properties:
<<: *ENTITYPROPS
work:
@@ -116,8 +122,6 @@ definitions:
type: object
properties:
<<: *ENTITYPROPS
- title:
- type: string
work_type:
type: string
entity_edit:
@@ -134,7 +138,6 @@ definitions:
editgroup:
type: object
required:
- - id
- editor_id
properties:
id:
@@ -170,6 +173,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/creator_entity"
responses:
@@ -213,6 +217,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/container_entity"
responses:
@@ -256,6 +261,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/file_entity"
responses:
@@ -299,6 +305,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/release_entity"
responses:
@@ -342,6 +349,7 @@ paths:
parameters:
- name: body
in: body
+ required: true
schema:
$ref: "#/definitions/work_entity"
responses: