API文档注解
Swagger 生成API文档常用注解实例,如:@Api("")、@ApiOperation("")、@ApiModel(value = "",description = "")
- controller类头部@Api(tags = "文章管理")配置
java
@RestController
@RequestMapping("/api/article")
@Api(tags = "文章管理")
public class ArticleController extends BaseController{}
- controller对应方法@ApiOperation("修改角色")配置
java
/**
* 查询文章列表
*/
@SaCheckLogin
@SaCheckPermission("article:list")
@ApiOperation("查询文章列表")
@GetMapping("/list")
public JSONObject listArticle(HttpServletRequest request) {
return articleService.listArticle(CommonUtil.request2Json(request));
}
- Api接口参数实体配置@ApiModel
java
/**
* 文章编辑
* @author jiangwei
*/
@ApiModel(value = "编辑文章对象",description = "编辑文章对象")
public class EditArticleReq implements Serializable{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "标题",name = "title",required=true)
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}