rsmack_utils/schemars.rs
1#[macro_export]
2macro_rules! impl_json_schema {
3 ($id:ident, "string") => {
4 impl_json_schema!{ @simple_ty $id, "string" }
5 };
6 (@simple_ty $id:ident, $ty:literal) => {
7 impl schemars::JsonSchema for $id {
8 fn schema_name() -> std::borrow::Cow<'static, str> {
9 stringify!($id).into()
10 }
11
12 fn json_schema(_generator: &mut schemars::SchemaGenerator) -> Schema {
13 json_schema!({
14 "type": $ty,
15 })
16 }
17 }
18 };
19}