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 | |
|---|---|---|---|
| pydantic_converter-0.1.4.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_converter-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
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
|