I'm using validation-api with Springdoc in my Spring boot application.
I want to use single DTO class in similar requests.
Springdoc checks validation-api's annotations, like @NotBlank
, @NotNull
. But doesn't check it's groups @NotBlank(groups = {GetGroup.class})
.
public class MyController {
@GetMapping
public MyResponseDto getFoo(@ParameterObject @Validated(GetGroup.class) MyRequestDto request) {
...
}
@PostMapping
public Long postFoo(@ParameterObject @Validated(PostGroup.class) MyRequestDto request) {
...
}
}
public class MyRequestDto {
@NotNull(group = {GetGroup.class})
private String field01;
@NotNull(group = {PostGroup.class})
private String field02;
}
The field01
required in @Validated(GetGroup.class)
, and field02
required in @Validated(PostGroup.class)
without Springdoc.
But Springdoc recognize them required fields.
How can I solve this problem?
This link is same issue.