1

I am trying to update my Swagger Base URL from '/' to '/testapp' for my REST API

This is my Swagger Config

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": "/swagger_doc/",
}

As per the config, I can access the Swagger Page at 127.0.0.1:4444/swagger_doc

I want to change it to 127.0.0.1:4444/testapp/swagger_doc

I have tried using basePath as /testapp in this config. Did not work.

Issue is 127.0.0.1:4444/swagger_doc needs some .js and .css files which are inside 127.0.0.1:4444/flasgger_static/ which should change to 127.0.0.1:4444/testapp/flasgger_static/.

Nikhil Redij
  • 1,011
  • 1
  • 14
  • 21

1 Answers1

3

You should add "url_prefix": "/testapp" in swagger_config.

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": "/swagger_doc/",
    "url_prefix": "/testapp"
}
JaoJaoLin
  • 31
  • 2