Skip to main content

DTO generator for Java, TypeScript, Python

Project description

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.

Project details


Download files

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

Source Distribution

dtogen-0.0.17.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file dtogen-0.0.17.tar.gz.

File metadata

  • Download URL: dtogen-0.0.17.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for dtogen-0.0.17.tar.gz
Algorithm Hash digest
SHA256 4170d21afb81598f4946e8a70a0b181e6837b8a0f36abd0dfab41e18504bdcdc
MD5 48e21cbdd240d2e1529807484ebb42c9
BLAKE2b-256 210b31a4e7e1f46e4d0865f76e208753af440dfc424a3a1e1ad7f33f63e21f1d

See more details on using hashes here.

Supported by

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