Swagger 示例参数值
Swagger Example Parameter Value
我想在我的Swagger-ui界面上修改Data Type下的Example Value。目前它包含以下默认值(由 Swagger 生成):
"user":{
"birth":null,
"nationality":null,
"lastname":null,
"firstname":null,
"identity":null
}
我想指定实际值而不是 "null" 值。
PS:我使用 spring 引导并带有注释:@ApiOperation,...
然后您必须为 bean 中的所有属性插入 @ApiModelProperty 注释。然后在里面放一个example属性。假设您的用户映射到 User.java class,那么您将拥有:
public class User {
@ApiModelProperty(value = "The birthdate", example = "1985-12-07", format= "yyyy-MM-dd")
private String birth;
我想在我的Swagger-ui界面上修改Data Type下的Example Value。目前它包含以下默认值(由 Swagger 生成):
"user":{
"birth":null,
"nationality":null,
"lastname":null,
"firstname":null,
"identity":null
}
我想指定实际值而不是 "null" 值。 PS:我使用 spring 引导并带有注释:@ApiOperation,...
然后您必须为 bean 中的所有属性插入 @ApiModelProperty 注释。然后在里面放一个example属性。假设您的用户映射到 User.java class,那么您将拥有:
public class User {
@ApiModelProperty(value = "The birthdate", example = "1985-12-07", format= "yyyy-MM-dd")
private String birth;