Skip to content

refactor: map binary params to io.Reader in Go client#47

Open
dschmidt wants to merge 2 commits into
mainfrom
refactor/go-binary-io-reader
Open

refactor: map binary params to io.Reader in Go client#47
dschmidt wants to merge 2 commits into
mainfrom
refactor/go-binary-io-reader

Conversation

@dschmidt

@dschmidt dschmidt commented May 14, 2026

Copy link
Copy Markdown
Contributor

Adds --type-mappings=binary=io.Reader,file=io.Reader,File=io.Reader to the Go generator invocation so binary request/response bodies (e.g. UpdateOwnUserPhotoPut, GetOwnUserPhoto) are emitted as io.Reader instead of *os.File.

*os.File satisfies io.Reader, so existing callers compile unchanged. The runtime setBody path in the generated client already prefers io.Reader over *os.File, so behavior is identical at the wire.

The download path relies on the *io.Reader branch added to the shared decode helper in OpenAPITools/openapi-generator#23789, released in openapi-generator 7.23.0. The generator_image pin in .woodpecker/build-go.yaml is bumped from v7.13.0 to v7.23.0 accordingly, so GetOwnUserPhoto / GetUserPhoto decode into io.Reader instead of returning "undefined response type".

@dschmidt dschmidt marked this pull request as ready for review May 14, 2026 09:01
@dschmidt dschmidt force-pushed the refactor/go-binary-io-reader branch from 5a1e7ac to a61870f Compare May 14, 2026 09:01
@dschmidt dschmidt marked this pull request as draft May 14, 2026 13:22
@dschmidt dschmidt force-pushed the refactor/go-binary-io-reader branch from aa7f96f to a61870f Compare May 14, 2026 15:15
@dschmidt dschmidt marked this pull request as ready for review July 1, 2026 18:32
dschmidt added 2 commits July 1, 2026 20:36
Override the openapi-generator Go default of *os.File for type: string
+ format: binary to io.Reader. *os.File still satisfies the interface,
so existing callers compile unchanged.
@dschmidt dschmidt force-pushed the refactor/go-binary-io-reader branch from 28dab37 to 77067b7 Compare July 1, 2026 18:39
@dschmidt

dschmidt commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Stumbled upon this when I reviewed opencloud-eu/opencloud#2704.

If we're going for the event based approach I suggested (and which the author already implemented), we don't need this anymore. But it's still more correct and more flexible and more idiomatic. I strongly suggest to merge this fix anyhow :)

@dschmidt dschmidt requested review from aduffeck and rhafer July 1, 2026 19:06
@dschmidt

dschmidt commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

If you prefer I can send a preliminary PR that just bumps the openapi-generator - then it becomes more obvious what is changed by the flags I'm introducing in this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant