pub trait ToResponse<'__r> {
// Required method
fn response() -> (&'__r str, RefOr<Response>);
}
Expand description
This trait is implemented to document a type which represents a single response which can be referenced or reused as a component in multiple operations.
ToResponse
trait can also be derived with #[derive(ToResponse)]
.
§Examples
use utoipa::{
openapi::{RefOr, Response, ResponseBuilder},
ToResponse,
};
struct MyResponse;
impl<'__r> ToResponse<'__r> for MyResponse {
fn response() -> (&'__r str, RefOr<Response>) {
(
"MyResponse",
ResponseBuilder::new().description("My Response").build().into(),
)
}
}
Required Methods§
Object Safety§
This trait is not object safe.