Swagger示例参数值

时间:2017-09-06 09:20:46

标签: java spring swagger swagger-ui

我想在Swagger-ui界面的数据类型下修改Example Value。目前它包含以下默认值(由Swagger生成):

"user":{
        "birth":null,
        "nationality":null,
        "lastname":null,
        "firstname":null,
        "identity":null
     }

我想指定实际值而不是" null"值。 PS:我使用带注释的spring boot:@ApiOperation,...

1 个答案:

答案 0 :(得分:0)

然后必须为bean中的所有属性插入@ApiModelProperty anotation。然后在里面放一个示例属性。假设您的用户已映射到User.java类,因此您将拥有:

public class User {

    @ApiModelProperty(value = "The birthdate", example = "1985-12-07", format= "yyyy-MM-dd")
    private String birth;