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:
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();
|
let mut responses : IndexMap<StatusCode, ReferenceOr<Response>> = IndexMap::new();
|
||||||
responses.insert(StatusCode::Code(default_status.as_u16()), Item(Response {
|
responses.insert(StatusCode::Code(default_status.as_u16()), Item(Response {
|
||||||
description: default_status.canonical_reason().map(|d| d.to_string()).unwrap_or_default(),
|
description: default_status.canonical_reason().map(|d| d.to_string()).unwrap_or_default(),
|
||||||
headers: IndexMap::new(),
|
|
||||||
content,
|
content,
|
||||||
links: IndexMap::new()
|
..Default::default()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let request_body = body_schema.map(|schema| Item(OARequestBody {
|
let request_body = body_schema.map(|schema| Item(OARequestBody {
|
||||||
|
@ -540,7 +539,7 @@ mod test
|
||||||
{
|
{
|
||||||
let types = NoContent::accepted_types();
|
let types = NoContent::accepted_types();
|
||||||
let schema = <NoContent as OpenapiType>::schema();
|
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());
|
assert!(content.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +548,7 @@ mod test
|
||||||
{
|
{
|
||||||
let types = Raw::<&str>::accepted_types();
|
let types = Raw::<&str>::accepted_types();
|
||||||
let schema = <Raw<&str> as OpenapiType>::schema();
|
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);
|
assert_eq!(content.len(), 1);
|
||||||
let json = serde_json::to_string(&content.values().nth(0).unwrap()).unwrap();
|
let json = serde_json::to_string(&content.values().nth(0).unwrap()).unwrap();
|
||||||
assert_eq!(json, r#"{"schema":{"type":"string","format":"binary"}}"#);
|
assert_eq!(json, r#"{"schema":{"type":"string","format":"binary"}}"#);
|
||||||
|
|
|
@ -384,6 +384,11 @@ impl ResourceResult for NoContent
|
||||||
Ok(Response::no_content())
|
Ok(Response::no_content())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn accepted_types() -> Option<Vec<Mime>>
|
||||||
|
{
|
||||||
|
Some(Vec::new())
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the schema of the `()` type.
|
/// Returns the schema of the `()` type.
|
||||||
#[cfg(feature = "openapi")]
|
#[cfg(feature = "openapi")]
|
||||||
fn schema() -> OpenapiSchema
|
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")]
|
#[cfg(feature = "openapi")]
|
||||||
fn schema() -> OpenapiSchema
|
fn schema() -> OpenapiSchema
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue