python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
https://flask-restx.readthedocs.io/en/latest/
Other
2.16k stars 335 forks source link

SwaggerUIBundle is not defined #549

Open viveksahu56722 opened 1 year ago

viveksahu56722 commented 1 year ago

I am using flask-restx==1.1.0

My Python is 3.8.10

Sometime I am seeing this issue in my swagger dashboard

GET https://{host}/api/swaggerui/swagger-ui-standalone-preset.js net::ERR_ABORTED 404 (NOT FOUND) {host}/:71 GET https://{host}/api/swaggerui/swagger-ui-bundle.js net::ERR_ABORTED 404 (NOT FOUND) {host}/:7 GET https://{host}/api/swaggerui/swagger-ui.css net::ERR_ABORTED 404 (NOT FOUND) (index):75 Uncaught ReferenceError: SwaggerUIBundle is not defined at window.onload ((index):75:40)

And my dashboard is not getting load because of this issue

Can someone please help me with this ? I am not able to find much about this issue in internet already

peter-doggart commented 1 year ago

@viveksahu56722 Did you install flask-restx using pip? It sounds like the swagger components are not installed.

If you clone the project directly from github, you need to have Invoke and npm installed and run inv assets to download the swagger components. We do this as part of the build process when it's published to pypi so they are included in the pip available version.

viveksahu56722 commented 1 year ago

@peter-doggart Yeah I have installed it using pip but this issue is not always there. Sometimes it is there and automatically gets fixed but again may occur after some time, what could be causing it ? The above solution for this case too as sometime its working fine ?

peter-doggart commented 1 year ago

It randomly appears whilst the application is running? How is the application deployed?

viveksahu56722 commented 1 year ago

Yes it has been appearing randomly, can it be because of API requests loads in server ? if there are very frequent calls ? Its deployed on VMware or Physical (Ubuntu 20.04) I think

pydevmans commented 1 year ago

Hi @viveksahu56722 , I agree @peter-doggart, seems like swagger files are not installed. I would recommand to start fresh with new venv and install all packages. Keep posted how that goes. :-)