目前我有这样的东西:
paths:
/home
...
responses:
200:
description: Successful operation
401:
$ref: '#/components/responses/401UnauthorizedDefault'
404:
$ref: '#/components/responses/404NotFound'
502:
$ref: '#/components/responses/502BadGatewayDefault'
/sign_up
...
responses:
201:
description: Created
401:
$ref: '#/components/responses/401UnauthorizedDefault'
404:
$ref: '#/components/responses/404NotFound'
502:
$ref: '#/components/responses/502BadGatewayDefault'
是否可以组合所有三个错误响应并使用$ref引用它们?
paths:
/home
...
responses:
200:
description: Successful operation
$ref: '#/components/responses/AllCommonErrorResponses’
/sign_up
...
responses:
201:
description: Created
$ref: '#/components/responses/AllCommonErrorResponses’
目前我不知道我们将使用的所有错误响应。但是会有一组共享的。如果我们稍后扩展它们,我不想去到每个端点并调整响应。
OpenAPI v3不允许引用多个响应的列表。
您可以使用特定的(例如,"200")响应码或其他的默认值。
没有导入标准响应列表并重用它的选项。