feat: Add support for aide

This commit is contained in:
gengteng
2023-12-18 16:45:31 +08:00
parent edddee3ccb
commit 053d3b5dc1
5 changed files with 36 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ 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> {

View File

@@ -28,6 +28,7 @@ use validator::{Validate, ValidateArgs, ValidationErrors};
/// For examples with custom extractors, check out the `tests/custom.rs` file.
///
#[derive(Debug, Clone, Copy, Default)]
#[cfg_attr(feature = "aide", derive(aide::OperationIo))]
pub struct Valid<E>(pub E);
impl<E> Deref for Valid<E> {
@@ -71,6 +72,7 @@ impl<E> Valid<E> {
/// Although current module documentation predominantly showcases `Valid` examples, the usage of `ValidEx` is analogous.
///
#[derive(Debug, Clone, Copy, Default)]
#[cfg_attr(feature = "aide", derive(aide::OperationIo))]
pub struct ValidEx<E, A>(pub E, pub A);
impl<E, A> Deref for ValidEx<E, A> {

View File

@@ -24,6 +24,7 @@ use validify::{Modify, Validate, ValidationErrors, Validify};
/// It only does validation, usage is similar to `Valid`.
///
#[derive(Debug, Clone, Copy, Default)]
#[cfg_attr(feature = "aide", derive(aide::OperationIo))]
pub struct Validated<E>(pub E);
impl<E> Deref for Validated<E> {
@@ -73,6 +74,7 @@ impl<E> Validated<E> {
///
/// This allows applying modifications during response conversion by leveraging validify.
#[derive(Debug, Clone, Copy, Default)]
#[cfg_attr(feature = "aide", derive(aide::OperationIo))]
pub struct Modified<E>(pub E);
impl<E> Deref for Modified<E> {
@@ -121,6 +123,7 @@ impl<E: IntoResponse + HasModify> IntoResponse for Modified<E> {
/// And can treat missing fields as validation errors.
///
#[derive(Debug, Clone, Copy, Default)]
#[cfg_attr(feature = "aide", derive(aide::OperationIo))]
pub struct Validified<E>(pub E);
impl<E> Deref for Validified<E> {
@@ -160,6 +163,7 @@ impl<E> Validified<E> {
/// Suitable for inner extractors not based on `serde`.
///
#[derive(Debug, Clone, Copy, Default)]
#[cfg_attr(feature = "aide", derive(aide::OperationIo))]
pub struct ValidifiedByRef<E>(pub E);
impl<E> Deref for ValidifiedByRef<E> {