diff --git a/rocket-okapi/src/request/from_data_impls.rs b/rocket-okapi/src/request/from_data_impls.rs index 44471f73..88c32198 100644 --- a/rocket-okapi/src/request/from_data_impls.rs +++ b/rocket-okapi/src/request/from_data_impls.rs @@ -22,7 +22,7 @@ impl<'a, T: JsonSchema + Deserialize<'a>> OpenApiFromData<'a> for Json { "application/json".to_owned(), MediaType { schema: Some(schema), - ..okapi::openapi3::MediaType::default() + ..MediaType::default() }, ); map @@ -58,7 +58,7 @@ impl<'a> OpenApiFromData<'a> for Data<'a> { "application/octet-stream".to_owned(), MediaType { schema: Some(schema), - ..okapi::openapi3::MediaType::default() + ..MediaType::default() }, ); map diff --git a/rocket-okapi/src/response/responder_impls.rs b/rocket-okapi/src/response/responder_impls.rs index c7a4e9d9..376b48c2 100644 --- a/rocket-okapi/src/response/responder_impls.rs +++ b/rocket-okapi/src/response/responder_impls.rs @@ -11,8 +11,6 @@ use rocket::fs::NamedFile; use rocket::serde::json::{Json, Value}; use schemars::JsonSchema; use serde::Serialize; -use std::fmt::Debug; -use std::result::Result as StdResult; type Result = crate::Result; @@ -108,21 +106,10 @@ macro_rules! status_responder { status_responder!(Accepted, 202); status_responder!(Created, 201); status_responder!(BadRequest, 400); -// status_responder!(Unauthorized, 401); -// status_responder!(Forbidden, 403); +status_responder!(Unauthorized, 401); +status_responder!(Forbidden, 403); status_responder!(NotFound, 404); -// impl<'r, T> OpenApiResponderInner<'r> for rocket::response::status::Custom -// where -// T: OpenApiResponderInner<'r> + Send -// { -// fn responses(_: &mut OpenApiGenerator) -> Result { -// let mut responses = Responses::default(); -// set_status_code(&mut responses, xxx)?; -// Ok(responses) -// } -// } - macro_rules! response_content_wrapper { ($responder: ident, $mime: literal) => { impl OpenApiResponderInner @@ -145,34 +132,10 @@ response_content_wrapper!(MsgPack, "application/msgpack"); response_content_wrapper!(Plain, "text/plain"); response_content_wrapper!(Xml, "text/xml"); -// impl<'r, T, E> OpenApiResponderInner<'r> for StdResult -// where -// T: OpenApiResponderInner<'r> + Send, -// E: Debug + Send -// { -// default fn responses(gen: &mut OpenApiGenerator) -> Result { -// let mut responses = T::responses(gen)?; -// ensure_status_code_exists(&mut responses, 500); -// Ok(responses) -// } -// } - -/* -impl<'r, 'o, T, E> OpenApiResponderInner for StdResult -where - T: OpenApiResponderInner + Send, - E: Responder<'r, 'o> + Debug + Send + 'r, -{ - default fn responses(_: &mut OpenApiGenerator) -> Result { - Err(OpenApiError::new("Unable to generate OpenAPI spec for Result response, as E implements Responder but not OpenApiResponderInner.".to_owned())) - } -} -*/ - -impl<'r, 'o, T, E> OpenApiResponderInner for StdResult +impl<'r, 'o, T, E> OpenApiResponderInner for std::result::Result where T: OpenApiResponderInner, - E: OpenApiResponderInner + Debug, + E: OpenApiResponderInner, { fn responses(gen: &mut OpenApiGenerator) -> Result { let ok_responses = T::responses(gen)?; diff --git a/rocket-okapi/src/util.rs b/rocket-okapi/src/util.rs index 34796c5e..f9200b91 100644 --- a/rocket-okapi/src/util.rs +++ b/rocket-okapi/src/util.rs @@ -78,7 +78,7 @@ pub fn add_schema_response( ) -> Result<()> { let media = MediaType { schema: Some(schema), - ..okapi::openapi3::MediaType::default() + ..MediaType::default() }; add_content_response(responses, status, content_type, media) }