Skip to main content

DocResponseBody

Trait DocResponseBody 

Source
pub trait DocResponseBody {
    // Required method
    fn describe(op: &mut Operation, schemas: &mut Vec<(String, RefOr<Schema>)>);
}
Expand description

Describe how a handler’s return type contributes to its OpenAPI operation’s 200 response.

Invoked once per handler at spec-build time via the [crate::__private::ResponseBodyContribution] autoref dispatch. Implementors mutate op.responses.responses (typically inserting an entry at "200") and append any schema components the response references to schemas so they can be registered on components.schemas by the surrounding crate::ApidocHandlerSchemas machinery.

The blanket impl on Result<Ok, Err> means handlers returning Result<Foo, MyError> transparently defer to Foo’s impl; the error half is handled separately by utoipa’s utoipa::IntoResponses from the macro’s existing responses(E) emission.

Required Methods§

Source

fn describe(op: &mut Operation, schemas: &mut Vec<(String, RefOr<Schema>)>)

Add the success response entry to op and append any referenced schemas to schemas.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<Ok, Err> DocResponseBody for Result<Ok, Err>
where Ok: DocResponseBody,

Source§

fn describe(op: &mut Operation, schemas: &mut Vec<(String, RefOr<Schema>)>)

Source§

impl<T> DocResponseBody for Json<T>
where T: PartialSchema + ToSchema + 'static,

Source§

fn describe(op: &mut Operation, schemas: &mut Vec<(String, RefOr<Schema>)>)

Implementors§

Source§

impl<E, S> DocResponseBody for SseStream<E, S>
where E: PartialSchema + ToSchema + 'static,