pom 中配置
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.5.0</version>
</dependency>
启动类中加注解
@EnableSwagger2
Controller中配置(其中 notes 支持 markdown)
/**
* Created by johnzh on
* 2017/4/21. 22:08
*/
@Api(description = "商户系统")
@RestController
@RequestMapping(value = "/merchant")
public class MerchantController extends BaseController{
private final MerchantService merchantService;
@Autowired
public MerchantController(MerchantService merchantService) {
this.merchantService = merchantService;
}
@ApiOperation(value = "获取待办任务", httpMethod = "GET", notes = ApiNote.BACKLOG)
@ApiImplicitParams({
@ApiImplicitParam(value = "页数", paramType = "query", name = "page", dataType = "int", required = true),
@ApiImplicitParam(value = "大小", paramType = "query", name = "size", dataType = "int", required = true)
})
@GetMapping(value = "/backLog", produces = "application/json;charset=UTF-8")
public String getBackLog(@Param("page") Integer page, @Param("size") Integer size, HttpSession session){
Integer userId = getUserId(session);
List<OrderDO> orderDOList = merchantService.getBackLog(userId, page, size);
return responseList(orderDOList);
}
}