feat: implement aide::OperationInput/OperationOutput for extractors
This commit is contained in:
11
src/garde.rs
11
src/garde.rs
@@ -25,7 +25,6 @@ use std::ops::{Deref, DerefMut};
|
||||
/// If using arguments, you must pass the arguments to Garde extractor via state, meaning implementing `FromRef<StateType>` for your validation arguments type.
|
||||
///
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
#[cfg_attr(feature = "aide", derive(aide::OperationIo))]
|
||||
pub struct Garde<E>(pub E);
|
||||
|
||||
impl<E> Deref for Garde<E> {
|
||||
@@ -58,6 +57,16 @@ impl<E> Garde<E> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "aide")]
|
||||
impl<T> aide::OperationInput for Garde<T>
|
||||
where
|
||||
T: aide::OperationInput,
|
||||
{
|
||||
fn operation_input(ctx: &mut aide::gen::GenContext, operation: &mut aide::openapi::Operation) {
|
||||
T::operation_input(ctx, operation);
|
||||
}
|
||||
}
|
||||
|
||||
/// `GardeRejection` is returned when the `Garde` extractor fails.
|
||||
///
|
||||
pub type GardeRejection<E> = ValidationRejection<Report, E>;
|
||||
|
||||
Reference in New Issue
Block a user