Skip to main content

DTOgen - Data Transfer Object Generator

DTOgen is a powerful library that allows users to effortlessly generate Data Transfer Object (DTO) classes in multiple programming languages from YAML definitions. DTOgen aims to simplify the process of mapping JSON or XML data to objects, making it an excellent tool for microservices development.

With DTOgen, syncing Data Transfer Objects (DTOs) across services becomes a seamless process. Since DTOgen allows you to define DTOs in a centralized YAML file and generates the corresponding classes in multiple programming languages, you can ensure consistency across your microservices easily.

DTOgen is designed to handle not only simple data types but also complex data structures like lists and maps. With the ability to represent lists and maps in the YAML definitions, DTOgen can generate DTO classes that accurately reflect these data structures in multiple programming languages.

Features

  • Define DTOs in YAML: Users can create their Data Transfer Object definitions in a YAML file, which makes it easy to manage and understand the data structures.

  • Multi-language Support: DTOgen supports generating DTO classes for three popular programming languages: Java, Python, and TypeScript. This enables seamless integration into various microservices projects.

  • Simple CLI Integration: The library provides a command-line interface (CLI) tool 'dtogen', making it straightforward for users to generate DTO classes for their chosen language.

Installation

DTOgen can be installed using pip for Python, TypeScript and Java projects.

pip install dtogen

Usage

  1. Create a YAML file with your DTO definitions. For example, dto_definitions.yaml:
info:
  name: library-dtos
  version: 0.0.1

dtos:
  person :
    attributes :
      - name : name
        type : string
      - name : age
        type : integer
  1. Run the 'dtogen' CLI command with the desired target language:
dtogen -i dto_definitions.yaml -o dto_directory -l java --java-package com.example.dtos
  1. The library will generate the corresponding DTO classes in the specified output directory for the chosen language.

Example

Given the dto_definitions.yaml example above, DTOgen will generate the following DTO classes for each language:

Java

public class Person {
  public String name;
  public int age;
}

Python

class Person:
  name: str
  age: int

TypeScript

export class Person {
    name: string | undefined;
    age: number | undefined;
}

DTOgen simplifies the process of creating Data Transfer Objects, enabling developers to focus more on building efficient microservices without worrying about complex data mapping.

Metadata

Release files for dtogen 0.0.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dtogen 0.0.17
File Size Uploaded
dtogen-0.0.17.tar.gz 9.6 kB Details

Release files / dtogen-0.0.17.tar.gz

Download URL dtogen-0.0.17.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4170d21afb81598f4946e8a70a0b181e6837b8a0f36abd0dfab41e18504bdcdc
BLAKE2b-256 checksum
How to use checksums
210b31a4e7e1f46e4d0865f76e208753af440dfc424a3a1e1ad7f33f63e21f1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.0.17 This release

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page