pub trait OperationOutput {
    type Inner;

    fn operation_response(
        ctx: &mut GenContext,
        operation: &mut Operation
    ) -> Option<Response> { ... } fn inferred_responses(
        ctx: &mut GenContext,
        operation: &mut Operation
    ) -> Vec<(Option<u16>, Response)> { ... } }
Expand description

A trait for operation output schema generation.

This can be implemented for types that can describe their own output schema.

All method implementations are optional.

For simpler cases or wrappers the OperationIo derive macro can be used to implement this trait.

Required Associated Types

The type that is used in examples.

Examples

In case of Json<T>, this should be T, whereas for String it should be Self.

Provided Methods

Return a response documentation for this type, alternatively modify the operation if required.

This method gets mutable access to the entire operation, it’s the implementer’s responsibility to detect errors and only modify the operation as much as needed.

Note that this function can be called multiple times for the same operation and should be idempotent.

There are reusable helpers in aide::operation to help with both boilerplate and error detection.

Inferred responses are used when the type is used as a request handler return type.

The function is supposed to return (status code, response) pairs, if the status code is not specified, the response is assumed to be a default response.

As an example Result<T, E> could return (Some(200), T::operation_response(..)) and (None, E::operation_response(..)) to indicate a successful response and a default error.

This function can be called after or before operation_response, it’s important for the implementation to be idempotent.

Implementations on Foreign Types

Implementors