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

L5-swagger config doesn't support swagger-php option to add multiple servers / base URLs

vibonacci opened this issue · comments

  • L5-Swagger Version: 8.5
  • PHP Version 8.3
  • OS: N.A.

Description:

OpenApi 3.x, swagger-php and swagger-ui support multiple servers / base URLs to be defined.

However, l5-swagger.php config file will not accept an array - or anything else for that matter - to have multiple servers end up in the servers array in the open-api-docs.json.

I've tried in l5-swagger.php:

           /*
             * Edit to set the api's base path
            */
            'base' => env('L5_SWAGGER_BASE_PATH', [
                ['url' => env('API_URL')],
                ['url' => env('APP_URL')],
            ]),

            /*
             * Edit to set the api's base path
            */
            'base' => env('L5_SWAGGER_BASE_PATH', [
                env('API_URL'),
                env('APP_URL'),
            ]),

Both do not result in the proper structure:

    "servers": [
        {
            "url": [
                "http://localhost/api",
                "http://localhost"
            ]
        }
    ],

afbeelding

    "servers": [
        {
            "url": [
                {
                    "url": "http://localhost/api"
                },
                {
                    "url": "http://localhost"
                }
            ]
        }
    ],

Could support for this be added? It is quite useful.
Or this there another way to hook into the open-api-docs.json generation to add it manually in the meantime?

@vibonacci Would you like to submit PR for this?

I'll give it a shot 🙂

Specify for all routes:

* @OA\Server(
 *      url="/api/v1",
 *      description="API Server"
 * )
 *
 * @OA\Server(
 *      url="/",
 *      description="Session Server"
 * )

image

or specify server for a single route

 *     @OA\Response(
     *          response="422",
     *          ref="#/components/responses/422"
     *      ),
     *      @OA\Server(
     *      url="/",
     *      description="Session Server"
     *     ),

image