Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip seralizing null fields on JSON #695

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
]
}