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

Swagger-UI Resources Missing #100

Closed
s1rc opened this issue Nov 22, 2017 · 10 comments
Closed

Swagger-UI Resources Missing #100

s1rc opened this issue Nov 22, 2017 · 10 comments

Comments

@s1rc
Copy link

s1rc commented Nov 22, 2017

  • L5-Swagger Version: 5.5.2
  • PHP Version (php -v): 7.1.8
  • OS: macOS

Description:

When trying to view API Docs, css and js assets are missing. Server returns 404. Do I need to add these into the vendor folder generated from artisan l5-swagger:publish

:8080/docs/asset/swagger-ui.css Failed to load resource: the server responded with a status of 404 (Not Found)
09:36:05.147 swagger-ui-bundle.js Failed to load resource: the server responded with a status of 404 (Not Found)
09:36:05.147 swagger-ui-standalone-preset.js Failed to load resource: the server responded with a status of 404 (Not Found)
09:36:05.435 documentation:75 Uncaught ReferenceError: SwaggerUIBundle is not defined
    at window.onload (documentation:75)
09:36:05.455 :8080/docs/asset/favicon-16x16.png Failed to load resource: the server responded with a status of 404 (Not Found)
09:36:05.457 :8080/docs/asset/favicon-32x32.png Failed to load resource: the server responded with a status of 404 (Not Found)
09:36:09.536 swagger-ui.css Failed to load resource: the server responded with a status of 404 (Not Found)

Steps To Reproduce:

  1. Setup L5-Swagger with composer
  2. Run artisan l5-swagger:publish
  3. Modify l5-swagger.php config file
  4. Run artisan config:cache
  5. Run artisan route:cache
  6. Run artisan l5-swagger:generate
@DarkaOnLine
Copy link
Owner

DarkaOnLine commented Nov 22, 2017

It looks like a php build in server issue.

How are you running your php server?

Please try this: php -S localhost:8080 -t public or php -S localhost:8080 public/index.php

@s1rc
Copy link
Author

s1rc commented Nov 22, 2017

php -S localhost:8080 -t public does not work, resources are still 404.
php -S localhost:8080 public/index.php does work for Swagger-ui, however now all the assets in the main application are 404.

Edit:
I am running locally using the built in php server. The command is from IntelliJ and like php -S localhost:8080 -t public just with full directory paths.

@DarkaOnLine
Copy link
Owner

I am not using php server and don't know much about them. I recommend you to try Laravel valet - simple to install, works with a bunch of frameworks.

Closing this, cause it's not related to the package.

@sohaieb
Copy link

sohaieb commented Sep 3, 2019

Hello, I have the solution,
you have first to check updates with this command:
composer update
then publish the Swagger views with this command :
php artisan swagger-lume:publish
and then create a new folder named swagger-ui-assets in laravel public folder,
finaly put wanted css & js files from {yourproject}/vendor/swagger-api/swagger-ui/dist to {yourproject}/public/swagger-ui-assets.
that's all

@Daniil-Solovyev
Copy link

Daniil-Solovyev commented Sep 9, 2020

In my case the problem was that I was dumping sql queries via the built-in dump() function in laravel. Actually, swagger should be displayed on a blank page, without debug panel, etc.

@thanhkhuatdac
Copy link

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

@es2ws
Copy link

es2ws commented Jul 7, 2021

what @thanhkhuatdac suggested works great, but better way for servers and mac without copying is symlink:
ln -s /path-to-your-laravel-app/vendor/swagger-api/swagger-ui/dist/ /path-to-your-laravel-app/public/docs/asset
and also keep i mind that you need to have /path-to-your-laravel-app/public/docs already created

@WuzorGiftKnowledge
Copy link

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

This works fine on my localhost but when I deploy the app api/documentation returns 404 error

@omept
Copy link

omept commented Oct 14, 2021

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

This works fine on my localhost but when I deploy the app api/documentation returns 404 error

You have to use the full file url. It's assuming that you're trying to fetch a route.

i.e Use
/api/documentation/index.html

@Gossteer
Copy link

Gossteer commented Nov 2, 2022

Maybe you use common settings for nginx:

    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
        expires max;
        try_files $uri =404;
    }

Need add:

    location ~ (^/docs/asset/.*) {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
        expires max;
        try_files $uri =404;
    }

Or wait - #503

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

9 participants