Skip to main content

Convert OpenAPI schema JSON files to Zod schema definitions or TypeScript interfaces

Project description

dtolator

Code generator that converts OpenAPI schemas, plain JSON, and JSON Schema files into typed code for multiple languages and frameworks.

Supported outputs

Flag Output
(default) Zod schemas (stdout)
--typescript / -t TypeScript interfaces
--zod / -z Zod schemas + TypeScript DTOs
--angular / -a Angular API services
--pydantic Python Pydantic models
--python-dict Python TypedDict definitions
--dotnet C# classes (System.Text.Json)
--json-schema JSON Schema
--endpoints / -e API endpoint types
--rust-serde Rust structs with Serde

Installation

Install with uv (recommended) — it fetches the prebuilt binary from PyPI and puts it on your PATH:

uv tool install dtolator

To upgrade later:

uv tool upgrade dtolator

Or download the latest executable from the GitHub Releases page and place it on your PATH.

Or install via Cargo:

cargo install --git https://github.com/vivainio/dtolator

Or build from source:

git clone https://github.com/vivainio/dtolator
cd dtolator
cargo build --release

Usage

# Zod schemas to stdout (default)
dtolator --from-openapi schema.json

# TypeScript interfaces to stdout
dtolator --from-openapi schema.json --typescript

# Write to directory (generates dto.ts + schema.ts)
dtolator --from-openapi schema.json --zod -o ./output

# Angular services with Zod validation and promises
dtolator --from-openapi schema.json -o ./src/app/api --angular --zod --promises

# From plain JSON (like quicktype)
dtolator --from-json data.json --typescript --root MyType

# From JSON Schema
dtolator --from-json-schema schema.json --pydantic

Input types

Exactly one required:

  • --from-openapi <FILE> — OpenAPI 3.x specification (richest: includes endpoints, params, validation)
  • --from-json <FILE> — Plain JSON data (schema inferred automatically)
  • --from-json-schema <FILE> — JSON Schema definition

Output options

  • -o, --output <DIR> — Write files to directory instead of stdout
  • --delete-old — After generation, delete files in the output directory that weren't just generated
  • --skip-file <NAME> — Skip writing a specific file (repeatable)
  • --hide-version — Omit version from generated file headers
  • --debug — Verbose debug output

Angular-specific options

  • --promises — Use lastValueFrom / Promise instead of Observable
  • --base-url-mode <MODE>global (default), argument, or none (relative URLs, route only)
  • --api-url-variable <NAME> — Global variable name for API URL (default: API_URL)
  • --ignore-operation-id — Derive method names from the operation summary, ignoring operationId

See ANGULAR.md for detailed Angular integration docs.

OpenAPI features supported

  • Basic types: string, number, integer, boolean, array, object
  • Enums, $ref references, nullable/optional properties
  • Composition: allOf, oneOf, anyOf
  • Validation: minLength, maxLength, minimum, maximum, pattern, format
  • Paths: path params, query params, header params, request bodies, response types
  • Map/dictionary types via additionalProperties

Incremental writes

Files are only written when content actually changes (with a fast-path file-size check), so bundler watchers won't trigger unnecessary rebuilds.

Testing

cargo test                           # Run all tests
python run-tests.py                  # Integration test suite
python run-tests.py --refresh        # Update expected outputs after intentional changes

See ADVANCED.md for endpoint generation details.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dtolator-0.25.0-py3-none-win_amd64.whl (807.1 kB view details)

Uploaded Python 3Windows x86-64

dtolator-0.25.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (968.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

dtolator-0.25.0-py3-none-macosx_11_0_arm64.whl (881.5 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

dtolator-0.25.0-py3-none-macosx_10_12_x86_64.whl (923.6 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file dtolator-0.25.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: dtolator-0.25.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 807.1 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dtolator-0.25.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1e6971cde14b29f845b582c55cd9d19abea84c5e6cf6be0aea2433faa1e6df97
MD5 d8efe5129cfa466cbf980c26e2530202
BLAKE2b-256 e6c824a5bf8de90d814051412164b6d1ad05cd440ff2e8ac5bf0e5d070843e1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.25.0-py3-none-win_amd64.whl:

Publisher: ci.yml on vivainio/dtolator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dtolator-0.25.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dtolator-0.25.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 12074e350c9ea057e8f64155d3412f726ff9f6b346ca984b8da58c99eb544990
MD5 59bc9089b660c8a7f3132276d91a6f8f
BLAKE2b-256 b14b6e8b9ee6d47596256b2e140fe04c6d937c0f76d90cb45135e226963d9513

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.25.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on vivainio/dtolator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dtolator-0.25.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dtolator-0.25.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b95b8787ebc9066f1a8675c757a444f6e36f37320fde04278ac2da3eb699465
MD5 161289d33f6e541d6e2942b5aa540404
BLAKE2b-256 94a173ed73fbb6dc37f53a7b98afbfc258de0046cf7625c70adc0ef4d478eeef

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.25.0-py3-none-macosx_11_0_arm64.whl:

Publisher: ci.yml on vivainio/dtolator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dtolator-0.25.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dtolator-0.25.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dfe7ddbe7909c3d6bff18a1662d1aa4085bf221af68937f1768ca011abef01ff
MD5 2b49a99a39cc36ee1c3fa30ba711ad32
BLAKE2b-256 105fe5a31c4b595aeb3575c9883398f88a5be8438559f0cf5c4724ab278281b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.25.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: ci.yml on vivainio/dtolator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page