java—如何在自定义注解中有选择地使用注解

oxalkeyp  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(233)
@Target({METHOD, TYPE})
@ApiResponses(value = {
            @ApiResponse(code = 200, message = "OK"),
            @ApiResponse(code = 400, message = "Bad Request", response = ResourceErrorModel.class),
            @ApiResponse(code = 401, message = "Unauthorized", response = ResourceErrorModel.class),
            @ApiResponse(code = 403, message = "Forbidden", response = ResourceErrorModel.class),
            @ApiResponse(code = 404, message = "Not Found", response = ResourceErrorModel.class),
            @ApiResponse(code = 409, message = "Conflict", response = ResourceErrorModel.class),
            @ApiResponse(code = 422, message = "Unprocessable Entity", response = ResourceErrorModel.class),
            @ApiResponse(code = 424, message = "Failed Dependency", response = ResourceErrorModel.class)})
public @interface DefaultAPIResponse{}

谁能帮我解决这个问题。如果我们用@defaultapiresponse替换,它将替换它下面定义的所有注解,但是如果我们想根据需要使用它,比如如果我们想排除@apiresponse(代码=422和424),该怎么办。是否有任何方法可以根据选择在自定义注解中使用选择性api响应注解。如果那样的话怎么实施?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题