Questions tagged [dto]

DTO is an acronym for Data Transfer Object, a design pattern used in data transfer.

DTO is an acronym for Data Transfer Object, a design pattern used in transferring data through internal or external interfaces. A DTO protects the application's internal data by acting as dummy storages, the whole logic is implemented only in actual Domain Objects (DO).

Pros:

  • Fewer remote calls (typically one, getDto() vs. individual getId(), getName(), etc.)
  • Improved data capsulation (Remote systems need only to know the details of the DTO, not DO internals)

Cons:

  • class explosion
  • conversions needed between DTOs and DOs
2100 questions
0
votes
1 answer

Spring Boot unmarshalling JSON request body creates modifiable list

I am trying to create an immutable DTO. Therefore I have added the @Builder and @Getter Lombok annotation for creating immutable objects from Pizza.class. To prevent the ingredients field to be initialized with a mutable List, I have added the…
0
votes
1 answer

Spatie Laravel/data not formatting errors

I'm working on a project in which I'm using Spatie's laravel-data package (https://spatie.be/docs/laravel-data/v2/introduction) to manage Data Transfer Objects (DTOs). I've got some DTOs which are currently working fine until I got to this one in…
MrCujo
  • 1,218
  • 3
  • 31
  • 56
0
votes
0 answers

NestJS Interceptor mapping URL parameters into DTO is not converting values to numbers following @Type( ()=> Number)

Following on from This question, I have created an interceptor, and I am able to map my parameters into my DTO. However, the number parameters, are not being converted to numeric during the validation. The DTO: export class GetDTO { @IsDefined()…
Steven Scott
  • 10,234
  • 9
  • 69
  • 117
0
votes
1 answer

Cannot create a mapping profile (DTO => entity)

I'm using NestJs with https://github.com/nartc/mapper (automapper). I really love this library but it doesn't come with structured documentation for NestJs, so a lot of errors aren't documented. In my others entities it just works and I'm doing the…
persicoDev
  • 31
  • 2
  • 5
0
votes
1 answer

.NET Use Dto models in Infrastructure

i try do app with clean architecture (with mediator, fluent validation). I have services (interfaces) in application project and implementation in infrastructure project. Is it ok use in the services as parameter the Dto objects? I save dto in…
pietro
  • 143
  • 1
  • 9
0
votes
1 answer

nestJS class-validator for complex data structure

I have an XML document that I have parsed into JSON. The element values have an odd structure. { "id": [ "62314" ], "artnr": [ "OBS6680" ], "categories": [ { "category": [ { "cat": [ …
0
votes
1 answer

Custom validator for email doesn't throw exception when validating an invalid email address on a Spatie DTO object

I'm currently working on an integration with a third party API for an application, for which I'm using Spatie's data transfer object library. I'm currently looking to set up validation for some fields, and have run into an issue. I've written the…
Matthew Daly
  • 9,212
  • 2
  • 42
  • 83
0
votes
1 answer

Is there an approach in C# WebAPI with DTO's to only update elements that need to change?

In the tutorials I've walked through around creating an API in C#, I've gone through creating an HTTP PUT command for updating records in a table contained in a database. The examples I've seen, essentially, I create a DTO around the fields that can…
CSharpNewb
  • 181
  • 5
  • 15
0
votes
0 answers

DTO sharing between API gateway and other services

I understand that sharing code between microserices in an anti-pattern, but what about sharing DTOs between the API Gateway and the services it communicates with? Is it better to copy all of the DTOs from all of the services into the gateway? Or is…
kraikov
  • 53
  • 6
0
votes
0 answers

NestJS Combine DTOs into a single DTO with Swagger support

I have different routes that use different DTOs for the payload requests. However, I have some input rules on the payloads, and I want to enforce those, without having to redefine them in my different DTOs. I also use the Swagger documentation and…
Steven Scott
  • 10,234
  • 9
  • 69
  • 117
0
votes
1 answer

WebFlux & formation DTO

Hello recently started studying Webflux. And sometimes I encounter the tasks that you need to form a simple DTO and return it Take for example the usual class dto @Data @Builder public static class Dto { private long id; private…
LeshaRB
  • 1,345
  • 2
  • 23
  • 44
0
votes
0 answers

How to deserialize json data and get rid of all the excess information

I'm having a problem with deserializing json object into DTO class. The dto object has the following structure: @Getter @Setter @ToString @RequiredArgsConstructor @JsonIgnoreProperties(value = { "charsetinfo" }) public class SingleEngineJsonDto { …
SoN
  • 3
  • 4
0
votes
1 answer

ChildDTO into ParentDTO in JHIPSTER with mapstruct

I have this entities entity Employee { firstName String lastName String } entity Role { Name String } relationship OneToMany { Employee{role} to Role{employee required} } And i want to return in the ParentDTO something like…
0
votes
1 answer

Symfony validator exhausting the memory for long running process

I have a process where I try to import a big data to the database. I'm handling this using a row-by-row approach so I can make the validation for each row. For some reason, the code starts to run out of memory while running, so I could find the…
Mahmoud Abdelsattar
  • 1,299
  • 1
  • 15
  • 31
0
votes
0 answers

relating data.sql to springboot project

spring.datasource.data=classpath:/schema.sql #spring.jpa.properties.hibernate.hbm2ddl.import_files=schema.sql what's the difference between those 2? first one doesn't work on my project, but the other one works. But, if i create new data(article),…
Samuel Yoo
  • 21
  • 2