Skip to content

Commit

Permalink
Allow for any type for additionalProperties in HTTPLogItem (#2742)
Browse files Browse the repository at this point in the history
* handle untyped additionalproperties

* Regenerate client from commit 37070fd4 of spec repo

---------

Co-authored-by: Kevin Zou <kevin.zou@datadoghq.com>
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
3 people authored Oct 18, 2024
1 parent 52cdcb0 commit 0bc3efc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-17 14:10:54.976689",
"spec_repo_commit": "fb024a45"
"regenerated": "2024-10-18 21:00:51.408686",
"spec_repo_commit": "37070fd4"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-10-17 14:10:54.995137",
"spec_repo_commit": "fb024a45"
"regenerated": "2024-10-18 21:00:51.427778",
"spec_repo_commit": "37070fd4"
}
}
}
1 change: 0 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9917,7 +9917,6 @@ components:
HTTPLogItem:
additionalProperties:
description: Additional log attributes.
type: string
description: Logs that are sent over HTTP.
properties:
ddsource:
Expand Down
2 changes: 2 additions & 0 deletions .generator/src/generator/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ def format_data_with_schema_dict(
nested_schema_name = schema_name(nested_schema)
if nested_schema_name:
nested_schema_name = name_prefix + nested_schema_name
elif nested_schema.get("type") is None:
nested_schema_name = "interface{}"

has_properties = schema.get("properties")

Expand Down
4 changes: 2 additions & 2 deletions api/datadogV2/model_http_log_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type HTTPLogItem struct {
Service *string `json:"service,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]string `json:"-"`
AdditionalProperties map[string]interface{} `json:"-"`
}

// NewHTTPLogItem instantiates a new HTTPLogItem object.
Expand Down Expand Up @@ -227,7 +227,7 @@ func (o *HTTPLogItem) UnmarshalJSON(bytes []byte) (err error) {
if all.Message == nil {
return fmt.Errorf("required field message missing")
}
additionalProperties := make(map[string]string)
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"ddsource", "ddtags", "hostname", "message", "service"})
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/logs/SubmitLog.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
Hostname: datadog.PtrString("i-012345678"),
Message: "2019-11-19T14:37:58,995 INFO [process.name][20081] Hello World",
Service: datadog.PtrString("payment"),
AdditionalProperties: map[string]string{
AdditionalProperties: map[string]interface{}{
"status": "info",
},
},
Expand Down

0 comments on commit 0bc3efc

Please sign in to comment.