You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Multipart file upload using generated client does not work due to missing filename in content disposition headers. I generated a client against an upload API in Kotlin Spring. When using the generated client to upload a file Spring returns status 400 indicating the file has not been uploaded. After a bit of digging I found that Spring is expecting the filename in content disposition but its missing from the generated client.
Actual Output: Returns status 400 due to file missing
Expected Output: The file should be uploaded and return a status 200
The issue seemed to resolve when I manually added the headers.
openapi-generator version
7.8.0 ( I did observe this issue in older versions as well.)
The API application is created using spring boot.
Code was generated using the below configuration
tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generateClient") {
generatorName.set("kotlin")
inputSpec.set("$projectDir/swagger.json")
outputDir.set("$projectDir/src/main/kotlin")
apiPackage.set("org.example.api")
modelPackage.set("org.example.api.model")
configOptions.set(mapOf("dateLibrary" to "java8"))
additionalProperties.set(mapOf("java8" to "true"))
skipOverwrite.set(true)
verbose.set(true)
validateSpec.set(false)
library.set("jvm-ktor")
}
Steps to reproduce
Create a multipart file upload API in Spring
Use the swagger.json to generate a ktor client for the upload API
try uploading a file using the generated client
Spring will respond with 400 with the error required field file is missing. I narrowed down the issue to be that the generated client is missing HTTP Headers ContentDisposition with filename. If I manually add this header then the API call works as expected as shown below
Bug Report Checklist
Description
Multipart file upload using generated client does not work due to missing filename in content disposition headers. I generated a client against an upload API in Kotlin Spring. When using the generated client to upload a file Spring returns status 400 indicating the file has not been uploaded. After a bit of digging I found that Spring is expecting the filename in content disposition but its missing from the generated client.
Actual Output: Returns status 400 due to file missing
Expected Output: The file should be uploaded and return a status 200
The issue seemed to resolve when I manually added the headers.
openapi-generator version
7.8.0 ( I did observe this issue in older versions as well.)
OpenAPI declaration file content or url
https://gist.github.com/JishnuRamesh/4aa53186b4725f6daff11aee641e3ee3
Generation Details
The API application is created using spring boot.
Code was generated using the below configuration
Steps to reproduce
Spring will respond with 400 with the error required field
file
is missing. I narrowed down the issue to be that the generated client is missing HTTP Headers ContentDisposition with filename. If I manually add this header then the API call works as expected as shown belowRelated issues/PRs
A similar issue was raised here
Files
GeneratedUploadApi.kt.txt
GeneratedUploadApiFixed.kt.txt
Upload.kt.txt
The text was updated successfully, but these errors were encountered: