Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vibonacci opened this issue Apr 12, 2024 · 3 comments

Comments

@vibonacci
Copy link

vibonacci commented Apr 12, 2024

  • 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?

@DarkaOnLine
Copy link
Owner

@vibonacci Would you like to submit PR for this?

@vibonacci
Copy link
Author

vibonacci commented Apr 12, 2024

I'll give it a shot 🙂

@BorisWild
Copy link

BorisWild commented May 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants