1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::collections::HashMap;
use serde_derive::Serialize;
use crate::dsl::schema::Schema;
use crate::dsl::schema::when::DependencyGraph;
use crate::dsl::schema::Widget;
pub mod generator;
mod serialization;
pub struct JsonSchema<'a> {
version: u64,
schema_url: &'a str,
root: Option<&'a Schema>,
dependencies: Option<&'a DependencyGraph>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UiObject(HashMap<String, UiObjectProperty>);
impl UiObject {
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
#[derive(Clone, Debug, Serialize)]
struct UiObjectProperty {
#[serde(rename = "ui:help", skip_serializing_if = "Option::is_none")]
help: Option<String>,
#[serde(rename = "ui:warning", skip_serializing_if = "Option::is_none")]
warning: Option<String>,
#[serde(rename = "ui:description", skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(rename = "ui:widget", skip_serializing_if = "Option::is_none")]
widget: Option<Widget>,
#[serde(flatten)]
children: Option<UiObject>,
}
impl UiObjectProperty {
pub fn is_empty(&self) -> bool {
self.help.is_none()
&& self.warning.is_none()
&& self.description.is_none()
&& self.widget.is_none()
&& self.children.is_none()
}
}