Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger does not publish assets files in laravel 5.6

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.

like image 628
Ian Nato Avatar asked Aug 30 '25 17:08

Ian Nato


2 Answers

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

like image 157
Ashfaq Muhammad Avatar answered Sep 02 '25 06:09

Ashfaq Muhammad


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

like image 22
hassan helfi Avatar answered Sep 02 '25 07:09

hassan helfi