@ErrorResponse
指定接口失败返回的示例数据,用法:@ErrorResponse 返回类型 返回状态码 其他说明。
返回类型 为常见的http返回类型,如:text/html、text/xml、image/png、application/json等。
返回状态码 为常见的http失败返回状态码,如:404、500等。
该指令可以定义多条,用来区分不同的返回情况。
示例:
/**
* @ApiStart
*
* @Name getDemo
* @Group demoGroup
*
* @Api get /api/getTest
*
* @QueryParam {Number} page 此处page为必传字段
*
* @ErrorResponse application/json 400 error response demo
*
* {
* status: "fail",
* message: "error message"
* }
*
* @ErrorResponse application/json 403 Forbidden response demo
*
* {
* status: "fail",
* message: "error message"
* }
*
* @ApiEnd
*/
如上注解会生成一下内容:
