how to load swagger UI, in before_request looking for token but token used in particular endpoint

Solution
@app.before_request
def before_request():

    if request.path == '/apidocs' or request.path == '/apispec.json':
        return shutdown_session() 
    try:
       # some code here
    except:
       # something here
swagger_config = {
    "headers": [
    ],
    "specs": [
        {
            "endpoint": 'apispec',
            "route": '/apispec.json',
            "rule_filter": lambda rule: True,  # all in
            "model_filter": lambda tag: True,  # all in
        }
    ],

    "static_url_path": "/flasgger_static",
    "swagger_ui": True,
    "specs_route": "/apidocs",
    'swagger_ui_bundle_js':  '//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js',
    'swagger_ui_standalone_preset_js': '//unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js',
    'jquery_js': '//unpkg.com/jquery@2.2.4/dist/jquery.min.js',
    'swagger_ui_css': '//unpkg.com/swagger-ui-dist@3/swagger-ui.css'
}