swagger.py 文件源码

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

项目:aiohttp-transmute 作者: toumorokoshi 项目源码 文件源码
def create_swagger_json_handler(app, **kwargs):
    """
    Create a handler that returns the swagger definition
    for an application.

    This method assumes the application is using the
    TransmuteUrlDispatcher as the router.
    """

    spec = get_swagger_spec(app).swagger_definition(**kwargs)
    encoded_spec = json.dumps(spec).encode("UTF-8")

    async def swagger(request):
        return web.Response(
            # we allow CORS, so this can be requested at swagger.io
            headers={
                "Access-Control-Allow-Origin": "*"
            },
            body=encoded_spec,
            content_type="application/json",
        )

    return swagger
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号