1
votes

i have installed laravel 5.6 with Swagger with DarkaOnLine/L5-Swagger package, i have followed the installation instructions that is

php composer require "darkaonline/l5-swagger:5.6.*"

php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"

i have also set

L5_SWAGGER_GENERATE_ALWAYS=true

in my env and created a controller and added

/**
 * @SWG\Swagger(
 *     schemes={"http","https"},
 *     host="api.host.com",
 *     basePath="/",
 *     @SWG\Info(
 *         version="1.0.0",
 *         title="This is my website cool API",
 *         description="Api description...",
 *         termsOfService="",
 *         @SWG\Contact(
 *             email="[email protected]"
 *         ),
 *         @SWG\License(
 *             name="Private License",
 *             url="URL to the license"
 *         )
 *     ),
 *     @SWG\ExternalDocumentation(
 *         description="Find out more about my website",
 *         url="http..."
 *     )
 * )
 */

after that i typed

php artisan l5-swagger:generate
php artisan vendor:publish

when i visit /api/documentation i get a white screen and in the console i am getting the following error

enter image description here

your help will be highly appreciated.

4
I have the same issue and could not found any solution still now...Ashfaq Muhammad

4 Answers

5
votes

I have fixed that issue by steps:

just copied files from vendor folder and added in the specific path.

Copy all the files from : laravel-yourapp\vendor\swagger-api\swagger-ui\dist

Then paste all files in path: laravel-yourapp\public\docs\asset

0
votes

1 - try to copy the /dist directory in \vendor\swagger-api\swagger-ui to \public_html\swagger-api\

2 - change "swagger_ui_assets_path" address from \config\l5-swagger.php to 'public_html\swagger-api\'

3 - change all links in link and script tag in view file \resources\views\vendor\l5-swagger\index.blade.php

4- type command php artisan l5-swagger:generate or add L5_SWAGGER_GENERATE_ALWAYS=true in .env file

0
votes

in Laravel 8. The documentation says that it uses a package auto-discovery feature. But it's not true.

You have to add to your config/app.php in the providers section:

L5Swagger\L5SwaggerServiceProvider::class,

Then, you have to run the

php artisan config:cache

And only then, you can run the

php artisan vendor:publish --provider 'L5Swagger\L5SwaggerServiceProvider'
-1
votes

After Debugging i have found that the error was coming when i was accessing the the swagger page via an open localhost port eg http://localhost:8000/api/documentation , the solution is to access it via the full laravel url eg http://localhost/my-app-name/public/api/documentation