The Seven Year Itch.

MENU

Flasgger的配置应该如何写

January 7, 2019 • Read: 84 • 闲记

first:
一丶 配置文件中 setting.py

  SWAGGER = {
  "swagger_version": "2.0",
  "title": "Le2To平台项目",
  "specs_route": "/api/docs",
  "specs": [
      {
          "version": "0.1",
          "title": "主页API接口列表",
          "description": 'This is the version 0.1 of Le2To API',
          "endpoint": 'apispec_1',
          "route": '/apispec_1.json',
      }
  ],
}

二丶 这个配置在网上的很多文章中都没有详细记录,特别是SWAGGER这里的参数很多文章也没有记录.详细阅读了下flasgger下的源代码发现的

from flasgger import Swagger
追踪进入到 Swagger类中 找到 load_config方法就明白了.

def load_config(self, app):
  """
  Copy config from app
  """
  self.config.update(app.config.get('SWAGGER', {}))
Tags: None
Archives QR Code
QR Code for this page
Tipping QR Code