Skip to content

Commit b0f8ba0

Browse files
authored
Fix uint64 representation. (#390)
Fix overflow bugs due to representing uint64s as ints.
1 parent dfdb24e commit b0f8ba0

File tree

5 files changed

+71
-54
lines changed

5 files changed

+71
-54
lines changed

internal/generate/paths.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ func buildPathOrQueryParams(
425425
)
426426
case "*int":
427427
pathParams = append(pathParams, fmt.Sprintf("%q: PointerIntToStr(%s),", name, n))
428+
case "*uint64":
429+
pathParams = append(pathParams, fmt.Sprintf("%q: PointerUint64ToStr(%s),", name, n))
428430
case "*time.Time":
429431
pathParams = append(pathParams, fmt.Sprintf("%q: PointerTimeToStr(%s),", name, n))
430432
default:

internal/generate/utils.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ func schemaValueToGoType(schemaValue *openapi3.Schema, property string) string {
151151
}
152152

153153
if schemaValue.Type.Is("integer") {
154+
// uint64 values can overflow Go's int type, so we use *uint64 for
155+
// properties with format "uint64".
156+
if schemaValue.Format == "uint64" {
157+
return "*uint64"
158+
}
154159
// It is necessary to use pointers for integer types as we need
155160
// to differentiate between an empty value and a 0.
156161
return "*int"

oxide/paths.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oxide/types.go

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)