2025-04-05 17:07:29 -03:00
2025-06-12 00:53:28 -03:00
2025-06-21 18:26:14 -03:00
2025-06-19 23:51:33 -03:00
2025-06-21 11:46:47 -03:00
2025-03-21 22:50:52 -03:00
2025-04-10 00:57:50 -03:00
2025-06-20 22:54:24 -03:00
2025-06-20 22:54:24 -03:00

Jambo - JSON Schema to Pydantic Converter

Tests Coverage
Package version Python versions License

Jambo is a Python package that automatically converts JSON Schema definitions into Pydantic models. It's designed to streamline schema validation and enforce type safety using Pydantic's powerful validation features.

Created to simplifying the process of dynamically generating Pydantic models for AI frameworks like LangChain, CrewAI, and others.


Features

  • Convert JSON Schema into Pydantic models dynamically;
  • 🔒 Supports validation for strings, integers, floats, booleans, arrays, nested objects, allOf, anyOf and ref;
  • ⚙️ Enforces constraints like minLength, maxLength, pattern, minimum, maximum, uniqueItems, and more;
  • 📦 Zero config — just pass your schema and get a model.

📦 Installation

pip install jambo

🚀 Usage

from jambo import SchemaConverter


schema = {
    "title": "Person",
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer"},
    },
    "required": ["name"],
}

Person = SchemaConverter.build(schema)

obj = Person(name="Alice", age=30)
print(obj)

Example Validations

Strings with constraints

from jambo import SchemaConverter


schema = {
    "title": "EmailExample",
    "type": "object",
    "properties": {
        "email": {
            "type": "string",
            "minLength": 5,
            "maxLength": 50,
            "pattern": r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$",
        },
    },
    "required": ["email"],
}

Model = SchemaConverter.build(schema)
obj = Model(email="user@example.com")
print(obj)

Integers with bounds

from jambo import SchemaConverter


schema = {
    "title": "AgeExample",
    "type": "object",
    "properties": {
        "age": {"type": "integer", "minimum": 0, "maximum": 120}
    },
    "required": ["age"],
}

Model = SchemaConverter.build(schema)
obj = Model(age=25)
print(obj)

Nested Objects

from jambo import SchemaConverter


schema = {
    "title": "NestedObjectExample",
    "type": "object",
    "properties": {
        "address": {
            "type": "object",
            "properties": {
                "street": {"type": "string"},
                "city": {"type": "string"},
            },
            "required": ["street", "city"],
        }
    },
    "required": ["address"],
}

Model = SchemaConverter.build(schema)
obj = Model(address={"street": "Main St", "city": "Gotham"})
print(obj)

References

from jambo import SchemaConverter


schema = {
    "title": "person",
    "$ref": "#/$defs/person",
    "$defs": {
        "person": {
            "type": "object",
            "properties": {
                "name": {"type": "string"},
                "age": {"type": "integer"},
                "emergency_contact": {
                    "$ref": "#/$defs/person",
                },
            },
        }
    },
}

model = SchemaConverter.build(schema)

obj = model(
    name="John",
    age=30,
    emergency_contact=model(
        name="Jane",
        age=28,
    ),
)

🧪 Running Tests

To run the test suite:

poe tests

Or manually:

python -m unittest discover -s tests -v

🛠 Development Setup

To set up the project locally:

  1. Clone the repository
  2. Install uv (if not already installed)
  3. Install dependencies:
uv sync
  1. Set up git hooks:
poe create-hooks

📌 Roadmap / TODO

  • Support for enum and const
  • Better error reporting for unsupported schema types

🤝 Contributing

PRs are welcome! This project uses MIT for licensing, so feel free to fork and modify as you see fit.


🧾 License

MIT License.

Description
Jambo - JSON Schema to Pydantic Converter
Readme MIT 780 KiB
v0.1.7 Latest
2026-01-14 19:14:35 +00:00
Languages
Python 99.9%