diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 95c23e19..c45756c0 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -31,16 +31,17 @@ pub trait Tag { } /// Output of the SHA256t hash function. -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[repr(transparent)] -pub struct Hash( - #[cfg_attr( - feature = "schemars", - schemars(schema_with = "crate::util::json_hex_string::len_32") - )] - [u8; 32], - #[cfg_attr(feature = "schemars", schemars(skip))] PhantomData, -); +pub struct Hash([u8; 32], PhantomData); + +#[cfg(feature = "schemars")] +impl schemars::JsonSchema for Hash { + fn schema_name() -> String { "Hash".to_owned() } + + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + crate::util::json_hex_string::len_32(gen) + } +} impl Hash { fn internal_new(arr: [u8; 32]) -> Self { Hash(arr, Default::default()) }