如何在swagger-ui生成的文档中显示@PostMapping参数?

时间:2017-11-07 15:48:13

标签: java spring swagger swagger-ui springfox

我使用springfox-swagger2springfox-swagger-ui进行自动生成的REST文档。

问题:任何GET请求都记录得很好。但是当涉及POST个请求时,请求体参数描述不会显示在swagger ui中。但为什么呢?

@RestController
public class PersonController {
    @GetMapping
    public PersonRsp findPerson(PersonDTO p) {
        //this works just fine an shows the @ApiParam fields in documentation
    } 

    @PostMapping
    public PersonRsp updatePerson(@RequestBody PersonDTO p) {
        //service logic
        return rsp;
    }
}

class PersonDTO {
    @ApiParam(required = true, value = "the persons family name")
    private String lastname;

    private String firstname;

    @ApiParam(value = "date of birth in format YYYY-MM-DD")
    private Date dob;
}

问题:如何在swagger-ui文档中显示@ApiParam注释提示?

1 个答案:

答案 0 :(得分:0)

简单回答:似乎必须对@ApiModelProperty("some description")次请求使用POST,对@ApiParam次请求使用GET