springdoc-openapi icon indicating copy to clipboard operation
springdoc-openapi copied to clipboard

ParameterObject annotation dosen't work when has RequestPart annotation

Open YoungTakhin opened this issue 10 months ago • 0 comments

the ParameterObject annotation dosen't work when the Controller has RequestPart annotation

the dependency version:

  • SpringBoot version is 3.2.4
  • Springdoc OpenAPI version is 2.5.0

My Controller like this:

    @Operation(summary = "upload file")
    @PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public FileInfo uploadFile(@ParameterObject FileInfoVO fileInfoVO, @RequestPart MultipartFile file) {
        System.out.println(fileInfoVO);
        return fileService.uploadFileInfo(fileInfoVO, file);
    }

the FileInfoVO:

public record FileInfoVO(
        @Schema(description = "creditId", requiredMode = REQUIRED)
        Long creditId,
        @Schema(description = "bucket name", requiredMode = REQUIRED)
        String bucketName,
        @Schema(description = "file key", requiredMode = NOT_REQUIRED)
        String fileKey
) {}

When I upload the file with the params of FileInfoVO, I got null like this:

FileInfoVO[creditId=null, bucketName=null, fileKey=null]

Is it a bug or I use it with wrong way? Help me pls, thx!

YoungTakhin avatar Apr 13 '24 07:04 YoungTakhin