DarkaOnLine / L5-Swagger

OpenApi or Swagger integration to Laravel
https://github.com/DarkaOnLine/L5-Swagger
MIT License
2.64k stars 394 forks source link

Hit JavaScript error when you press the execute button on the docs page #524

Closed arlexw90 closed 1 month ago

arlexw90 commented 1 year ago

Description:

L5 Swagger UI - Google Chrome 2023-01-27 09 24 46

Steps To Reproduce:

.../app/Http/Controllers/Controller.php

/**
 * @SWG\Swagger(
 *   @SWG\Info(
 *     title="Site Title",
 *     version="1.0",
 *     description="Site description",
 *     @SWG\Contact(
 *         email="xyz@xyz.com"
 *     )
 *   )
 * )
 */

../app/Http/Controllers/ProductController.php

/**
     * @SWG\Get(
     *      path="/api/products",
     *      summary="Get list User",
     *      description="Returns User data",
     *      security={{"bearerAuth":{}}},
     *      @SWG\Response(
     *          response=200,
     *          description="Successful operation",
     *       ),
     *      @SWG\Response(
     *          response=400,
     *          description="Bad Request"
     *      ),
     *      @SWG\Response(
     *          response=401,
     *          description="Unauthenticated",
     *      ),
     *      @SWG\Response(
     *          response=403,
     *          description="Forbidden"
     *      )
     * )
     */

Access http://127.0.0.1:8000/api/documentation then click the execute button, it doesn't render any response but I noticed some error shown on the console area, you can check my screenshot at above.

DarkaOnLine commented 1 year ago

You need to check your base path is set correctly: https://github.com/DarkaOnLine/L5-Swagger/blob/master/config/l5-swagger.php#L90

gioid commented 1 year ago

I have the same problem. I tried to set the base path through L5_SWAGGER_BASE_PATH on the .env file, but I get this error:

$ php artisan l5-swagger:generate
Regenerating docs

In Logger.php line 39:

  Unexpected field "basePath" for @OA\OpenApi(), expecting "openapi", "info", "servers", "paths", "components", "security", "tags", "externalDocs", "x" in 

I think this PR is missing on the 5.5x branch, right? https://github.com/DarkaOnLine/L5-Swagger/issues/147