writer.py 文件源码

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

项目:sphinx-swagger 作者: dave-shawley 项目源码 文件源码
def _render_response_information(body):
    """
    :param nodes.field_body body:
    :rtype: dict|NoneType
    """
    if len(body.children) > 1 or not isinstance(body[0], nodes.bullet_list):
        return None

    bullet_list = body[0]

    response_obj = {
        'description': '',
        'schema': {
            'type': 'object',
            'required': [],
            'properties': {},
        },
    }

    for list_item in bullet_list.children:
        assert isinstance(list_item, nodes.list_item)
        assert len(list_item.children) == 1

        para = list_item[0]
        assert isinstance(para, nodes.paragraph)

        obj_info = _parsed_typed_object(para)
        if obj_info:
            response_obj['schema']['required'].append(obj_info['name'])
            response_obj['schema']['properties'][obj_info['name']] = {
                'type': obj_info['type'],
                'description': obj_info['description'],
            }

    return response_obj
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号