1mod json;
2mod status_codes;
3mod text;
4mod undocumented;
5
6use std::convert::Infallible;
7
8pub use self::{json::*, status_codes::*, text::*};
9use crate::{Registry, openapi::Responses};
10
11pub type Response = axum::response::Response;
12
13pub trait IntoResponse {
21 fn openapi(registry: &mut Registry) -> Responses;
23 fn into_response(self) -> Response;
25}
26
27impl<T: IntoResponse, E: IntoResponse> IntoResponse for Result<T, E> {
28 fn openapi(registry: &mut Registry) -> Responses {
29 let mut responses = T::openapi(registry);
30 responses.merge_with(E::openapi(registry));
31 responses
32 }
33
34 fn into_response(self) -> Response {
35 match self {
36 Self::Ok(t) => t.into_response(),
37 Self::Err(e) => e.into_response(),
38 }
39 }
40}
41
42impl IntoResponse for Infallible {
43 fn openapi(_: &mut Registry) -> Responses {
44 Default::default()
45 }
46 fn into_response(self) -> Response {
47 match self {}
48 }
49}