First attempt at using flask-restful and swagger api documentation.
This commit is contained in:
parent
52d2229482
commit
de1a44f853
5 changed files with 283 additions and 4 deletions
40
endpoints/api/__init__.py
Normal file
40
endpoints/api/__init__.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from flask import Blueprint
|
||||
from calendar import timegm
|
||||
from email.utils import formatdate
|
||||
from functools import partial
|
||||
|
||||
|
||||
api = Blueprint('api', __name__)
|
||||
|
||||
|
||||
def truthy_bool(param):
|
||||
return param not in {False, 'false', 'False', '0', 'FALSE', '', 'null'}
|
||||
|
||||
|
||||
def format_date(date):
|
||||
""" Output an RFC822 date format. """
|
||||
return formatdate(timegm(date.utctimetuple()))
|
||||
|
||||
|
||||
def add_method_metadata(name, value):
|
||||
def modifier(func):
|
||||
if '__api_metadata' not in dir(func):
|
||||
func.__metadata = {}
|
||||
func.__metadata[name] = value
|
||||
return func
|
||||
return modifier
|
||||
|
||||
|
||||
def method_metadata(func, name):
|
||||
if '__api_metadata' in dir(func):
|
||||
return func.__metadata.get(name, None)
|
||||
return None
|
||||
|
||||
|
||||
nickname = partial(add_method_metadata, 'nickname')
|
||||
|
||||
|
||||
import endpoints.api.legacy
|
||||
|
||||
import endpoints.api.repository
|
||||
import endpoints.api.discovery
|
Reference in a new issue