DarkaOnLine / L5-Swagger

OpenApi or Swagger integration to Laravel

Home Page:https://github.com/DarkaOnLine/L5-Swagger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specify Two Responses with the Same Response Code

AlvaroGata opened this issue · comments

  • L5-Swagger Version: 8.6
  • PHP Version 8.1
  • OS: N.A.

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.

@OA\Response( response=400, description="Authorization empty",
     *         @OA\JsonContent(
     *             @OA\Property( property="code", type="integer", example=4001 ),
     *             @OA\Property( property="message", type="string", example="Bad request" ),
     *             @OA\Property( property="details", type="string", example="Authorization empty" ),
     *         ),
     *     ),

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