Skip to content

Commit

Permalink
fix(gen): change HttpBody.Data from string to any for monitoring:v1 (#…
Browse files Browse the repository at this point in the history
…2744)

fixes: #2304
  • Loading branch information
quartzmo authored Aug 22, 2024
1 parent f836095 commit eda6a59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions google-api-go-generator/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,14 @@ func (s *Schema) writeSchemaStruct(api *API) {
typ = "*" + typ
}

// HACK(chrisdsmith) Hardcodes HttpBody.Data to the Go type "any" only
// for monitoring:v1 in order to avoid errors with JSON objects in the responses.
// (json: cannot unmarshal object into Go struct field HttpBody.data of type string)
// See https://github.com/googleapis/google-api-go-client/issues/2304
if s.api.Name == "monitoring" && s.api.Version == "v1" && s.GoName() == "HttpBody" && pname == "Data" {
typ = "any"
}

s.api.pn(" %s %s `json:\"%s,omitempty%s\"`", pname, typ, p.p.Name, extraOpt)
if firstFieldName == "" {
firstFieldName = pname
Expand Down
2 changes: 1 addition & 1 deletion monitoring/v1/monitoring-gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eda6a59

Please sign in to comment.