[kotlin] [multiplatform] [jvm-ktor] Fix formdata file upload#21056
Merged
wing328 merged 3 commits intoOpenAPITools:masterfrom Apr 25, 2025
Merged
[kotlin] [multiplatform] [jvm-ktor] Fix formdata file upload#21056wing328 merged 3 commits intoOpenAPITools:masterfrom
wing328 merged 3 commits intoOpenAPITools:masterfrom
Conversation
Member
|
thanks for the PR using the spec provided, I did a test with but i don't see any change in the code (only changes in the doc - DefaultApi.md) am I testing your change with the right configurations/options? |
Contributor
Author
|
That seems strange, i get the following diff vs. the generated code using master: Used the same command with the yaml from this PR |
Contributor
Author
|
@wing328 : could you restart the ci, i solved the merge conflicts and somehow the ci has an error now.. |
Member
|
restarted (by closing and reopening the PR) |
076404c to
a77ee1d
Compare
Contributor
Author
|
Here we go. Don't know what the issue was, but rebasing again seems to have solved it. |
Member
|
good i'm able to spot some differences with your fix --- a/src/commonMain/kotlin/org/openapitools/client/apis/DefaultApi.kt
+++ b/src/commonMain/kotlin/org/openapitools/client/apis/DefaultApi.kt
@@ -49,15 +49,15 @@ open class DefaultApi : ApiClient {
* @param isAccepted (optional)
* @return void
*/
- open suspend fun somePathMethodPost(singledocument: io.ktor.client.request.forms.InputProvider? = null, documents: io.ktor.client.request.forms.InputProvider? = null, isAccepted: kotlin.Boolean? = null): HttpResponse<Unit> {
+ open suspend fun somePathMethodPost(singledocument: io.ktor.client.request.forms.FormPart<io.ktor.client.request.forms.InputProvider>? = null, documents: kotlin.collections.List<io.ktor.client.request.forms.FormPart<io.ktor.client.request.forms.InputProvider>>? = null, isAccepted: kotlin.Boolean? = null): HttpResponse<Unit> {
val localVariableAuthNames = listOf<String>()
val localVariableBody =
formData {
- singledocument?.apply { append("singledocument", singledocument) }
+ singledocument?.apply { append(singledocument) }
documents?.onEach {
- append("documents[]", it)
+ append(it)
}
isAccepted?.apply { append("isAccepted", isAccepted) }
}
and build is fine |
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.
The currently generated code for multipart/form-data does not compile for binary parameters.
See #9423, #19644 and #18094. It also fails when there's a list of files to be uploaded.
This PR includes 2 changes:
No. 2 has some implications:
FormPart("document", inputProvider)This may not be the most convenient solution to upload files, but it should suit every application as it leaves FormPart creation to the caller.
I think this would be a good improvement to the current state.
Sample Yaml:
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)@dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10)