[英]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.