框架学习

spring boot学习之 api接口注释

Swagger接口注解注释,接口定义为中文

1. 接口注解为中文

@Api(value = "接口定义", description = "相关接口" , tags={"****接口"})
@RestController
public class XXController extends XXPController implements XXFacade 

 

2.方法注解

 @ApiOperation(value = "**详情/基本信息", httpMethod = "GET", produces = "application/json", notes = "**详情/基本信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "userid", paramType = "header", value = "userid参数说明", required = true, dataType = "String"),            
            @ApiImplicitParam(name = "id", paramType = "query", value = "模块ID", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "bid", paramType = "query", value = "其他字段", required = false, dataType = "String"),
            @ApiImplicitParam(name = "p", paramType = "query", value = "当前第几页", required = true, dataType = "int"),
            @ApiImplicitParam(name = "ps", paramType = "query", value = "每页条数", required = true, dataType = "int")
    })
   public ReturnResult<DetailVo> queryDetail(String userid, Long id, String bid,
                                                                 int p, int ps)

        @RequestHeader(value = "userid", required = true) String userid,   
                @RequestParam(value = "id", required = false) Long id,
                @RequestParam(value = "bid", required = false) String bid,
      @RequestParam(value = "p", required = false) Integer bid,
    @RequestParam(value = "ps", required = false) Integer bid

3. 返回对象的注解


@ApiModel("详情")
public class DetailVo {
    @ApiModelProperty(value = "id")
    private Long id;
    @ApiModelProperty(value = "名称")
    private String name;
    @ApiModelProperty(value = "区域")
    private Integer age;
}


原文链接:https://blog.csdn.net/yunxing323/article/details/108616134