Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Cannot get API specs with Flask Blueprints and Swagger UI

So, following the examples for swagger ui usage with flask blueprints (https://github.com/rantav/flask-restful-swagger/blob/master/examples/blueprints.py), I have the following code:

app = Flask(__name__)
test_blueprint = Blueprint('tests', __name__)
test_api = swagger.docs(restful.Api(test_blueprint), apiVersion='0.1',
                        produces=["application/json", "text/html"],

# Operation TestOp defined here
test_api.add_resource(TestOp, '/')

if __name__ == "__main__":
    app.register_blueprint(test_blueprint, url_prefix='/test')

However, when I try to access the api spec docs, the URL cannot be located. I've tried...


...all of which return a 404. I've also tried creating the app without blueprints, creating the docs with


instead. When there this is done and no blueprints are involved, I can reach the docs at


So, am I creating my application incorrectly with blueprints, or am I just not hitting the right URL to get access to the docs?

like image 966
user1499956 Avatar asked Mar 19 '23 16:03


1 Answers

I know this thread is old, but I ran into this exact problem today, trying to use flask-restful-swagger with my (somewhat) modern flask + python3 app that uses blueprints. Same problem, no errors, just no spec available no matter what i tried.

I finally abandoned this package (as it seems like it hasn't been very active anyway), even though I like the markup better with this package.

I chose Flasgger, which seemed to be updated more recently. In 10 minutes I had it up and running. Code and short tutorial are here: https://github.com/rochacbruno/flasgger

like image 134
Andrew Schwäbe Avatar answered Apr 06 '23 08:04

Andrew Schwäbe