def extract(cls, extractor, typ):
"""
take an attrs based class, and convert it
to jsonschema.
"""
schema = {
"title": typ.__name__,
"type": "object",
"properties": {},
"required": []
}
for attribute in attr.fields(typ):
details = cls._extract_attribute(extractor, attribute)
if details.is_required:
schema["required"].append(details.name)
schema["properties"][details.name] = details.schema
return schema
attrs_extractor.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录