L5-Swagger: API documentation is not shown (show blank page)

I used fresh Laravel 5.4.28 and fresh L5-Swagger version 5.0.3. I have followed the installation and worked properly (also executed l5-swagger:publish). But the documentation page is not shown.

Just read issue #73 and followed the instruction there, and my page is still blank (the background is light grey, so I supposed the CSS was loaded correctly).

I inspected and found errors mentioning all asset files asset/swagger-ui.css, asset/swagger-ui-bundle.js, and asset/swagger-ui-standalone-preset.js are not found (HTTP 404).

The console showed error:

documentation:75 Uncaught ReferenceError: SwaggerUIBundle is not defined at window.onload
window.onload @ documentation:75

I visited all asset files URL, all files are found and loaded correctly.

Is there something missing? I check the swagger-ui version is 3.0.19.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@matriphe Adding try_files to the block in Nginx config worked for me.

location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
    try_files $uri /index.php;
    access_log off;
    expires 365d;
}

@ivanm Wow! Thanks for your help!

It’s confirmed, the problem is in the Nginx config. After removing this block in my Nginx, the docs shown correctly.

location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
	expires 365d;
}

I had a similar problem, removing this part from my nginx config solved the issue:

location ~ ^/assets/(img|js|css)/(.*)$ {
    try_files $uri $uri/ /wp-content/themes/sitename/assets/$1/$2;
  }

nginx was trying the assets before php does.

None of this helped me. But this helped me:

    if (!-e $request_filename) {
      rewrite ^.*$ /index.php last;
    }

@crestpointmediaph in nginx.conf just in server. For example:

server {
    listen 80 default;

    client_max_body_size 108M;

    access_log /var/log/nginx/application.access.log;

    root /application/public;
    index index.php;

    if (!-e $request_filename) {
        rewrite ^.*$ /index.php last;
    }
...

Unexpected end of input

this error is coming in console with blank page.

@josedsilva Many thanks