You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix OneOf type templates when property types differ (#234)
## Overview
A few of our OpenAPI OneOf types contain properties that are of
different types. These were not handled properly, as the generator would
take the first property type only and set that as the expected type.
Sadly this impacted only a single type as the others had been set as
`string` which the JSON decoder happily used. This commit contains a fix
for said situation.
## Fix
All struct field types that have different property types in the OpenAPI
spec have now been set to `any`.
## Manual testing
I have tested manually against a rack by running the following code
```go
func main() {
client, err := oxide.NewClient(nil)
if err != nil {
panic(err)
}
startTime, err := time.Parse(time.RFC3339, "2024-09-17T06:25:23.696Z")
if err != nil {
panic(err)
}
endTime := time.Now()
ctx := context.Background()
params := oxide.DiskMetricsListParams{
Disk: oxide.NameOrId("5cea3d86-cb2a-43b1-bd3a-2a487b048f44"),
Metric: oxide.DiskMetricNameReadBytes,
Limit: 3,
StartTime: &startTime,
EndTime: &endTime,
}
resp, err := client.DiskMetricsList(ctx, params)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", resp)
}
```
The results were as expected
```console
$ go run main.go
&{Items:[{Datum:{Datum:map[start_time:2024-09-18T06:24:22.956977316Z value:1.41800448e+08] Type:cumulative_i64} Timestamp:2024-09-18 06:24:53.186026344 +0000 UTC} {Datum:{Datum:map[start_time:2024-09-18T06:24:22.956977316Z value:1.4213632e+08] Type:cumulative_i64} Timestamp:2024-09-18 06:25:23.187327342 +0000 UTC} {Datum:{Datum:map[start_time:2024-09-18T06:24:22.956977316Z value:1.4213632e+08] Type:cumulative_i64} Timestamp:2024-09-18 06:25:53.188840965 +0000 UTC}] NextPage:eyJ2IjoidjEiLCJwYWdlX3N0YXJ0Ijp7InN0YXJ0X3RpbWUiOiIyMDI0LTA5LTE4VDA2OjI1OjUzLjE4ODg0MDk2NVoiLCJlbmRfdGltZSI6IjIwMjQtMDktMThUMDY6NTM6MDJaIiwib3JkZXIiOm51bGx9fQ==}
```
Closes: #233
description = "All struct field types that have different property types in the OpenAPI spec have now been set to `any`. [#234](https://github.com/oxidecomputer/oxide.go/pull/234)"
4
4
5
5
[[features]]
6
6
title = ""
@@ -11,5 +11,5 @@ title = ""
11
11
description = ""
12
12
13
13
[[bugs]]
14
-
title = ""
15
-
description = ""
14
+
title = "Fix for fields of type `time.Time`"
15
+
description = "Change encoding of time parameters to RFC3339. [232](https://github.com/oxidecomputer/oxide.go/pull/232)"
0 commit comments