Spaces:
Build error
Build error
/// Similar to `#[derive(JsonSchema)]`, but allows to override `schema_name()` | |
/// for each generic specialization using the following syntax: | |
/// ```ignore | |
/// #[macro_rules_attribute::macro_rules_derive(schemars_rename_generics)] | |
/// #[derive_args(<i32> => "NewName", ...)] | |
/// ``` | |
/// Workaround for https://github.com/GREsau/schemars/issues/193 | |
macro_rules! schemars_rename_generics { | |
{ | |
$( | )*|
$vis:vis struct $name:ident<$($param:ident),*> { $($body:tt)* } | |
} => { | |
impl ::schemars::JsonSchema for $name<$($old_params),*> { | |
fn schema_name() -> String { | |
$new_name.to_string() | |
} | |
fn json_schema(gen: &mut ::schemars::gen::SchemaGenerator) -> ::schemars::schema::Schema { | |
$( | )*|
struct Temp<$($param),*>{ $($body)* } | |
Temp::<$($old_params),*>::json_schema(gen) | |
} | |
} | |
$crate::common::macros::schemars_rename_generics! { | |
$( | )*|
$vis struct $name<$($param),*> | |
{ $($body)* } | |
} | |
}; | |
{ | $( $rest:tt )* } => {}|
} | |
pub(crate) use schemars_rename_generics; | |