Skip to content

Commit 455ccd2

Browse files
committed
better serialization
1 parent 7ee4552 commit 455ccd2

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

document_tree/src/attribute_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub struct TableGroupCols(pub usize);
9797
// no eq for f64
9898
#[derive(Clone, Debug, PartialEq, Serialize, JsonSchema)]
9999
#[serde(tag = "unit", content = "value")]
100+
#[schemars(_unstable_ref_variants)]
100101
pub enum Measure {
101102
// https://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#length-units
102103
Em(f64),

document_tree/src/element_categories.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ macro_rules! synonymous_enum {
5353
} ) => {
5454
#[derive(Clone, PartialEq, Serialize, JsonSchema)]
5555
#[serde(tag = "type")]
56+
#[schemars(_unstable_ref_variants)]
5657
pub enum $name { $(
5758
$(#[$attr])?
5859
$entry(Box<$entry>),

document_tree/src/elements.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ pub trait Element {
2929

3030
#[derive(Clone, Debug, Default, PartialEq, Serialize, JsonSchema)]
3131
pub struct CommonAttributes {
32-
#[serde(skip_serializing_if = "CanBeEmpty::is_empty")]
32+
#[serde(default, skip_serializing_if = "CanBeEmpty::is_empty")]
3333
ids: Vec<ID>,
34-
#[serde(skip_serializing_if = "CanBeEmpty::is_empty")]
34+
#[serde(default, skip_serializing_if = "CanBeEmpty::is_empty")]
3535
names: Vec<NameToken>,
36-
#[serde(skip_serializing_if = "CanBeEmpty::is_empty")]
36+
#[serde(default, skip_serializing_if = "CanBeEmpty::is_empty")]
3737
source: Option<PathBuf>,
38-
#[serde(skip_serializing_if = "CanBeEmpty::is_empty")]
38+
#[serde(default, skip_serializing_if = "CanBeEmpty::is_empty")]
3939
classes: Vec<String>,
4040
//TODO: dupnames
4141
}
@@ -182,6 +182,7 @@ macro_rules! impl_elem {
182182
pub struct $name {
183183
#[serde(flatten)]
184184
common: CommonAttributes,
185+
#[serde(default, skip_serializing_if = "CanBeEmpty::is_empty")]
185186
children: Vec<$childtype>,
186187
}
187188
);
@@ -196,6 +197,7 @@ macro_rules! impl_elem {
196197
common: CommonAttributes,
197198
#[serde(flatten)]
198199
extra: extra_attributes::$name,
200+
#[serde(default, skip_serializing_if = "CanBeEmpty::is_empty")]
199201
children: Vec<$childtype>,
200202
}
201203
);

0 commit comments

Comments
 (0)