[英]Is there a way to introduce Swagger automated documentation into a solution that uses Flask Bluperints?
我想将 Swagger 文档介绍给我使用 Flask 和蓝图构建的项目,但我找不到这样做的方法。
例如
from flask import Flask, Blueprint
class HealthController():
def __init__(self):
self.blueprint = self.define_routes()
def define_routes(self):
blueprint = Blueprint('health', __name__)
@blueprint.route('/api/health', methods=['GET'])
def health():
return flask.jsonify({"result": True}), 200
return blueprint
application = Flask(__name__)
application.register_blueprint(HealthController().blueprint)
application.run()
如何在坚持使用 Flask 和蓝图的同时引入flasgger
或任何其他生成 Swagger UI 的框架?
我已经尝试使用flask-openapi3、flassger 并四处搜索,但到目前为止,我找不到解决方案:(
显然apiflask与蓝图完美配合。 您所要做的就是按照手册将 Flask 中的Blueprint
类替换为APIBlueprint
中的 APIBlueprint。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.