pub trait IntoResponses {
// Required method
fn responses() -> BTreeMap<String, RefOr<Response>>;
}
Expand description
This trait is implemented to document a type (like an enum) which can represent multiple responses, to be used in operation.
§Examples
use std::collections::BTreeMap;
use utoipa::{
openapi::{Response, ResponseBuilder, ResponsesBuilder, RefOr},
IntoResponses,
};
enum MyResponse {
Ok,
NotFound,
}
impl IntoResponses for MyResponse {
fn responses() -> BTreeMap<String, RefOr<Response>> {
ResponsesBuilder::new()
.response("200", ResponseBuilder::new().description("Ok"))
.response("404", ResponseBuilder::new().description("Not Found"))
.build()
.into()
}
}
Required Methods§
Object Safety§
This trait is not object safe.