Derive Macro aide::OperationIo
source · #[derive(OperationIo)]
{
// Attributes available to this derive:
#[aide]
}
Available on crate feature
macros
only.Expand description
A helper to reduce boilerplate for implementing OperationInput
and OperationOutput
for common use-cases.
§Examples
The following implements an empty OperationInput
and
OperationOutput
so that the type can be used in documented
handlers but does not modify the documentation generation in any way.
ⓘ
use aide::{OperationInput, OperationOutput};
#[derive(OperationIo)]
struct MyExtractor;
By default both OperationInput
and OperationOutput
are implemented.
It is possible to restrict either with the input
and output
parameters.
The following will only implement OperationOutput
:
ⓘ
#[derive(OperationIo)]
#[aide(output)]
struct MyExtractor;
We can use the implementations of another type,
this is useful for wrapping other (e.g. Json
) extractors
that might alter runtime behaviour but the documentation remains the same.
Additionally passing the json_schema
flag will put a
JsonSchema
bound to all generic parameters.
ⓘ
#[derive(OperationIo)]
#[aide(
input_with = "some_other::Json<T>",
output_with = "some_other::Json<T>",
json_schema
)]
struct Json<T>(pub T);