Closed AlvaroGata closed 1 week ago
it would be something like this in attributes:
use OpenApi\Attributes as OA;
#[OA\Get(
...
responses: [
new OA\Response(
response: 400,
description: 'Authorization empty',
content: new OA\JsonContent(
oneOf: [
new OA\Schema(
items: new OA\Items(
properties: [
new OA\Property(property: "code", type: "integer", example: 4001),
new OA\Property(property: "message", type: "string", example: "Bad request"),
new OA\Property(property: "details", type: "string", example: "Authorization empty"),
]
)
),
// or with ...
new OA\Schema(ref: "#/components/schemas/YourSchema"), // reference to existing Schema
]
)
)]
)]
Description
I have some endpoints that return different bodies for the same response code. Specifically, when the status code is 400, I want to return different responses with an internal code, a message, and details.
I have seen in this link that schemas can be defined in OpenAPI 2.0, but I don't see how to do it with L5-Swagger. Link