我正在努力正确地描述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时,上面的描述并没有显示出来。这里的错误是什么?
发布于 2021-04-11 20:51:58
只需使用@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;
https://stackoverflow.com/questions/67049928
复制相似问题