1
0
Fork 0
mirror of https://gitlab.com/msrd0/gotham-restful.git synced 2025-02-22 20:52:27 +00:00

fix no schema having content

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

View file

@ -317,9 +317,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 {
@ -552,7 +551,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());
}
@ -561,7 +560,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

@ -483,6 +483,11 @@ impl ResourceResult for NoContent
future::ok(Response::no_content()).boxed()
}
fn accepted_types() -> Option<Vec<Mime>>
{
Some(Vec::new())
}
/// Returns the schema of the `()` type.
#[cfg(feature = "openapi")]
fn schema() -> OpenapiSchema
@ -515,6 +520,11 @@ where
}
}
fn accepted_types() -> Option<Vec<Mime>>
{
NoContent::accepted_types()
}
#[cfg(feature = "openapi")]
fn schema() -> OpenapiSchema
{