def response(self, status_code, response):
"""
Describe a possible response for a Flask handler.
Args:
status_code: The status code for which the response is
described. `str`, `int` or `http.HTTPStatus` are
accepted. The result will be exposed as a string. See
:swagger:`responsesCode`.
response: A description of the response object. This may be
a dict describing a response or a string referring to a
response added using `add_response`. See
:swagger:`responseObject`.
"""
if isinstance(response, str):
response = ref('responses', response)
if isinstance(status_code, HTTPStatus):
status_code = int(status_code)
def attach_response(fn):
if not hasattr(fn, 'responses'):
fn.responses = {}
fn.responses[str(status_code)] = response
return fn
return attach_response
评论列表
文章目录