architect_api/utils/
json_schema.rs1#[macro_export]
2macro_rules! json_schema_is_string {
3 ($type:ident) => {
4 impl schemars::JsonSchema for $type {
5 fn schema_name() -> String {
6 stringify!($type).to_owned()
7 }
8
9 fn json_schema(
10 _gen: &mut schemars::r#gen::SchemaGenerator,
11 ) -> schemars::schema::Schema {
12 schemars::schema::SchemaObject {
13 instance_type: Some(schemars::schema::InstanceType::String.into()),
14 ..Default::default()
15 }
16 .into()
17 }
18
19 fn is_referenceable() -> bool {
20 true
21 }
22 }
23 };
24 ($type:ident, $format:literal) => {
25 impl schemars::JsonSchema for $type {
26 fn schema_name() -> String {
27 stringify!($type).to_owned()
28 }
29
30 fn json_schema(
31 _gen: &mut schemars::r#gen::SchemaGenerator,
32 ) -> schemars::schema::Schema {
33 schemars::schema::SchemaObject {
34 instance_type: Some(schemars::schema::InstanceType::String.into()),
35 format: Some($format.to_owned()),
36 ..Default::default()
37 }
38 .into()
39 }
40
41 fn is_referenceable() -> bool {
42 true
43 }
44 }
45 };
46}