Skip to main content

pydantic-to-typescript

A simple CLI tool for converting pydantic models into typescript interfaces. Useful for any scenario in which python and javascript applications are interacting, since it allows you to have a single source of truth for type definitions.

This tool requires that you have the lovely json2ts CLI utility installed. Instructions can be found here: https://www.npmjs.com/package/json-schema-to-typescript

Installation

$ pip install pydantic-to-typescript

Command-line usage

Prop Description
--module name of the python module you would like to convert. All the pydantic models within it will be converted to typescript interfaces. Discoverable submodules will also be checked. Ex: 'pydantic2ts.examples.pydantic_models'
--output name of the file the typescript definitions should be written to. Ex: '/frontend/api-types.ts'
--json2ts-cmd optional, the command used to invoke json2ts. The default is 'json2ts'. Specify this if you have it installed in a strange location and need to provide the exact path (ex: /myproject/node_modules/bin/json2ts)

Example:

$ pydantic2ts --module pydantic2ts.examples.pydantic_models --output output.ts

Metadata

Release files for pydantic-to-typescript 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-to-typescript 1.0.2
File Size Uploaded Provenance Actions
pydantic-to-typescript-1.0.2.tar.gz 3.7 kB Without provenance Details for pydantic-to-typescript-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-to-typescript 1.0.2
File Interpreter ABI Platform Actions
pydantic_to_typescript-1.0.2-py3-none-any.whl Python 3 none any Details for pydantic_to_typescript-1.0.2-py3-none-any.whl

Total release size: 9.5 kB

Release files / pydantic-to-typescript-1.0.2.tar.gz

Download URL pydantic-to-typescript-1.0.2.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a0c78fe34dce1c3e5a21acb36a6619634d576c631845c7e6efdf82e4101595f2
BLAKE2b-256 checksum
How to use checksums
eb201e5eecea76f8a337c7a4766453e34d2fa1f5fae94d9d92949c047ddc790c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / pydantic_to_typescript-1.0.2-py3-none-any.whl

Download URL pydantic_to_typescript-1.0.2-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97cc44f1d827110a0f4ed58636ede2c213433ae20a25a20530ccb826d93d76d2
BLAKE2b-256 checksum
How to use checksums
2b7225621882b84b874492e6d194b2cc63f55ea9fccfdf6e1c386711c76c9e35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Security for pydantic-to-typescript 1.0.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page