Swagger-Core 似乎将 @Suspished 最终 AsyncResponse asyncResponse 成员解释为请求正文参数。这显然不是有意的,也不是事实。
我想告诉 swagger-core 忽略此参数并将其从 api 文档中排除。有任何想法吗?
这就是我的代码的样子:
@Stateless
@Path("/coffee")
@Api(value = "/coffee", description = "The coffee service.")
public class CoffeeService
{
@Inject
Event<CoffeeRequest> coffeeRequestListeners;
@GET
@ApiOperation(value = "Get Coffee.", notes = "Get tasty coffee.")
@ApiResponses({
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 404, message = "Beans not found."),
@ApiResponse(code = 500, message = "Something exceptional happend.")})
@Produces("application/json")
@Asynchronous
public void makeCoffee( @Suspended final AsyncResponse asyncResponse,
@ApiParam(value = "The coffee type.", required = true)
@QueryParam("type")
String type)
{
coffeeRequestListeners.fire(new CoffeeRequest(type, asyncResponse));
}
}
更新:基于答案的解决方案
public class InternalSwaggerFilter implements SwaggerSpecFilter
{
@Override
public boolean isOperationAllowed(Operation operation, ApiDescription apiDescription, Map<String, List<String>> stringListMap, Map<String, String> stringStringMap, Map<String, List<String>> stringListMap2) {
return true;
}
@Override
public boolean isParamAllowed(Parameter parameter, Operation operation, ApiDescription apiDescription, Map<String, List<String>> stringListMap, Map<String, String> stringStringMap, Map<String, List<String>> stringListMap2) {
if( parameter.paramAccess().isDefined() && parameter.paramAccess().get().equals("internal") )
return false;
return true;
}
}
FilterFactory.setFilter(new InternalSwaggerFilter());
修改后的示例代码片段
...
@Asynchronous
public void makeCoffee( @Suspended @ApiParam(access = "internal") final AsyncResponse asyncResponse,...)
...