Skip to content

Commit

Permalink
Merge pull request #695 from pvdrz/remove-nulls
Browse files Browse the repository at this point in the history
Skip seralizing null fields on JSON
  • Loading branch information
Shnatsel authored May 9, 2024
2 parents b01a876 + 399b7cd commit b85f788
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 2 additions & 0 deletions cyclonedx-bom/src/specs/v1_5/annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl FromXml for Annotations {
#[serde(rename_all = "camelCase")]
pub(crate) struct Annotation {
/// Optional identifier to reference the annotation elsewhere in the Bom.
#[serde(skip_serializing_if = "Option::is_none")]
bom_ref: Option<String>,
/// A list of BOM references, TODO change to `Subjects`
subjects: Vec<String>,
Expand All @@ -124,6 +125,7 @@ pub(crate) struct Annotation {
/// The textual content of the annotation.
text: String,
/// The optional signature
#[serde(skip_serializing_if = "Option::is_none")]
signature: Option<Signature>,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: cyclonedx-bom/tests/specification_tests_v1_5.rs
assertion_line: 54
expression: bom_output
input_file: cyclonedx-bom/tests/spec/1.5/valid-annotation-1.5.json
---
Expand All @@ -19,7 +18,6 @@ input_file: cyclonedx-bom/tests/spec/1.5/valid-annotation-1.5.json
],
"annotations": [
{
"bomRef": null,
"subjects": [
"component-a"
],
Expand All @@ -38,11 +36,9 @@ input_file: cyclonedx-bom/tests/spec/1.5/valid-annotation-1.5.json
}
},
"timestamp": "2022-01-01T00:00:00Z",
"text": "This is a sample annotation made by an organization",
"signature": null
"text": "This is a sample annotation made by an organization"
},
{
"bomRef": null,
"subjects": [
"component-a"
],
Expand All @@ -54,11 +50,9 @@ input_file: cyclonedx-bom/tests/spec/1.5/valid-annotation-1.5.json
}
},
"timestamp": "2022-01-01T00:00:00Z",
"text": "This is a sample annotation made by a person",
"signature": null
"text": "This is a sample annotation made by a person"
},
{
"bomRef": null,
"subjects": [
"component-a"
],
Expand All @@ -70,11 +64,9 @@ input_file: cyclonedx-bom/tests/spec/1.5/valid-annotation-1.5.json
}
},
"timestamp": "2022-01-01T00:00:00Z",
"text": "This is a sample annotation made by a component",
"signature": null
"text": "This is a sample annotation made by a component"
},
{
"bomRef": null,
"subjects": [
"component-a"
],
Expand Down Expand Up @@ -105,8 +97,7 @@ input_file: cyclonedx-bom/tests/spec/1.5/valid-annotation-1.5.json
}
},
"timestamp": "2022-01-01T00:00:00Z",
"text": "This is a sample annotation made by a service",
"signature": null
"text": "This is a sample annotation made by a service"
}
]
}

0 comments on commit b85f788

Please sign in to comment.