Skip to content

Commit 2de9c6c

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Ensure clients can handle empty oneOf objects (#2702)
* handle empty oneof * handle empty object matches * lint * Regenerate client from commit 60bc9127 of spec repo --------- Co-authored-by: Sherzod Karimov <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 46c520f commit 2de9c6c

File tree

40 files changed

+177
-53
lines changed

40 files changed

+177
-53
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-09-30 13:56:52.513837",
8-
"spec_repo_commit": "eb66b1cf"
7+
"regenerated": "2024-09-30 14:37:39.238144",
8+
"spec_repo_commit": "60bc9127"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-09-30 13:56:52.527994",
13-
"spec_repo_commit": "eb66b1cf"
12+
"regenerated": "2024-09-30 14:37:39.252667",
13+
"spec_repo_commit": "60bc9127"
1414
}
1515
}
1616
}

.generator/src/generator/templates/model_oneof.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (obj *{{ name }}) UnmarshalJSON(data []byte) error {
6363
if err == nil {
6464
if obj.{{ attributeName }} != nil {% if oneOf.get("type", "object") == "object" %}&& obj.{{ attributeName }}.UnparsedObject == nil {% endif %}{
6565
json{{ attributeName }}, _ := datadog.Marshal(obj.{{ attributeName }})
66-
if string(json{{ attributeName }}) == "{}" { // empty struct
66+
if string(json{{ attributeName }}) == "{}"{% if not oneOf|is_primitive and not oneOf.required %} && string(data) != "{}" {% endif %} { // empty struct
6767
obj.{{ attributeName }} = nil
6868
} else {
6969
match++

api/datadogV1/model_distribution_point_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (obj *DistributionPointItem) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.DistributionPointData != nil {
5555
jsonDistributionPointData, _ := datadog.Marshal(obj.DistributionPointData)
56-
if string(jsonDistributionPointData) == "{}" { // empty struct
56+
if string(jsonDistributionPointData) == "{}" && string(data) != "{}" { // empty struct
5757
obj.DistributionPointData = nil
5858
} else {
5959
match++

api/datadogV1/model_shared_dashboard_invites_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (obj *SharedDashboardInvitesData) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.SharedDashboardInvitesDataList != nil {
5555
jsonSharedDashboardInvitesDataList, _ := datadog.Marshal(obj.SharedDashboardInvitesDataList)
56-
if string(jsonSharedDashboardInvitesDataList) == "{}" { // empty struct
56+
if string(jsonSharedDashboardInvitesDataList) == "{}" && string(data) != "{}" { // empty struct
5757
obj.SharedDashboardInvitesDataList = nil
5858
} else {
5959
match++

api/datadogV1/model_widget_time.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (obj *WidgetTime) UnmarshalJSON(data []byte) error {
4242
if err == nil {
4343
if obj.WidgetLegacyLiveSpan != nil && obj.WidgetLegacyLiveSpan.UnparsedObject == nil {
4444
jsonWidgetLegacyLiveSpan, _ := datadog.Marshal(obj.WidgetLegacyLiveSpan)
45-
if string(jsonWidgetLegacyLiveSpan) == "{}" { // empty struct
45+
if string(jsonWidgetLegacyLiveSpan) == "{}" && string(data) != "{}" { // empty struct
4646
obj.WidgetLegacyLiveSpan = nil
4747
} else {
4848
match++

api/datadogV2/model_api_key_response_included_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *APIKeyResponseIncludedItem) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.User != nil && obj.User.UnparsedObject == nil {
3838
jsonUser, _ := datadog.Marshal(obj.User)
39-
if string(jsonUser) == "{}" { // empty struct
39+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
4040
obj.User = nil
4141
} else {
4242
match++

api/datadogV2/model_application_key_response_included_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (obj *ApplicationKeyResponseIncludedItem) UnmarshalJSON(data []byte) error
4242
if err == nil {
4343
if obj.User != nil && obj.User.UnparsedObject == nil {
4444
jsonUser, _ := datadog.Marshal(obj.User)
45-
if string(jsonUser) == "{}" { // empty struct
45+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
4646
obj.User = nil
4747
} else {
4848
match++

api/datadogV2/model_auth_n_mapping_included.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (obj *AuthNMappingIncluded) UnmarshalJSON(data []byte) error {
7676
if err == nil {
7777
if obj.AuthNMappingTeam != nil && obj.AuthNMappingTeam.UnparsedObject == nil {
7878
jsonAuthNMappingTeam, _ := datadog.Marshal(obj.AuthNMappingTeam)
79-
if string(jsonAuthNMappingTeam) == "{}" { // empty struct
79+
if string(jsonAuthNMappingTeam) == "{}" && string(data) != "{}" { // empty struct
8080
obj.AuthNMappingTeam = nil
8181
} else {
8282
match++

api/datadogV2/model_ci_app_aggregate_bucket_value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (obj *CIAppAggregateBucketValue) UnmarshalJSON(data []byte) error {
7676
if err == nil {
7777
if obj.CIAppAggregateBucketValueTimeseries != nil {
7878
jsonCIAppAggregateBucketValueTimeseries, _ := datadog.Marshal(obj.CIAppAggregateBucketValueTimeseries)
79-
if string(jsonCIAppAggregateBucketValueTimeseries) == "{}" { // empty struct
79+
if string(jsonCIAppAggregateBucketValueTimeseries) == "{}" && string(data) != "{}" { // empty struct
8080
obj.CIAppAggregateBucketValueTimeseries = nil
8181
} else {
8282
match++

api/datadogV2/model_container_image_item.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *ContainerImageItem) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.ContainerImage != nil && obj.ContainerImage.UnparsedObject == nil {
3838
jsonContainerImage, _ := datadog.Marshal(obj.ContainerImage)
39-
if string(jsonContainerImage) == "{}" { // empty struct
39+
if string(jsonContainerImage) == "{}" && string(data) != "{}" { // empty struct
4040
obj.ContainerImage = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *ContainerImageItem) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.ContainerImageGroup != nil && obj.ContainerImageGroup.UnparsedObject == nil {
5555
jsonContainerImageGroup, _ := datadog.Marshal(obj.ContainerImageGroup)
56-
if string(jsonContainerImageGroup) == "{}" { // empty struct
56+
if string(jsonContainerImageGroup) == "{}" && string(data) != "{}" { // empty struct
5757
obj.ContainerImageGroup = nil
5858
} else {
5959
match++

api/datadogV2/model_container_item.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *ContainerItem) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.Container != nil && obj.Container.UnparsedObject == nil {
3838
jsonContainer, _ := datadog.Marshal(obj.Container)
39-
if string(jsonContainer) == "{}" { // empty struct
39+
if string(jsonContainer) == "{}" && string(data) != "{}" { // empty struct
4040
obj.Container = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *ContainerItem) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.ContainerGroup != nil && obj.ContainerGroup.UnparsedObject == nil {
5555
jsonContainerGroup, _ := datadog.Marshal(obj.ContainerGroup)
56-
if string(jsonContainerGroup) == "{}" { // empty struct
56+
if string(jsonContainerGroup) == "{}" && string(data) != "{}" { // empty struct
5757
obj.ContainerGroup = nil
5858
} else {
5959
match++

api/datadogV2/model_downtime_response_included_item.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *DowntimeResponseIncludedItem) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.User != nil && obj.User.UnparsedObject == nil {
3838
jsonUser, _ := datadog.Marshal(obj.User)
39-
if string(jsonUser) == "{}" { // empty struct
39+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
4040
obj.User = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *DowntimeResponseIncludedItem) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.DowntimeMonitorIncludedItem != nil && obj.DowntimeMonitorIncludedItem.UnparsedObject == nil {
5555
jsonDowntimeMonitorIncludedItem, _ := datadog.Marshal(obj.DowntimeMonitorIncludedItem)
56-
if string(jsonDowntimeMonitorIncludedItem) == "{}" { // empty struct
56+
if string(jsonDowntimeMonitorIncludedItem) == "{}" && string(data) != "{}" { // empty struct
5757
obj.DowntimeMonitorIncludedItem = nil
5858
} else {
5959
match++

api/datadogV2/model_downtime_schedule_create_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (obj *DowntimeScheduleCreateRequest) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.DowntimeScheduleOneTimeCreateUpdateRequest != nil && obj.DowntimeScheduleOneTimeCreateUpdateRequest.UnparsedObject == nil {
5555
jsonDowntimeScheduleOneTimeCreateUpdateRequest, _ := datadog.Marshal(obj.DowntimeScheduleOneTimeCreateUpdateRequest)
56-
if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" { // empty struct
56+
if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" && string(data) != "{}" { // empty struct
5757
obj.DowntimeScheduleOneTimeCreateUpdateRequest = nil
5858
} else {
5959
match++

api/datadogV2/model_downtime_schedule_update_request.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *DowntimeScheduleUpdateRequest) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.DowntimeScheduleRecurrencesUpdateRequest != nil && obj.DowntimeScheduleRecurrencesUpdateRequest.UnparsedObject == nil {
3838
jsonDowntimeScheduleRecurrencesUpdateRequest, _ := datadog.Marshal(obj.DowntimeScheduleRecurrencesUpdateRequest)
39-
if string(jsonDowntimeScheduleRecurrencesUpdateRequest) == "{}" { // empty struct
39+
if string(jsonDowntimeScheduleRecurrencesUpdateRequest) == "{}" && string(data) != "{}" { // empty struct
4040
obj.DowntimeScheduleRecurrencesUpdateRequest = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *DowntimeScheduleUpdateRequest) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.DowntimeScheduleOneTimeCreateUpdateRequest != nil && obj.DowntimeScheduleOneTimeCreateUpdateRequest.UnparsedObject == nil {
5555
jsonDowntimeScheduleOneTimeCreateUpdateRequest, _ := datadog.Marshal(obj.DowntimeScheduleOneTimeCreateUpdateRequest)
56-
if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" { // empty struct
56+
if string(jsonDowntimeScheduleOneTimeCreateUpdateRequest) == "{}" && string(data) != "{}" { // empty struct
5757
obj.DowntimeScheduleOneTimeCreateUpdateRequest = nil
5858
} else {
5959
match++

api/datadogV2/model_incident_attachments_response_included_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (obj *IncidentAttachmentsResponseIncludedItem) UnmarshalJSON(data []byte) e
3030
if err == nil {
3131
if obj.User != nil && obj.User.UnparsedObject == nil {
3232
jsonUser, _ := datadog.Marshal(obj.User)
33-
if string(jsonUser) == "{}" { // empty struct
33+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
3434
obj.User = nil
3535
} else {
3636
match++

api/datadogV2/model_incident_field_attributes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *IncidentFieldAttributes) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.IncidentFieldAttributesSingleValue != nil && obj.IncidentFieldAttributesSingleValue.UnparsedObject == nil {
3838
jsonIncidentFieldAttributesSingleValue, _ := datadog.Marshal(obj.IncidentFieldAttributesSingleValue)
39-
if string(jsonIncidentFieldAttributesSingleValue) == "{}" { // empty struct
39+
if string(jsonIncidentFieldAttributesSingleValue) == "{}" && string(data) != "{}" { // empty struct
4040
obj.IncidentFieldAttributesSingleValue = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *IncidentFieldAttributes) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.IncidentFieldAttributesMultipleValue != nil && obj.IncidentFieldAttributesMultipleValue.UnparsedObject == nil {
5555
jsonIncidentFieldAttributesMultipleValue, _ := datadog.Marshal(obj.IncidentFieldAttributesMultipleValue)
56-
if string(jsonIncidentFieldAttributesMultipleValue) == "{}" { // empty struct
56+
if string(jsonIncidentFieldAttributesMultipleValue) == "{}" && string(data) != "{}" { // empty struct
5757
obj.IncidentFieldAttributesMultipleValue = nil
5858
} else {
5959
match++

api/datadogV2/model_incident_integration_metadata_response_included_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (obj *IncidentIntegrationMetadataResponseIncludedItem) UnmarshalJSON(data [
3030
if err == nil {
3131
if obj.User != nil && obj.User.UnparsedObject == nil {
3232
jsonUser, _ := datadog.Marshal(obj.User)
33-
if string(jsonUser) == "{}" { // empty struct
33+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
3434
obj.User = nil
3535
} else {
3636
match++

api/datadogV2/model_incident_response_included_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *IncidentResponseIncludedItem) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.User != nil && obj.User.UnparsedObject == nil {
3838
jsonUser, _ := datadog.Marshal(obj.User)
39-
if string(jsonUser) == "{}" { // empty struct
39+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
4040
obj.User = nil
4141
} else {
4242
match++

api/datadogV2/model_incident_service_included_items.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (obj *IncidentServiceIncludedItems) UnmarshalJSON(data []byte) error {
3030
if err == nil {
3131
if obj.User != nil && obj.User.UnparsedObject == nil {
3232
jsonUser, _ := datadog.Marshal(obj.User)
33-
if string(jsonUser) == "{}" { // empty struct
33+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
3434
obj.User = nil
3535
} else {
3636
match++

api/datadogV2/model_incident_team_included_items.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (obj *IncidentTeamIncludedItems) UnmarshalJSON(data []byte) error {
3030
if err == nil {
3131
if obj.User != nil && obj.User.UnparsedObject == nil {
3232
jsonUser, _ := datadog.Marshal(obj.User)
33-
if string(jsonUser) == "{}" { // empty struct
33+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
3434
obj.User = nil
3535
} else {
3636
match++

api/datadogV2/model_incident_todo_response_included_item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (obj *IncidentTodoResponseIncludedItem) UnmarshalJSON(data []byte) error {
3030
if err == nil {
3131
if obj.User != nil && obj.User.UnparsedObject == nil {
3232
jsonUser, _ := datadog.Marshal(obj.User)
33-
if string(jsonUser) == "{}" { // empty struct
33+
if string(jsonUser) == "{}" && string(data) != "{}" { // empty struct
3434
obj.User = nil
3535
} else {
3636
match++

api/datadogV2/model_list_entity_catalog_response_included_item.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err
5454
if err == nil {
5555
if obj.EntityResponseIncludedSchema != nil && obj.EntityResponseIncludedSchema.UnparsedObject == nil {
5656
jsonEntityResponseIncludedSchema, _ := datadog.Marshal(obj.EntityResponseIncludedSchema)
57-
if string(jsonEntityResponseIncludedSchema) == "{}" { // empty struct
57+
if string(jsonEntityResponseIncludedSchema) == "{}" && string(data) != "{}" { // empty struct
5858
obj.EntityResponseIncludedSchema = nil
5959
} else {
6060
match++
@@ -71,7 +71,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err
7171
if err == nil {
7272
if obj.EntityResponseIncludedRawSchema != nil && obj.EntityResponseIncludedRawSchema.UnparsedObject == nil {
7373
jsonEntityResponseIncludedRawSchema, _ := datadog.Marshal(obj.EntityResponseIncludedRawSchema)
74-
if string(jsonEntityResponseIncludedRawSchema) == "{}" { // empty struct
74+
if string(jsonEntityResponseIncludedRawSchema) == "{}" && string(data) != "{}" { // empty struct
7575
obj.EntityResponseIncludedRawSchema = nil
7676
} else {
7777
match++
@@ -88,7 +88,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err
8888
if err == nil {
8989
if obj.EntityResponseIncludedRelatedEntity != nil && obj.EntityResponseIncludedRelatedEntity.UnparsedObject == nil {
9090
jsonEntityResponseIncludedRelatedEntity, _ := datadog.Marshal(obj.EntityResponseIncludedRelatedEntity)
91-
if string(jsonEntityResponseIncludedRelatedEntity) == "{}" { // empty struct
91+
if string(jsonEntityResponseIncludedRelatedEntity) == "{}" && string(data) != "{}" { // empty struct
9292
obj.EntityResponseIncludedRelatedEntity = nil
9393
} else {
9494
match++
@@ -105,7 +105,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err
105105
if err == nil {
106106
if obj.EntityResponseIncludedOncall != nil && obj.EntityResponseIncludedOncall.UnparsedObject == nil {
107107
jsonEntityResponseIncludedOncall, _ := datadog.Marshal(obj.EntityResponseIncludedOncall)
108-
if string(jsonEntityResponseIncludedOncall) == "{}" { // empty struct
108+
if string(jsonEntityResponseIncludedOncall) == "{}" && string(data) != "{}" { // empty struct
109109
obj.EntityResponseIncludedOncall = nil
110110
} else {
111111
match++
@@ -122,7 +122,7 @@ func (obj *ListEntityCatalogResponseIncludedItem) UnmarshalJSON(data []byte) err
122122
if err == nil {
123123
if obj.EntityResponseIncludedIncident != nil && obj.EntityResponseIncludedIncident.UnparsedObject == nil {
124124
jsonEntityResponseIncludedIncident, _ := datadog.Marshal(obj.EntityResponseIncludedIncident)
125-
if string(jsonEntityResponseIncludedIncident) == "{}" { // empty struct
125+
if string(jsonEntityResponseIncludedIncident) == "{}" && string(data) != "{}" { // empty struct
126126
obj.EntityResponseIncludedIncident = nil
127127
} else {
128128
match++

api/datadogV2/model_logs_aggregate_bucket_value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (obj *LogsAggregateBucketValue) UnmarshalJSON(data []byte) error {
7676
if err == nil {
7777
if obj.LogsAggregateBucketValueTimeseries != nil {
7878
jsonLogsAggregateBucketValueTimeseries, _ := datadog.Marshal(obj.LogsAggregateBucketValueTimeseries)
79-
if string(jsonLogsAggregateBucketValueTimeseries) == "{}" { // empty struct
79+
if string(jsonLogsAggregateBucketValueTimeseries) == "{}" && string(data) != "{}" { // empty struct
8080
obj.LogsAggregateBucketValueTimeseries = nil
8181
} else {
8282
match++

api/datadogV2/model_metric_volumes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *MetricVolumes) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.MetricDistinctVolume != nil && obj.MetricDistinctVolume.UnparsedObject == nil {
3838
jsonMetricDistinctVolume, _ := datadog.Marshal(obj.MetricDistinctVolume)
39-
if string(jsonMetricDistinctVolume) == "{}" { // empty struct
39+
if string(jsonMetricDistinctVolume) == "{}" && string(data) != "{}" { // empty struct
4040
obj.MetricDistinctVolume = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *MetricVolumes) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.MetricIngestedIndexedVolume != nil && obj.MetricIngestedIndexedVolume.UnparsedObject == nil {
5555
jsonMetricIngestedIndexedVolume, _ := datadog.Marshal(obj.MetricIngestedIndexedVolume)
56-
if string(jsonMetricIngestedIndexedVolume) == "{}" { // empty struct
56+
if string(jsonMetricIngestedIndexedVolume) == "{}" && string(data) != "{}" { // empty struct
5757
obj.MetricIngestedIndexedVolume = nil
5858
} else {
5959
match++

api/datadogV2/model_metrics_and_metric_tag_configurations.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *MetricsAndMetricTagConfigurations) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.Metric != nil && obj.Metric.UnparsedObject == nil {
3838
jsonMetric, _ := datadog.Marshal(obj.Metric)
39-
if string(jsonMetric) == "{}" { // empty struct
39+
if string(jsonMetric) == "{}" && string(data) != "{}" { // empty struct
4040
obj.Metric = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *MetricsAndMetricTagConfigurations) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.MetricTagConfiguration != nil && obj.MetricTagConfiguration.UnparsedObject == nil {
5555
jsonMetricTagConfiguration, _ := datadog.Marshal(obj.MetricTagConfiguration)
56-
if string(jsonMetricTagConfiguration) == "{}" { // empty struct
56+
if string(jsonMetricTagConfiguration) == "{}" && string(data) != "{}" { // empty struct
5757
obj.MetricTagConfiguration = nil
5858
} else {
5959
match++

api/datadogV2/model_monitor_config_policy_policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (obj *MonitorConfigPolicyPolicy) UnmarshalJSON(data []byte) error {
3030
if err == nil {
3131
if obj.MonitorConfigPolicyTagPolicy != nil && obj.MonitorConfigPolicyTagPolicy.UnparsedObject == nil {
3232
jsonMonitorConfigPolicyTagPolicy, _ := datadog.Marshal(obj.MonitorConfigPolicyTagPolicy)
33-
if string(jsonMonitorConfigPolicyTagPolicy) == "{}" { // empty struct
33+
if string(jsonMonitorConfigPolicyTagPolicy) == "{}" && string(data) != "{}" { // empty struct
3434
obj.MonitorConfigPolicyTagPolicy = nil
3535
} else {
3636
match++

api/datadogV2/model_rum_aggregate_bucket_value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (obj *RUMAggregateBucketValue) UnmarshalJSON(data []byte) error {
7676
if err == nil {
7777
if obj.RUMAggregateBucketValueTimeseries != nil {
7878
jsonRUMAggregateBucketValueTimeseries, _ := datadog.Marshal(obj.RUMAggregateBucketValueTimeseries)
79-
if string(jsonRUMAggregateBucketValueTimeseries) == "{}" { // empty struct
79+
if string(jsonRUMAggregateBucketValueTimeseries) == "{}" && string(data) != "{}" { // empty struct
8080
obj.RUMAggregateBucketValueTimeseries = nil
8181
} else {
8282
match++

api/datadogV2/model_scalar_column.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (obj *ScalarColumn) UnmarshalJSON(data []byte) error {
3636
if err == nil {
3737
if obj.GroupScalarColumn != nil && obj.GroupScalarColumn.UnparsedObject == nil {
3838
jsonGroupScalarColumn, _ := datadog.Marshal(obj.GroupScalarColumn)
39-
if string(jsonGroupScalarColumn) == "{}" { // empty struct
39+
if string(jsonGroupScalarColumn) == "{}" && string(data) != "{}" { // empty struct
4040
obj.GroupScalarColumn = nil
4141
} else {
4242
match++
@@ -53,7 +53,7 @@ func (obj *ScalarColumn) UnmarshalJSON(data []byte) error {
5353
if err == nil {
5454
if obj.DataScalarColumn != nil && obj.DataScalarColumn.UnparsedObject == nil {
5555
jsonDataScalarColumn, _ := datadog.Marshal(obj.DataScalarColumn)
56-
if string(jsonDataScalarColumn) == "{}" { // empty struct
56+
if string(jsonDataScalarColumn) == "{}" && string(data) != "{}" { // empty struct
5757
obj.DataScalarColumn = nil
5858
} else {
5959
match++

0 commit comments

Comments
 (0)