def openAPIDoc(**kwargs):
"""
Update a function's docstring to include the OpenAPI Yaml generated by running the openAPIGraph object
"""
s = yaml.dump(kwargs, default_flow_style=False)
def deco(routeHandler):
# Wrap routeHandler, retaining name and __doc__, then edit __doc__.
# The only reason we need to do this is so we can be certain
# that __doc__ will be modifiable. partial() objects have
# a modifiable __doc__, but native function objects do not.
ret = functools.wraps(routeHandler)(routeHandler)
if not ret.__doc__:
ret.__doc__ = ''
ret.__doc__ = cleandoc(ret.__doc__) + '\n---\n' + s
return ret
return deco
评论列表
文章目录