Skip to content

Commit

Permalink
fix: swagger entities fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
toimc committed Aug 28, 2022
1 parent 829033f commit a86e584
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/module/admin/articles/dto/create-article.dto.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty } from 'class-validator';

export class CreateArticleDto {
@ApiProperty()
@IsNotEmpty()
title: string;

@ApiProperty()
@ApiPropertyOptional()
@IsNotEmpty()
description?: string;

Expand Down
4 changes: 2 additions & 2 deletions src/module/admin/articles/entities/article.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// src/articles/entities/article.entity.ts

import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Article } from '@prisma/client';

export class ArticleEntity implements Article {
Expand All @@ -10,7 +10,7 @@ export class ArticleEntity implements Article {
@ApiProperty()
title: string;

@ApiProperty({ required: false, nullable: true })
@ApiPropertyOptional({ required: false, nullable: true })
description: string | null;

@ApiProperty()
Expand Down
12 changes: 6 additions & 6 deletions src/module/admin/focus/dto/create-focus.dto.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty } from 'class-validator';

export class CreateFocusDto {
@ApiProperty()
@IsNotEmpty()
title: string;

@ApiProperty({ required: false, default: '' })
@ApiPropertyOptional({ required: false, default: '' })
@IsNotEmpty()
link?: string;

@ApiProperty({ required: false, default: '' })
@IsNotEmpty()
content: string;

@ApiProperty({ required: false, default: '' })
@ApiPropertyOptional({ required: false, default: '' })
focus_img?: string;

@ApiProperty({ required: false, default: 0 })
@ApiPropertyOptional({ required: false, default: 0 })
@IsNotEmpty()
type?: number;

@ApiProperty({ required: false, default: 0 })
@ApiPropertyOptional({ required: false, default: 0 })
@IsNotEmpty()
status?: number;

@ApiProperty({ required: false, default: 0 })
@ApiPropertyOptional({ required: false, default: 0 })
@IsNotEmpty()
sort?: number;
}
3 changes: 3 additions & 0 deletions src/user/dto/edit-user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsEmail, IsOptional, IsString } from 'class-validator';

export class EditUserDto {
@IsEmail()
@IsOptional()
@ApiPropertyOptional()
email?: string;

@IsString()
@IsOptional()
@ApiPropertyOptional()
name?: string;
}

0 comments on commit a86e584

Please sign in to comment.