Skip to main content

json-schema-to-class Build Status codecov PyPI version

Convert JSON Schema into Python Class

Installation

Need Python 3.6+.

pip install json-schema-to-class

Usage

For example, convert tests/test_schema.json into Python class:

# generate & highlight
json-schema-to-class tests/test_schema.json --indent 2 | pygmentize

# or generate to file
json-schema-to-class tests/test_schema.json -o tests/schema_build.py

# generate code with __repr__ method
json-schema-to-class tests/test_schema.json --indent 2 --repr | pygmentize

Get tests/schema_build.py as follow:

from typing import List


class WarmUp:
    def __init__(self, values: dict = None):
        values = values if values is not None else {}
        self.start: float = values.get("start", 0.0)
        self.steps: int = values.get("steps", 0)


class LrSchedulerConfig:
    def __init__(self, values: dict = None):
        values = values if values is not None else {}
        self.lr_mode: str = values.get("lr_mode", 'cos')
        self.base_lr: float = values.get("base_lr", None)
        self.target_lr: float = values.get("target_lr", 0.0002)
        self.decay_factor: float = values.get("decay_factor", 0.1)
        self.milestones: List[float] = values.get("milestones", [0.3, 0.6, 0.9])
        self.lr_decay: float = values.get("lr_decay", 0.98)
        self.warm_up = WarmUp(values=values.get("warm_up"))


class LrSchedulerConfigs(list):
    def __init__(self, values: list = None):
        super().__init__()
        values = values if values is not None else []
        self[:] = [LrSchedulerConfig(value) for value in values]

Metadata

Release files for json-schema-to-class 0.2.4

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

Source distribution (sdist)

Source distribution for json-schema-to-class 0.2.4
File Size Uploaded Provenance
json-schema-to-class-0.2.4.tar.gz 5.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for json-schema-to-class 0.2.4
File Interpreter ABI Platform
json_schema_to_class-0.2.4-py3.6.egg Legacy Egg format - - Details

Total release size: 17.2 kB

Release files / json-schema-to-class-0.2.4.tar.gz

Download URL json-schema-to-class-0.2.4.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
630d80d2594c9610e5ff6c863fc3c1d0a25b2629f03123e9b1c8bf52d15791d0
BLAKE2b-256 checksum
How to use checksums
6327f53457c74e75d052bc15ed0fe5e89bcd2ddd36d01a2cdaa7f40ef1157f49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.7

Release files / json_schema_to_class-0.2.4-py3.6.egg

Download URL json_schema_to_class-0.2.4-py3.6.egg
Size 11.5 kB
Tags Egg
SHA-256 checksum
How to use checksums
0c68fff09cd7f505667f51c544964646e3ce35278012e6d0f7724495b4b86c88
BLAKE2b-256 checksum
How to use checksums
50e53e406d1fa20e05c753e4df2f47e9a1f8cd075747328cf46838d56f339f05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.7

Security for json-schema-to-class 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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