"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.1.tar.gz
(12.3 kB
view hashes)
Built Distribution
Close
Hashes for jsonschema-extractor-2.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 300193712331bca0b244b274ab0bd502dbdc3cd3353abfc4d7b5c9b75d115fdf |
|
MD5 | 1079834d11b9af660bbc95dccc65f5f8 |
|
BLAKE2b-256 | b475f7fb7020c190b05cb4acacbd0f1f6166278afada6712f36a4587a566b213 |
Close
Hashes for jsonschema_extractor-2.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aa7e473dd6fbdce7bbe939e48dcbe91d7ea16a62b8e0b96032276aa9a84573c |
|
MD5 | f2ca562b5ee53ca8898464b62424dc46 |
|
BLAKE2b-256 | b284965a3394584f79d8c172c1b2e04099c7334dd6ca553550e8ef647a41eaa3 |