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

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

Uploaded Python 3Windows x86-64

dtolator-0.24.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (968.4 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

dtolator-0.24.0-py3-none-macosx_11_0_arm64.whl (880.0 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

dtolator-0.24.0-py3-none-macosx_10_12_x86_64.whl (923.4 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: dtolator-0.24.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 806.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.24.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3038ca5eec7699d388cb9e4a08fde102c87dea45e446a99ba289eddfb147862a
MD5 c9d4ae94acc1280460b869df75ec9f05
BLAKE2b-256 e68a73baf83a8f36a00050e6331db01e70c8024fb10f0fa43bd6aa7ee0335bd3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dtolator-0.24.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a58dd6c826f6de03cf27d5fd72f62c6d334a519ecd8cc6d62c0457b9ec4f66f
MD5 d57c4564c2424961400cd04da5aa7c8f
BLAKE2b-256 bdccb611b540c85299ef621796381922078f4a38e0b0423676aa106ab0fe619d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dtolator-0.24.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c4e1e369a6e1e532f813b883176b9d5cca352f600253f58836b6fb7fe247f67
MD5 bea1999931b11648ccebb7985b6596b6
BLAKE2b-256 9b09f26ded0d85ddafe574b0f3357d117c97c48de866c44c8af5e7a541216ba0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dtolator-0.24.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4da9c27e7f4eb770bc044919d006b0c8abd4516b06e9208718e9dbb8b73d9d65
MD5 a8ee8e488080cae5c51c752c6e7cf5b9
BLAKE2b-256 b79832e31ab129a00038249de2c188c0081e863022a3a79de97c38ec9a50ba04

See more details on using hashes here.

Provenance

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