Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

DTO support for ApiProperty #11

Open
LeulAria opened this issue Mar 16, 2023 · 1 comment
Open

DTO support for ApiProperty #11

LeulAria opened this issue Mar 16, 2023 · 1 comment

Comments

@LeulAria
Copy link

LeulAria commented Mar 16, 2023

can we add a confg like generateDTO for swagger to add api property

generator zod {
  provider                 = "nestjs-zod-prisma"
  output                   = "./src/zod" // (default) the directory where generated zod schemas will be saved

  relationModel            = true // (default) Create and export both plain and related models.
  // relationModel         = "default" // Do not export model without relations.
  // relationModel         = false // Do not generate related model

  generateDto              = true // (default) Generate DTOs for NestJS
  generateSwaggerApiProperty = true // (default) Genrate ApiPrpoertyDecorator on DTO's
  ...
  

From schema.prisma

model User {
  id                String   @id /// @z.string()
  email             String   @unique /// @z.string().email() @ApiProperty({ example: '[email protected]', description: 'User email' })
  full_name         String   @unique /// @z.string().max(50, { message: "Fullname should be less than 50 characters " }) @ApiProperty({ example: 'Jean Doe', description: 'Users full name' })
  password          String   @unique /// @z.password().atLeastOne('digit').atLeastOne('lowercase').atLeastOne('uppercase').min(8).max(100) @ApiProperty({ description: 'User password' })
}

To Generate example

export class UserDto {
  @ApiProperty({ example: '[email protected]', description: 'User email' })
  email: string;
  @ApiProperty({ example: 'Jean Doe', description: 'Users full name' })
  full_name: string;
  @ApiProperty({ description: 'User password' })
  password: string;
}
@yangricardo
Copy link

yangricardo commented Jul 14, 2023

Also desire this =D
There are some interesting behaviors from this other generator that could be included, like @DtoReadOnly and creations of Create / Update dtos

https://www.npmjs.com/package/prisma-types-generator

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants