1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-02-22 12:42:28 +00:00

fix no schema having content

This commit is contained in:
Dominic 2020-04-22 11:18:10 +02:00
parent 84c942111e
commit 415b280ae5
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
2 changed files with 13 additions and 4 deletions

View file

@ -314,9 +314,8 @@ fn new_operation(
let mut responses : IndexMap<StatusCode, ReferenceOr<Response>> = IndexMap::new();
responses.insert(StatusCode::Code(default_status.as_u16()), Item(Response {
description: default_status.canonical_reason().map(|d| d.to_string()).unwrap_or_default(),
headers: IndexMap::new(),
content,
links: IndexMap::new()
..Default::default()
}));
let request_body = body_schema.map(|schema| Item(OARequestBody {
@ -540,7 +539,7 @@ mod test
{
let types = NoContent::accepted_types();
let schema = <NoContent as OpenapiType>::schema();
let content = schema_to_content(types.unwrap_or_default(), Item(schema.into_schema()));
let content = schema_to_content(types.unwrap_or_else(|| vec![STAR_STAR]), Item(schema.into_schema()));
assert!(content.is_empty());
}
@ -549,7 +548,7 @@ mod test
{
let types = Raw::<&str>::accepted_types();
let schema = <Raw<&str> as OpenapiType>::schema();
let content = schema_to_content(types.unwrap_or_default(), Item(schema.into_schema()));
let content = schema_to_content(types.unwrap_or_else(|| vec![STAR_STAR]), Item(schema.into_schema()));
assert_eq!(content.len(), 1);
let json = serde_json::to_string(&content.values().nth(0).unwrap()).unwrap();
assert_eq!(json, r#"{"schema":{"type":"string","format":"binary"}}"#);

View file

@ -384,6 +384,11 @@ impl ResourceResult for NoContent
Ok(Response::no_content())
}
fn accepted_types() -> Option<Vec<Mime>>
{
Some(Vec::new())
}
/// Returns the schema of the `()` type.
#[cfg(feature = "openapi")]
fn schema() -> OpenapiSchema
@ -412,6 +417,11 @@ impl<E : Error> ResourceResult for Result<NoContent, E>
}
}
fn accepted_types() -> Option<Vec<Mime>>
{
NoContent::accepted_types()
}
#[cfg(feature = "openapi")]
fn schema() -> OpenapiSchema
{