Skip to main content

Automatically generate Pydantic models from dictionaries

Project description

PyAutoSchema

PyAutoSchema is a lightweight Python library that automatically generates Pydantic models from Python dictionaries. It's especially useful for fast prototyping, validating API responses, or converting JSON-like structures into Pydantic schemas.

🔧 Features

  • Supports nested dictionaries
  • Infers list and union types
  • Generates clean, human-readable Pydantic classes
  • Simple one-line usage

📦 Installation

pip install pyautoschema

🚀 Usage

from pyautoschema import infer_schema

sample = {
    "id": 123,
    "name": "Alice",
    "tags": ["admin", "user"],
    "profile": {
        "age": 30,
        "active": True
    }
}

infer_schema(sample, output="schemas.py")

Output (schemas.py):

from typing import List
from pydantic import BaseModel

class Profile(BaseModel):
    age: int
    active: bool

class InferredModel(BaseModel):
    id: int
    name: str
    tags: List[str]
    profile: Profile

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyautoschema-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyautoschema-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pyautoschema-0.1.0.tar.gz.

File metadata

  • Download URL: pyautoschema-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pyautoschema-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3df92dd188d785e5ec7399aa6886dc692090d315f76bb8f9174689fc79304d64
MD5 b135de68ec18c0b39c3cb175512b5ba7
BLAKE2b-256 2fe35f826c62ecce32766e16640422b060031a0e6f8fc86a092563b706c1db91

See more details on using hashes here.

File details

Details for the file pyautoschema-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyautoschema-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pyautoschema-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd251fda652d41c47612d9fefb4543e3c055e7b0ab93055bc71cdb9a363f452c
MD5 c525ddeae53ec2b0c327063a7f23683c
BLAKE2b-256 168bbea504d99423870415f1e9ac1d19af40e58a1f9450523f64b9c44d47a0a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page