如何注释请求体来描述示例

How to annotate request body to describe examples

我正在努力正确描述 requestBody。 我有这个 Dto 作为请求正文:

public @Data class ContactDto {
@Parameter(description = "Mailadress required if messageType is MAIL")
private String mailAddress;
@Parameter(description = "Phonenumber required if messageType is not MAIL", example = 
"0041791234567")
private String phoneNumber;
@Parameter(description = "Message type which will be used to inform the user", examples = {
        @ExampleObject(name = "SMS", value = "SMS"),
        @ExampleObject(name = "MAIL", value = "MAIL")
})
private MessageType messageType;

}

控制器中的这个:

@PostMapping(consumes = "application/json")
public ResponseEntity<Object> createWichtel(@RequestBody() final WichtelDetailsDto wichtelDetailsDto) 
{
    return new ResponseEntity<>(HttpStatus.CREATED);
}

我正在使用 Spring 和 springdoc-openapi-ui

但是当我打开swagger-ui时,上面的描述没有显示。 这里有什么错误?

只需使用@ApiParam

public @Data class ContactDto {
@ApiParam(value = "Mailadress required if messageType is MAIL")
private String mailAddress;
@ApiParam(value = "Phonenumber required if messageType is not MAIL", example = 
"0041791234567")
private String phoneNumber;
@ApiParam(value = "Message type which will be used to inform the user", example = "{(name = \"SMS\", value = \"SMS\")}")
private MessageType messageType;