Springdoc java不读取带有对象的数组里面

问题描述 投票:0回答:1

我发送了一个请求,除了这张表之外的所有内容都已在那里阅读

  @PostMapping(value = "/endLesson", consumes = "multipart/form-data") public ResponseEntity<?> something(@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true) @ModelAttribute FirstDto firstDto, BindingResult bindingResult){ log.info(firstDto);
...
2024-02-07T00:38:22.948+02:00  INFO 121296 FirstDto(id=3, reviews=null)
input data

java spring http dto springdoc
1个回答
0
投票
@Data
public class FirstDto{
    @NotNull
    private Long id;
    @NotNull
    @Size.List({
            @Size(min = 1, message = "Review must not be empty"),
            @Size(max = 50, message = "Review must have at most 50 characters")
    })
    private ArrayList<SecondDto> reviews;
    @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true)
    public ArrayList<SecondDto> getReviews() {
        return reviews;
    }
}
@Data
public class SecondDto{
    @NotNull
    private Boolean isPresent;
    @Size(max = 500)
    private String reason;
}
    @PostMapping(value = "/endLesson", consumes = "multipart/form-data") 
public ResponseEntity<?> something(@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true) @ModelAttribute FirstDto firstDto, 
BindingResult bindingResult)
{ log.info(firstDto); 
... 
2024-02-07T00:38:22.948+02:00 INFO 121296 FirstDto(id=3, reviews=null)

我尝试通过@JsonProperty @JsonUnwrapped 修复它,但没有成功。 丢弃

© www.soinside.com 2019 - 2024. All rights reserved.