jmcarp / flask-apispec

MIT License
655 stars 157 forks source link

docs can't register view function #224

Open ischaojie opened 3 years ago

ischaojie commented 3 years ago

I use flask factory mode, register docs in create_app, by got TypeError.

def create_app():
    app = Flask(__name__)
    # config
    app.config.from_object(config)

    # register urls
    app.register_blueprint(drogo_openid)
    app.register_blueprint(api)  # api
    app.register_blueprint(admin)
    app.register_blueprint(error)  # error

    register_extensions(app)

    register_docs(app)

    return app

def register_blueprint(app):
    pass

def register_extensions(app):
    docs.init_app(app)

def register_docs(app):
    for (fpath, view_function) in app.view_functions.items():
        blueprint_name = fpath.split('.')[0]
        if ismethod(view_function):
            docs.register(view_function, blueprint=blueprint_name)

In addition, use docs.register(...) in create_app got the same error, Please help

educanovas93 commented 2 years ago

Any solution ? I have the same issue :(