How to use flasgger with many blueprints?
See original GitHub issueI’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:
- Created 5 years ago
- Reactions:1
- Comments:9 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Thanks @blue995 , its working for me now. Actually I was getting some error due to incorrect yml path