Spring Boot 配合 swagger 使用

pom 中配置

        
        
            io.springfox
            springfox-swagger2
            2.5.0
        
        
            io.springfox
            springfox-swagger-ui
            2.5.0
        

启动类中加注解

@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 orderDOList = merchantService.getBackLog(userId, page, size);
        return responseList(orderDOList);
    }
}

你可能感兴趣的:(Spring Boot 配合 swagger 使用)