"一个从各种模型中提取jsonschema的框架."
项目描述
jsonschema-extractor是一个库和可扩展的框架,用于从各种对象和原语中提取json模式。
默认支持以下内容
用法
from typing import List
import jsonschema_extractor
assert jsonschema_extractor.extract(List[int]) == {
"type": "array",
"items": {"type": "integer"}
}
Attrs-example
import attr
from attr.validators import instance_of
import jsonschema_extractor
@attr.define
class Example(object):
integer: int = attr.field()
foo = attr.field(metadata={"jsonschema": {"type": "string", "format": "uuid"}})
validator_list: List[float] = attr.field()
string: str = attr.field(
default="foo",
metadata={"description": "This is an description."}
)
assert extractor.extract(Example) == {
"type": "object",
"title": "Example",
"properties": {
"string": {"description": "This is an description.", "type": "string"},
"integer": {"type": "integer"},
"validator_list": {"items": {"type": "number"}, "type": "array"},
"foo": {"type": "string", "format": "uuid"},
},
"required": ["integer", "foo", "validator_list"],
}
项目详情
下载文件
下载适合您平台的应用程序。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
jsonschema-extractor-2.0.2.tar.gz (12.3 kB 查看哈希值)