"a framework to extract jsonschemas from a variety of models."
Project description
jsonschema-extractor is a library and extensible framework for extracting json schema from various object and primitives.
Out of the box support exists for:
Usage
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"],
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonschema-extractor-2.0.tar.gz
(12.1 kB
view hashes)
Built Distribution
Close
Hashes for jsonschema_extractor-2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 776a62e3a00ddf9a3901e3808dc5c916b42d8973ae132b0b396f7ac24461f13f |
|
MD5 | 7934975c1c50bb8947292cfa5ea9f0c5 |
|
BLAKE2b-256 | 77400e0e801326a2fae277c65f946a668ebbbc9e654cf6ec2807b47a21ad477b |