extension.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:flask-openapi 作者: remcohaszing 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号