Description
The ListNewsParams struct in rest/gen/client.gen.go exposes comparison filters
for published_utc (and similarly for ticker.gte/gt/lte/lt) as anonymous structs
with a single unexported field:
// rest/gen/client.gen.go
type ListNewsParams struct {
// ...
PublishedUtcGte *struct {
union json.RawMessage
} `form:"published_utc.gte,omitempty" json:"published_utc.gte,omitempty"`
PublishedUtcGt *struct{ union json.RawMessage } `...`
PublishedUtcLte *struct{ union json.RawMessage } `...`
PublishedUtcLt *struct{ union json.RawMessage } `...`
// ...
}
These fields appear to come from a oneOf<datetime, date> schema in the OpenAPI
spec. oapi-codegen normally emits FromX / AsX / MergeX helpers for union
types, but no such helpers are generated here:
$ grep -E 'FromListNewsParamsPublishedUtcGte|AsListNewsParamsPublishedUtcGte' rest/gen
(no matches)
Why this is a problem
Two compounding issues make these fields unusable from outside the gen package:
-
The union field is unexported. Per the Go spec (Type identity):
Non-exported field names from different packages are always different.
So callers cannot construct an equivalent struct literal — struct{ union json.RawMessage }{...} declared elsewhere is a different type and is not assignable to *ListNewsParams.PublishedUtcGte.
-
No exported constructor or setter is generated.
The serialization side of the SDK does work — NewListNewsRequest calls runtime.StyleParamWithLocation on *params.PublishedUtcGte and produces the correct published_utc.gte=... query parameter — but there is no supported way to put a value into the field.
The only workarounds available to consumers are:
- A
RequestEditorFn that manually appends published_utc.gte to the query string (bypassing the typed param entirely).
reflect + unsafe to set the unexported field.
Affected fields include (non-exhaustive):
ListNewsParams.PublishedUtcGte / Gt / Lte / Lt
- Likely the same pattern on other endpoints that filter by
published_utc, timestamp, etc.
Versions
github.com/massive-com/client-go/v3 v3.1.0 and v3.3.0 (verified both)
- Go 1.26
Description
The
ListNewsParamsstruct inrest/gen/client.gen.goexposes comparison filtersfor
published_utc(and similarly forticker.gte/gt/lte/lt) as anonymous structswith a single unexported field:
These fields appear to come from a
oneOf<datetime, date>schema in the OpenAPIspec.
oapi-codegennormally emitsFromX/AsX/MergeXhelpers for uniontypes, but no such helpers are generated here:
Why this is a problem
Two compounding issues make these fields unusable from outside the
genpackage:The
unionfield is unexported. Per the Go spec (Type identity):So callers cannot construct an equivalent struct literal —
struct{ union json.RawMessage }{...}declared elsewhere is a different type and is not assignable to*ListNewsParams.PublishedUtcGte.No exported constructor or setter is generated.
The serialization side of the SDK does work —
NewListNewsRequestcallsruntime.StyleParamWithLocationon*params.PublishedUtcGteand produces the correctpublished_utc.gte=...query parameter — but there is no supported way to put a value into the field.The only workarounds available to consumers are:
RequestEditorFnthat manually appendspublished_utc.gteto the query string (bypassing the typed param entirely).reflect+unsafeto set the unexported field.Affected fields include (non-exhaustive):
ListNewsParams.PublishedUtcGte/Gt/Lte/Ltpublished_utc,timestamp, etc.Versions
github.com/massive-com/client-go/v3v3.1.0andv3.3.0(verified both)