TypeScript Schema Generator¶
Here's the reference information for the included TypeScript schema generator classes with all their parameters, attributes and methods.
You can import these classes directly from pyrmute:
pyrmute.TypeScriptExporter
¶
Export Pydantic models to TypeScript schema files.
Initialize the TypeScript exporter.
| PARAMETER | DESCRIPTION |
|---|---|
registry
|
Model registry instance.
TYPE:
|
style
|
Output style - 'interface', 'type', or 'zod'.
TYPE:
|
config
|
Optional configuration for schema generation.
TYPE:
|
Source code in src/pyrmute/typescript_schema.py
export_schema
¶
Export a single model version as a TypeScript schema.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Model name.
TYPE:
|
version
|
Model version.
TYPE:
|
output_path
|
Optional file path to save schema.
TYPE:
|
organization
|
Directory structure for output files: - 'flat': All files in output directory (Model.v1.0.0.ts) - 'major_version': Organize by major version (v1/Model.v1.0.0.ts) - 'model': Organize by model name (Model/1.0.0.ts)
TYPE:
|
include_barrel_exports
|
Whether to generate index.ts files for easier imports.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
TypeScript schema code. |
Source code in src/pyrmute/typescript_schema.py
export_all_schemas
¶
Export all registered models as TypeScript schemas.
| PARAMETER | DESCRIPTION |
|---|---|
output_dir
|
Directory to save schema files.
TYPE:
|
organization
|
Directory structure for output files: - 'flat': All files in output directory (Model.v1.0.0.ts) - 'major_version': Organize by major version (v1/Model.v1.0.0.ts) - 'model': Organize by model name (Model/1.0.0.ts)
TYPE:
|
include_barrel_exports
|
Whether to generate index.ts files for easier imports.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, dict[str, str]]
|
Dictionary mapping model names to version to schema code. |
Source code in src/pyrmute/typescript_schema.py
pyrmute.TypeScriptConfig
¶
Bases: TypedDict
Configuration options for TypeScript schema generation.