mod json;
mod status_codes;
mod text;
mod undocumented;
use std::convert::Infallible;
pub use self::{json::*, status_codes::*, text::*};
use crate::{Registry, openapi::Responses};
pub type Response = axum::response::Response;
pub trait IntoResponse {
fn openapi(registry: &mut Registry) -> Responses;
fn into_response(self) -> Response;
}
impl<T: IntoResponse, E: IntoResponse> IntoResponse for Result<T, E> {
fn openapi(registry: &mut Registry) -> Responses {
let mut responses = T::openapi(registry);
responses.merge_with(E::openapi(registry));
responses
}
fn into_response(self) -> Response {
match self {
Self::Ok(t) => t.into_response(),
Self::Err(e) => e.into_response(),
}
}
}
impl IntoResponse for Infallible {
fn openapi(_: &mut Registry) -> Responses {
Default::default()
}
fn into_response(self) -> Response {
match self {}
}
}