pydantic-converter
Convert pydantic models to other formats like typescript interfaces.
Installation
pip install pydantic-converter
Usage
You need to install json-schema-to-typescript to use this tool.
# sample.py
from pydantic_converter import schema
from pydantic import BaseModel
@schema
class User(BaseModel):
name: str
age: int
$ pydantic-converter --help
NAME
pydantic-converter
SYNOPSIS
pydantic-converter PATH OUTPUT_FILE <flags>
POSITIONAL ARGUMENTS
PATH
Type: str | pathlib.Path
OUTPUT_FILE
Type: str | pathlib.Path
FLAGS
-r, --recursive=RECURSIVE # Search .py files recursively from the given path.
Type: bool
Default: False
-c, --camelize=CAMELIZE # Convert field names to camelCase.
Type: bool
Default: False
-e, --export_to=EXPORT_TO
Type: Literal
Default: 'ts'
$ pydantic-converter ./ ./output.ts
# output.ts
export Name = string;
export Age = number;
export interface User {
name: Name;
age: Age;
}
TODO
- Support other language formats
Metadata
Release files for pydantic-converter 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydantic_converter-0.1.4.tar.gz | 5.3 kB | Without provenance | Details for pydantic_converter-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_converter-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for pydantic_converter-0.1.4-py3-none-any.whl |
Total release size: 10.4 kB
Release files / pydantic_converter-0.1.4.tar.gz
| Download URL | pydantic_converter-0.1.4.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fffb40478b81efd297b96f55372d432f931a8d7af21b44fcc6ca260a017f2a04
|
|
BLAKE2b-256 checksum How to use checksums |
530b756dcfd9d7140fdb647da63b6ee122b33402dfa53e4e03690abe15557d01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / pydantic_converter-0.1.4-py3-none-any.whl
| Download URL | pydantic_converter-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eefbc2cb92e47b26064888faac6052b6ebc1884a98ee22ae5e1794a370948957
|
|
BLAKE2b-256 checksum How to use checksums |
6a8ba61f3954a79f69d4a90d462ed4d46cb90f3ef4840d01f4dc1cecd3738a6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for pydantic-converter 0.1.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.