Convert pydantic models to typescript interfaces
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pydantic-to-typescript-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0c78fe34dce1c3e5a21acb36a6619634d576c631845c7e6efdf82e4101595f2 |
|
MD5 | cf0aa8f66fb361c4390a48680869eb3b |
|
BLAKE2b-256 | eb201e5eecea76f8a337c7a4766453e34d2fa1f5fae94d9d92949c047ddc790c |
Close
Hashes for pydantic_to_typescript-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97cc44f1d827110a0f4ed58636ede2c213433ae20a25a20530ccb826d93d76d2 |
|
MD5 | 983d72ff6fc648e78720ce34e4f97ce2 |
|
BLAKE2b-256 | 2b7225621882b84b874492e6d194b2cc63f55ea9fccfdf6e1c386711c76c9e35 |