Skip to main content

jsonschema-extractor is a library and extensible framework for extracting json schema from various object and primitives.

https://github.com/toumorokoshi/jsonschema-extractor/actions/workflows/python-package.yaml/badge.svg

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"],
}

Release files for jsonschema-extractor 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonschema-extractor 2.0.2
File Size Uploaded
jsonschema-extractor-2.0.2.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonschema-extractor 2.0.2
File Interpreter ABI Platform
jsonschema_extractor-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size:24.6 kB

Release files / jsonschema-extractor-2.0.2.tar.gz

Download URL jsonschema-extractor-2.0.2.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5eac4ef619eb8b7679571f31ff15d1fab52e1b9ff92d19b3241b0e3ebc357226
BLAKE2b-256 checksum
How to use checksums
d8978c7ec239d1ab786af80b2fb121b9806dbad0d0d58ee1e343b6d75924d11a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / jsonschema_extractor-2.0.2-py3-none-any.whl

Download URL jsonschema_extractor-2.0.2-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d87d7d78fd9a28cc4e8862dcc0ea371f511dd130e583861bff8e8cbb71ce82ec
BLAKE2b-256 checksum
How to use checksums
5520351a119c9133fad9034185cab15aecdb6222c806c9b44dbf96536b3b3652
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0

2 release files

1.0

2 release files

0.9

2 release files

0.8.2

2 release files

0.8.1

1 release file

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page