-
-
Notifications
You must be signed in to change notification settings - Fork 524
List<MultipartFile>
parameters incorrectly recognized as String
in Swagger UI with org.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0
and above
#2656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for your feedback on my issue. I apologize for not noticing that this issue had already been reported. I appreciate you bringing it to my attention and providing the necessary information. I am sorry for any inconvenience this may have caused. Thank you again for your assistance. Best regards. |
Hello Maintainer, @bnasslahsen I recently encountered an issue with Spring Documentation GuidelinesThe official Spring documentation generally recommends using the @Controller
public class FileUploadController {
@PostMapping("/upload")
public String handleFileUpload(@RequestParam("file") MultipartFile file) {
if (!file.isEmpty()) {
byte[] bytes = file.getBytes();
// File processing logic
return "redirect:uploadSuccess";
}
return "redirect:uploadFailure";
}
}
Issues with Using
|
Maybe you could try replacing The version I use: @Controller
public class FileUploadController {
@PostMapping("/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public String handleFileUpload(
@RequestPart("file")
@Schema(description = "just description", type = "file", format = "binary")
MultipartFile file
) {
if (!file.isEmpty()) {
byte[] bytes = file.getBytes();
// File processing logic
return "redirect:uploadSuccess";
}
return "redirect:uploadFailure";
}
} request code : public static void main(String[] args) throws Exception {
String filepath = "**********.pdf";
HttpPost httpPost = new HttpPost("http://127.0.0.1:8080/upload");
try (FileInputStream fileInputStream = new FileInputStream(filepath);
CloseableHttpClient httpClient = HttpClientBuilder.create().build()){
MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
entityBuilder.setContentType(ContentType.MULTIPART_FORM_DATA);
entityBuilder.addBinaryBody("file", fileInputStream, ContentType.APPLICATION_OCTET_STREAM,"**********.pdf");
httpPost.setEntity(entityBuilder.build());
String resString = httpClient.execute(httpPost, response -> EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8));
System.out.println(resString);
}
} |
Thank you for your suggestion. I tested using |
Describe the bug
When receiving
org.springframework.web.multipart.MultipartFile
from the client, Swagger correctly handles the type. However, whenMultipartFile
is declared as a List, it incorrectly identifies the type asString
. This issue appears to occur with versions oforg.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0
and above.To Reproduce
Steps to reproduce the behavior:
multipartFile
parameter is recognized asString
instead ofMultipartFile
.Spring Boot version: 3.3.2
Springdoc OpenAPI version: 2.4.0 and above
Expected behavior
Swagger should correctly identify the
multipartFile
parameter as aList<MultipartFile>
instead of aString
.Screenshots
2.4.0 and above
2.3.0
Additional context
This issue occurs specifically with versions of
org.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0
and above.The text was updated successfully, but these errors were encountered: