from flask import Flask from flasgger import Swagger import config app = Flask(__name__) app.config.from_object(config) swagger_config = Swagger.DEFAULT_CONFIG swagger_config['title'] = config.SWAGGER_TITLE # 配置大標題 swagger_config['description'] = config.SWAGGER_DESC # 配置公共描述內容 swagger_config['host'] = config.SWAGGER_HOST # 請求域名 # swagger_config['swagger_ui_bundle_js'] = '//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js' # swagger_config['swagger_ui_standalone_preset_js'] = '//unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js' # swagger_config['jquery_js'] = '//unpkg.com/jquery@2.2.4/dist/jquery.min.js' # swagger_config['swagger_ui_css'] = '//unpkg.com/swagger-ui-dist@3/swagger-ui.css' Swagger(app, config=swagger_config)
@blueprint.route('/register/', methods=['POST']) def register(): """ 用戶註冊 --- tags: - 用戶相關接口 description: 用戶註冊接口,json格式 parameters: - name: body in: body required: true schema: id: 用戶註冊 required: - username - password - inn_name properties: username: type: string description: 用戶名. password: type: string description: 密碼. inn_name: type: string description: 客棧名稱. phone: type: string description: 手機號. wx: type: string description: 微信. responses: 201: description: 註冊成功 example: {'code':1,'message':註冊成功} 406: description: 註冊有誤,參數有誤等 """ pass
flasgger配置文件解析:css
只是簡單記錄,其餘能夠看下面一些連接html
使用swagger 生成 Flask RESTful API
swagger文檔在線編輯樣例
swagger和openAPI: 描述參數
flasggerpython