Swagger常见注解
一、@Api
使用在类上,表明是swagger资源,@API拥有两个属性:value、tags,源码如下
//If tags is not used,this value will be used to set the tag for the operations described by this resource. Otherwise, the value will be ignored.
String value() default "";//Tags can be used for logical grouping of operations by resources or any other qualifier.
String[] tags() default {""};
生成的api文档会根据tags分类,直白的说就是这个controller中的所有接口生成的接口文档都会在tags这个list下;tags如果有多个值,会生成多个list,每个list都显示所有接口@Api(tags = "列表1")
@Api(tags = {"列表1","列表2"})
value的作用类似tags,但是不能有多个值

一、@ ApiOperation
使用于在方法上,表示一个http请求的操作.
value:用于方法描述
notes:用于提示内容
举例:
运行结果:
二、@PostMapping
定义前端访问的url,可以写在控制类上,也可以写在控制类汇总的方法上面,常用的的写在控制类上面,一般会与它的衍生注解组合使用:@GetMapping 查询请求@PostMapping 添加请求@PutMapping 修改请求@DeleteMapping 删除请求。

浙公网安备 33010602011771号