Metadata-Version: 2.4
Name: valbridge-pydantic-extractor
Version: 1.2.0
Summary: Pydantic extraction utilities for valbridge's Zod conversion pipeline
Project-URL: Homepage, https://github.com/vectorfy-co/valbridge
Project-URL: Documentation, https://github.com/vectorfy-co/valbridge
Project-URL: Repository, https://github.com/vectorfy-co/valbridge
Project-URL: Issues, https://github.com/vectorfy-co/valbridge/issues
Project-URL: Changelog, https://github.com/vectorfy-co/valbridge/blob/main/CHANGELOG.md
Author: vectorfyco
Maintainer: vectorfyco
License: MIT
Keywords: code-generation,extractor,introspection,pydantic,valbridge,validation,zod
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: pydantic<2.13.0,>=2.12.0
Requires-Dist: valbridge-core<2.0.0,>=1.1.0
Description-Content-Type: text/markdown

<div align="center">

# ![valbridge-pydantic-extractor](https://img.shields.io/static/v1?label=&message=valbridge-pydantic-extractor&color=E92063&style=for-the-badge&logo=pydantic&logoColor=white)

Extract valbridge-compatible schema data from existing Pydantic models for high-fidelity Zod generation.

<a href="https://pypi.org/project/valbridge-pydantic-extractor/"><img src="https://img.shields.io/pypi/v/valbridge-pydantic-extractor?style=flat&logo=pypi&logoColor=white" alt="PyPI" /></a>
<a href="https://github.com/vectorfy-co/valbridge/blob/main/LICENSE"><img src="https://img.shields.io/github/license/vectorfy-co/valbridge?style=flat" alt="License" /></a>

</div>

---

## Installation

```bash
pip install valbridge-pydantic-extractor
# or
uv add valbridge-pydantic-extractor
```

## CLI usage

```bash
valbridge-pydantic-extractor app.models:User --python-path .
```

Output is JSON with:
- `schema` -- the extracted JSON Schema document
- `diagnostics` -- import or extraction diagnostics when the target cannot be resolved cleanly

## Options

| Flag | Description |
| --- | --- |
| `--python-path <path>` | Prepend an import path before loading the target module |
| `--module-root <path>` | Add module roots for project-local imports |
| `--stub-module <module>` | Install placeholder modules for optional imports |
| `--env KEY=VALUE` | Inject environment variables before importing the model |

## Key behaviors

- Target must use `module:Class` format
- Target class must inherit from `pydantic.BaseModel`
- Extracted output preserves `x-valbridge` annotations needed by downstream code generation
- Emits diagnostics for Pydantic features that cannot be represented in JSON Schema

## Related packages

| Package | Purpose |
| --- | --- |
| [`valbridge-pydantic`](https://pypi.org/project/valbridge-pydantic/) | Pydantic adapter (JSON Schema to Pydantic) |
| [`valbridge-core`](https://pypi.org/project/valbridge-core/) | Core IR and JSON Schema parser |
| [`@vectorfyco/valbridge-zod-extractor`](https://www.npmjs.com/package/@vectorfyco/valbridge-zod-extractor) | TypeScript equivalent for Zod schemas |

## Learn more

- [GitHub repository](https://github.com/vectorfy-co/valbridge)
- [Full documentation](https://github.com/vectorfy-co/valbridge#readme)
