Skip to content

Commit 253d9d6

Browse files
fix: add utoipa where predicate
1 parent 93f2673 commit 253d9d6

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

packages/fortifier-macros/src/integrations.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn enum_field_attributes() -> TokenStream {
5959

6060
pub fn where_predicate(error_type: TokenStream) -> TokenStream {
6161
#[allow(unused_mut)]
62-
let mut lifetimes = TokenStream::new();
62+
let mut lifetime = TokenStream::new();
6363
#[allow(unused_mut)]
6464
let mut traits = TokenStream::new();
6565

@@ -68,12 +68,20 @@ pub fn where_predicate(error_type: TokenStream) -> TokenStream {
6868
use proc_macro_crate::crate_name;
6969

7070
if crate_name("serde").is_ok() {
71-
lifetimes = quote!(for<'fde>);
72-
traits = quote!(+ ::serde::Deserialize<'fde> + ::serde::Serialize);
71+
lifetime = quote!(for<'fde>);
72+
traits = quote!(#traits + ::serde::Deserialize<'fde> + ::serde::Serialize);
73+
}
74+
}
75+
#[cfg(feature = "utoipa")]
76+
{
77+
use proc_macro_crate::crate_name;
78+
79+
if crate_name("utoipa").is_ok() {
80+
traits = quote!(#traits + ::utoipa::ToSchema);
7381
}
7482
}
7583

7684
quote! {
77-
#lifetimes #error_type: ::std::fmt::Debug + PartialEq #traits
85+
#lifetime #error_type: ::std::fmt::Debug + PartialEq #traits
7886
}
7987
}

0 commit comments

Comments
 (0)