use utoipa::{
PartialSchema, ToResponse,
openapi::{Content, RefOr, Response, response::ResponseBuilder},
};
use crate::http::{ApiProblem, ProblemDetails, error::PROBLEM_JSON_MEDIA_TYPE};
#[must_use]
pub fn problem_response(description: impl Into<String>) -> Response {
ResponseBuilder::new()
.description(description)
.content(
PROBLEM_JSON_MEDIA_TYPE,
Content::new(Some(ProblemDetails::schema())),
)
.build()
}
impl ToResponse<'_> for ApiProblem {
fn response() -> (&'static str, RefOr<Response>) {
(
"ApiProblem",
problem_response("The request failed; inspect the problem code and details.").into(),
)
}
}