I\'m defining a path for a nested resource (content belonging to a delivery). If the client gets a 404 it could either because the delivery ID was not found, or the deliver
Multiple response types per status code are not allowed in OpenAPI/Swagger 2.0, but are supported in OpenAPI 3.0 by using oneOf.
In OpenAPI 2.0, you can only have a single schema for a 404 response:
responses:
'404':
description: delivery not found, or delivery did not contain any articles
schema:
$ref: '#/definitions/Error'
...
definitions:
Error:
type: object
properties:
status:
type: integer
type:
type: string
message:
type: string
where the Error
payload can be, say:
{
"status": 404,
"type": "DeliveryNotFoundError",
"message": "delivery not found"
}
{
"status": 404,
"type": "NoArticlesInDeliveryError",
"message": "delivery did not contain any articles"
}