Home  >  Q&A  >  body text

java - spring boot和swagger中怎么隐藏请求参数?

swagger2和springboot整合时,controller里面方法的请求参数是一个实体对象,但是生成api文档时不需要实体对象的所有属性作为请求参数。

controller方法如下
@ApiOperation(value = "测试隐藏属性",httpMethod = "GET")
@RequestMapping("/testHidden")
public  String testHidden(@ModelAttribute User user){

    return "success";
}


实体对象属性加了hidden注解但是在接口文档中并没有隐藏,有谁知道怎么解决吗?
@ApiModel
public class User {

    private Long id;
    
    @ApiModelProperty(hidden = true)
    private String name;
    
    private Integer age;
    
    我想隐藏name参数,怎么解决?

天蓬老师天蓬老师2761 days ago678

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 09:54:10

    All annotations can be implemented by importing the io.swagger.annotations package

    reply
    0
  • 阿神

    阿神2017-04-18 09:54:10

    Owner, has the problem been solved?

    reply
    0
  • Cancelreply