2

在这段代码中,当此方法返回 Response.noContent.build(); 时,我可以使用 Status.class @ApiOperation 吗?

    @DELETE
    @Path("/property/{id}")
    @ApiOperation(value = "Delete", notes = "Delete a persisted property from data source.", response = Status.class??)
    public Response delete(String id){
    ...
    ...
    return Response.noContent().build();
    }
4

1 回答 1

3

您可以省略该response部分,它将Void.class默认使用。从文档

public abstract Class<?> response

操作的响应类型。在 JAX-RS 应用程序中,将自动使用方法的返回类型,除非它是javax.ws.rs.core.Response. 在这种情况下,操作返回类型将默认void为无法知道实际响应类型。(强调我的)

设置此属性将覆盖任何自动派生的数据类型。

如果使用的值是表示原始类型 ( Integer, Long, ...) 的类,则将使用相应的原始类型。

默认

java.lang.Void.class

于 2015-07-21T22:20:27.943 回答