Search code examples
flaskflask-restplus

Flask-Restplus is not generating API documentation


Here are the relevant parts of app.py

def init_api():
    blueprint = Blueprint("api", __name__, url_prefix="/api/v1")
    api.init_app(blueprint)
    api.add_namespace(circuit_namespace)
    app.register_blueprint(blueprint)


def init_api_auth():
    app.config["JWT_SECRET_KEY"] = "super-secret-key"
    app.config["JWT_ACCESS_TOKEN_EXPIRES"] = datetime.timedelta(days=1)
    jwt.init_app(app)
    app.register_blueprint(auth_blueprint)


init_api()
init_api_auth()

if __name__ == "__main__":
    app.run(debug=True)

I can access the API resources at /api/v1/ but when I go to 127.0.0.1:5000/ I cannot see any documentation. According to the official docs, the API doc is available at / but there is a "NOT FOUND" HTTP response in my case. What am I doing wrong?


Solution

  • The API doc would also be available at 127.0.0.1:5000/api/v1 because of the defined blueprint. The default path is <server url>/. Hope this helps.