Skip to content

Commit 8820f00

Browse files
committed
fix(schemars): 0.8 only support schemars(with = ...) attr on fields
1 parent 54d079e commit 8820f00

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

crates/tlb-ton/src/address.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,10 @@ const CRC_16_XMODEM: Crc<u16> = Crc::<u16>::new(&crc::CRC_16_XMODEM);
3838
/// _ _:MsgAddressExt = MsgAddress;
3939
/// ```
4040
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
41-
#[cfg_attr(
42-
all(feature = "schemars_0_8", not(feature = "schemars_1")),
43-
derive(::schemars_0_8::JsonSchema),
44-
schemars(crate = "::schemars_0_8")
45-
)]
4641
#[cfg_attr(
4742
feature = "schemars_1",
4843
derive(::schemars_1::JsonSchema),
49-
schemars(crate = "::schemars_1")
50-
)]
51-
#[cfg_attr(
52-
any(feature = "schemars_0_8", feature = "schemars_1"),
53-
schemars(with = "String")
44+
schemars(crate = "::schemars_1", with = "String")
5445
)]
5546
#[cfg_attr(
5647
feature = "serde",
@@ -414,6 +405,22 @@ impl<'de> BitUnpack<'de> for Anycast {
414405
}
415406
}
416407

408+
#[cfg(feature = "schemars_0_8")]
409+
// schemars 0.8 supports #[schemars(with = "...")] attribute only for fields
410+
const _: () = {
411+
use schemars_0_8::{JsonSchema, r#gen::SchemaGenerator, schema::Schema};
412+
413+
impl JsonSchema for MsgAddress {
414+
fn schema_name() -> String {
415+
String::schema_name()
416+
}
417+
418+
fn json_schema(generator: &mut SchemaGenerator) -> Schema {
419+
String::json_schema(generator)
420+
}
421+
}
422+
};
423+
417424
#[cfg(test)]
418425
mod tests {
419426
use super::*;

0 commit comments

Comments
 (0)