You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-7Lines changed: 66 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,75 @@ This tool requires that you have the lovely json2ts CLI utility installed. Instr
8
8
```bash
9
9
$ pip install pydantic-to-typescript
10
10
```
11
+
---
12
+
### CLI
11
13
12
-
### Command-line usage
14
+
|Prop|Description|
15
+
|:----------|:-----------|
16
+
|`--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'|
17
+
|`--output`|name of the file the typescript definitions should be written to. Ex: './frontend/apiTypes.ts'|
18
+
|<nobr>`--json2ts-cmd`</nobr>|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)|
19
+
---
20
+
### Usage
21
+
pydantic2ts/examples/pydantic_models.py:
22
+
```python
23
+
from pydantic import BaseModel, Extra
24
+
from enum import Enum
25
+
from typing import List, Dict
13
26
14
-
|Prop |Description|
15
-
|:--------|:-----------|
16
-
|`--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'|
17
-
|`--output`|name of the file the typescript definitions should be written to. Ex: '/frontend/api-types.ts'|
18
-
|`--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)|
0 commit comments