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:
parent
84c942111e
commit
415b280ae5
2 changed files with 13 additions and 4 deletions
|
@ -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"}}"#);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue