Currently I have something like this:
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'
Is it possible to combine all three error responses and reference them with a $ref?
paths:
/home
...
responses:
200:
description: Successful operation
$ref: '#/components/responses/AllCommonErrorResponses’
/sign_up
...
responses:
201:
description: Created
$ref: '#/components/responses/AllCommonErrorResponses’
Currently I dont know all the error responses we will use. But there will be a set of shared. If we will extend them later, I dont want to go to every endpoint and adjust the responses.
OpenAPI v3 does not allow to reference a list of multiple responses.
You can use specific (e.g., "200") response codes or default for others.
There is no option to import a standard list of responses and reuse it.