refactor: map binary params to io.Reader in Go client#47
Open
dschmidt wants to merge 2 commits into
Open
Conversation
5a1e7ac to
a61870f
Compare
This was referenced May 14, 2026
aa7f96f to
a61870f
Compare
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.
28dab37 to
77067b7
Compare
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 :) |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
--type-mappings=binary=io.Reader,file=io.Reader,File=io.Readerto the Go generator invocation so binary request/response bodies (e.g.UpdateOwnUserPhotoPut,GetOwnUserPhoto) are emitted asio.Readerinstead of*os.File.*os.Filesatisfiesio.Reader, so existing callers compile unchanged. The runtimesetBodypath in the generated client already prefersio.Readerover*os.File, so behavior is identical at the wire.The download path relies on the
*io.Readerbranch added to the shareddecodehelper in OpenAPITools/openapi-generator#23789, released in openapi-generator 7.23.0. Thegenerator_imagepin in.woodpecker/build-go.yamlis bumped fromv7.13.0tov7.23.0accordingly, soGetOwnUserPhoto/GetUserPhotodecode intoio.Readerinstead of returning"undefined response type".