1

I have a Flask application and I've integrated Flasgger for documentation. When I run my app locally, I can access swagger at http://127.0.0.1:5000/apidocs. But when it's deployed to our dev environment, the hostname is https://services.company.com/my-flask-app. And when I add /apidocs at the end of that URL, swagger does not load.

This is how I've configured swagger:


swagger_config = {
    "headers": [],
    "specs": [
        {
            "endpoint": "APISpecification",
            "route": "/APISpecification",
            "rule_filter": lambda rule: True,  # all in
            "model_filter": lambda tag: True,  # all in
        }
    ],
    "static_url_path": "/flasgger_static",
    "specs_route": "/apidocs/",
    "url_prefix": "/my-flask-app", # TODO - redo this for INT deployment
}

When I run this, on my local I can access swagger at http://127.0.0.1:5000/my-flask-app/apidocs/#/, but I think on my dev environment it'd probably be accessible at https://services.company.com/my-flask-app/my-flask-app/api-docs. When I check the console, Flasgger tries to get the css from https://services.company.com/ not https://services.company.com/my-flask-app

Any ideas on how I can resolve this?

davidism
  • 121,510
  • 29
  • 395
  • 339
Saturnian
  • 1,686
  • 6
  • 39
  • 65
  • I'm facing a similar issue with the one you described. I managed to override the `swagger_ui_css`, `swagger_ui_bundle_js`, `swagger_ui_bundle_js`, and `jquery_js` keys and get Swagger displayed, but the path to the `swagger.json` file is still wrong since the path parameter (`my-flask-app` in your example) is not included. Did you find any way to put relative paths in specs/route? – Mihai Pantea Aug 09 '22 at 09:09
  • Not yet - I will post on here if I do! – Saturnian Aug 09 '22 at 15:06

0 Answers0