Flask-Swagger-UI does not recognize path to swagger.json Flask-Swagger-UI does not recognize path to swagger.json flask flask

Flask-Swagger-UI does not recognize path to swagger.json


I believe that its a restriction on flask's end, but it seems like you must place static files in a folder explicitly named static/ at the root of your flask app.

Try changing

API_URL = 'app/templates/docs/swagger.json'

to

API_URL = '/static/swagger.json'

Then create a static/ folder in API/app/, and move your json into it. Like so: API/app/static/swagger.json

If that doesn't work, make sure you have the static/ folder in the correct directory, try print(app.root_path) after defining your flask app variable in order to see what flask considered the root path to be.


We can't provide any custom file path for swagger.json.

But there is one catch which we can do if you require.I was facing the same issue where I need to provide different prefix for swagger URL and swagger.json.If we just want to serve swagger.json file from a different prefix instead of '/static/swagger.json':

Then make changes as below:

APP = Flask(__name__, static_url_path = '/my-prefix/static')API_URL = '/my-prefix/static/swagger.json'