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) or argument
  • --api-url-variable <NAME> — Global variable name for API URL (default: API_URL)

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.24.1-py3-none-win_amd64.whl (805.8 kB view details)

Uploaded Python 3Windows x86-64

dtolator-0.24.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (968.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

dtolator-0.24.1-py3-none-macosx_11_0_arm64.whl (880.5 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

dtolator-0.24.1-py3-none-macosx_10_12_x86_64.whl (923.5 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: dtolator-0.24.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 805.8 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.24.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1c23dc3414b560b650a1f5b347162f0b25f50ac0b3ec655251a6976dc1bc7f35
MD5 cf1f83f2f11255857b3843d737875a8e
BLAKE2b-256 bbebaa1704e2edee2e094ece8bc98fa64570a438aac19730016fb5c5fb820b5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.24.1-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.24.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dtolator-0.24.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7f7893ba6d7e71799542e30206a221dd65aee2d37dcc7d0b70d90e1a0689e0e
MD5 67a8748981b15628d7d9222d6130a14f
BLAKE2b-256 d205b41ba482c79fc1758f0626fc2d65621bea5b7799da58855537531a38a91f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.24.1-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.24.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dtolator-0.24.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fb00dad85a6b4c1eaac31cbfbaa4bc16cf5185ac716169aeb4edb02840f9e788
MD5 6cf9de5dbc41f4a6380c681d461e2949
BLAKE2b-256 53651747de0a5d7c17f978facd0623f45539a37a25f299a413d41e0e996da8ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.24.1-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.24.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dtolator-0.24.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 abe52e789271768a92978338f8b2ae935a45c9de5c73f7bfc7f3fb541471e86a
MD5 9da8dcfc83ac21132454ff2f87defce0
BLAKE2b-256 4e24fd549144278d699f2fdfbb56ee6b470baccb32238f5c94cf87ccc6cdc969

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtolator-0.24.1-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