Skip to content
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

ParameterObject annotation dosen't work when has RequestPart annotation #2572

Open
YoungTakhin opened this issue Apr 13, 2024 · 0 comments
Open

Comments

@YoungTakhin
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant