Closed
Description
Describe the bug
A controller that consumes a MultipartFile
and has a query parameter generates an incorrect spec.
To Reproduce
Steps to reproduce the behavior:
- What version of spring-boot you are using? 2.7.2
- What modules and versions of springdoc-openapi are you using? springdoc-openapi-ui:1.6.10
- What is the actual and the expected result using OpenAPI Description (yml or json)?
Expected (Generated spec with version 1.5.10):Actual:"/api/v1/file-upload": { "post": { "operationId": "uploadFile", "parameters": [ { "name": "targetDirectory", "in": "query", "required": true, "schema": { "type": "string" } } ], "requestBody": { "content": { "multipart/form-data": { "schema": { "required": [ "file" ], "type": "object", "properties": { "file": { "type": "string", "format": "binary" } } } } } } [...] } },
"/api/v1/file-upload": { "post": { "operationId": "uploadFile", "requestBody": { "content": { "multipart/form-data": { "schema": { "required": [ "file" ], "type": "object", "properties": { "file": { "type": "string", "format": "binary" }, "targetDirectory": {} } } } } } [...] } },
- Provide with a sample code (HelloController) or Test that reproduces the problem
@RestController
@RequestMapping("/api/v1/file-upload")
public class FileUploadController {
@PostMapping(consumes = {"multipart/form-data"})
@ResponseStatus(HttpStatus.NO_CONTENT)
@PreAuthorize(UPLOAD_FILES)
public void uploadFile(
@RequestParam("targetDirectory") String targetDirectory,
@RequestParam("file") MultipartFile multipartFile)
throws IOException {
}
}
Expected behavior
targetDirectory
should be a query parameter, not part of the request body
CC @Digirik
Metadata
Metadata
Assignees
Labels
No labels