如何修复错误响应模型swagger 2

时间:2019-01-18 08:19:19

标签: error-handling swagger swagger-2.0 error-code

我正在尝试生成带有招摇注解的文档。当我生成yml文件时,我看到很多错误,例如:“ $ refs必须引用文档中的有效位置”以获取错误代码。 即使我没有定义错误响应,我也会看到:$ ref:'#/ definitions / ErrorResponse'。对于定义的错误响应,我也看到同一行。

这是代码示例:

@ApiOperation(value = "Get details about an account")
@ApiResponses({
        @ApiResponse(code = 401, message = "Unauthorized : Account ID unknown", response = ServiceErrorResponse.class),
        @ApiResponse(code = 401, message = "Unauthorized : Unknown consent", response = ServiceErrorResponse.class),
        @ApiResponse(code = 403, message = "Consent unknown", response = BerlinGroupErrorResponse.class),
        @ApiResponse(code = 503, message = "Service unavailable")
})
AccountResponse getAccountDetails(@ApiParam(value = "Account identifier", required = true) String accountId,
        @ApiParam(value = "Include the booking balance in the account details") Boolean withBalance);

并使用@ApiModel(description =“其他错误信息”)注释对ServiceErrorResponse进行注释

0 个答案:

没有答案