question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use flasgger with many blueprints?

See original GitHub issue

I’m new to python and I feel sorry for this is a stupid question.

I have many blueprints in my project.

file directories in my project:

app/view/ # here are many flask restful apis

for eg:

books.py

from flask_restful import Api,Resource
from flask import Flask,Blueprint


book_blueprint = Blueprint("book", __name__)
api = Api(book_blueprint)
books = [
    "mysql","java","js"
]
class Book(Resource):
    def get(self,book_id):
        try:
            return books[book_id]
        except IndexError,e:
            print e.message
            return '#book not exist!#'


api.add_resource(Book,'/books/<int:book_id>')

tree.py

# coding:utf-8
from flask import Blueprint
tree_mold_blueprint = Blueprint("tree_api", __name__)


@tree_mold_blueprint.route("/leaves")
def leaves():
    return "This tree has leaves"

and I have a ‘manager.py’ to run this project ,which exists at : app/

manager.py

from flask import Flask

from app.view.tree import tree_mold_blueprint
from app.view.tom import tom_blueprint
from app.view.user_info import user_blueprint
from app.view.books import book_blueprint
from flasgger import Swagger
app = Flask(__name__)
app.register_blueprint(tree_mold_blueprint, url_prefix='/api')
app.register_blueprint(tom_blueprint, url_prefix='/api')
app.register_blueprint(user_blueprint, url_prefix='/api')
app.register_blueprint(book_blueprint, url_prefix='/api')

swg = Swagger(app)    # I try to use flasgger here

if __name__ == '__main__':
    app.run(host='0.0.0.0' ,port = 27016 , debug= 'true' )

There is no API at localhost:27016/apidocs ,but flasgger page. So how can I use flasgger to show all my APIs? Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
blue995commented, Jun 21, 2018

One of my private python 3 projects relies on multiple blueprints. It would be a problem if flasgger does not support this feature, so i’m really happy about that. I don’t tested it with Python 2 though.

2reactions
prasadborkar1109commented, Jun 21, 2018

Thanks @blue995 , its working for me now. Actually I was getting some error due to incorrect yml path

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Flasgger with Flask applications ...
I am using flask Blueprints. Like following: from flask import Flask, Blueprint from flask_restful import Api, Resource from flasgger.
Read more >
how to use flasgger with flask applications using blueprints?
from flask import Blueprint, Flask, jsonify from flasgger import Swagger from flasgger.utils import swag_from app = Flask(__name__) example_blueprint ...
Read more >
How to use the flasgger.Swagger function in ...
To help you get started, we've selected a few flasgger. ... 500 # Import a module / component using its blueprint handler variable...
Read more >
flasgger
Flasgger is compatible with Flask-RESTful so you can use Resources and swag ... Nested(Color, many=True) class PaletteView(SwaggerView): parameters ...
Read more >
A Cloud Pak Show Case – The Reefer Simulator as web app
Flask, with blueprint, flasgger.Swagger, prometheus metrics; Kafka producer code using Confuent-python library; Integration with Health for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found