springboot 整合 swagger(2)注解使用


1:@Api:用在类上,对类进行描述

@Api(tags = "用户controller")

2:@ApiOperation:用在方法上,对方法描述

 @ApiOperation(value = "这是用户的查询方法")

3:@ApiImplicitParams   对于参数的描述,若传入参数是对象,则不需要加此注解,swagger会自动翻译,对象参数前加上 @requestBody

@ApiImplicitParams({
    @ApiImplicitParam(name = "id",value = "用户userId",dataType = "String",defaultValue = "默认值"),
    @ApiImplicitParam(name = "name",value = "用户userName",dataType = "String",defaultValue = "binbin")
})

4:@ApiResponses 用在方法上描述返回值

 @ApiResponses({
            @ApiResponse(code = 200,message = "成功"),
            @ApiResponse(code = 201,message = "失败")
    })

 5:@ApiModel("用户实体类") 写在 entity上

6:@ApiModelProperty("密码") 写在属性上