jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

JDL: DTO/Entity separate generation #18878

Closed b509 closed 2 years ago

b509 commented 2 years ago
Overview of the feature request

Have the possibility to not only define the entity but also a separate DTO for it. For a DB entry you could then have an entity definition (persistence layer) as is written into the database as well as a DTO (presentation layer). Mapping is feasible with Mapstruct, either by trying to generate it or by having the user provide it according to a given format beside the JDL file.

Motivation for or Use Case

In most applications I am aware of the persistence layer is always slightly different than what is presented in the frontend/REST api. To account for that you currently have to adapt the generated code. But technically it seems pretty straight-forward to support and would make the generated functionality more powerful and cover - in my experience - a very common issue that presentation layer != persistence layer.

Related issues or PR

No related issues

Tcharl commented 2 years ago

You can generate dto for jhipster application, see

Advanced syntax is not supported yet: you can code your own DTO and your own mappers on top of jhipster-generated dtos or entities then (see)