Skip to content

Commit

Permalink
Always serialize required nullable fields (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzou authored Feb 20, 2024
1 parent d126e3c commit f853875
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .generator/src/generator/templates/model_simple.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pub struct {{ name }} {
{%- endif %}
{%- if schema.deprecated %}
#[deprecated]
{%- endif %}
{%- if required and nullable %}
#[serialize_always]
{%- endif %}
#[serde(rename = "{{ attr }}"{% if not required and nullable%}, default, with = "::serde_with::rust::double_option"{% endif %})]
pub {{propertyName}}: {{dataType}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde_with::skip_serializing_none;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SharedDashboardUpdateRequest {
/// Timeframe setting for the shared dashboard.
#[serialize_always]
#[serde(rename = "global_time")]
pub global_time: Option<crate::datadogV1::model::SharedDashboardUpdateRequestGlobalTime>,
/// Whether to allow viewers to select a different global time setting for the shared dashboard.
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/model/model_incident_create_relationships.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde_with::skip_serializing_none;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct IncidentCreateRelationships {
/// Relationship to user.
#[serialize_always]
#[serde(rename = "commander_user")]
pub commander_user: Option<crate::datadogV2::model::NullableRelationshipToUser>,
}
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/model/model_logs_archive_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde_with::skip_serializing_none;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct LogsArchiveAttributes {
/// An archive's destination.
#[serialize_always]
#[serde(rename = "destination")]
pub destination: Option<crate::datadogV2::model::LogsArchiveDestination>,
/// To store the tags in the archive, set the value "true".
Expand Down
1 change: 1 addition & 0 deletions src/datadogV2/model/model_nullable_relationship_to_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde_with::skip_serializing_none;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct NullableRelationshipToUser {
/// Relationship to user object.
#[serialize_always]
#[serde(rename = "data")]
pub data: Option<crate::datadogV2::model::NullableRelationshipToUserData>,
}
Expand Down

0 comments on commit f853875

Please sign in to comment.