diff --git a/src/module/categories/dto/create-category.dto.ts b/src/module/categories/dto/create-category.dto.ts index f68d513..2b72bf7 100644 --- a/src/module/categories/dto/create-category.dto.ts +++ b/src/module/categories/dto/create-category.dto.ts @@ -1,17 +1,34 @@ +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsOptional, IsString, IsUUID, MaxLength, MinLength } from 'class-validator'; export class CreateCategoryDto { + @ApiProperty({ + example: 'Technology', + description: 'Name of the category', + minLength: 1, + maxLength: 120, + }) @IsString() @MinLength(1) @MaxLength(120) name: string; + @ApiPropertyOptional({ + example: 'technology', + description: 'URL-friendly slug for the category', + maxLength: 140, + }) @IsOptional() @IsString() @MaxLength(140) slug?: string; + @ApiPropertyOptional({ + example: '550e8400-e29b-41d4-a716-446655440000', + description: 'Parent category UUID (if this is a sub-category)', + nullable: true, + }) @IsOptional() @IsUUID() parentId?: string | null; -} +} \ No newline at end of file diff --git a/src/module/categories/dto/update-category.dto.ts b/src/module/categories/dto/update-category.dto.ts index 0455e07..c11e244 100644 --- a/src/module/categories/dto/update-category.dto.ts +++ b/src/module/categories/dto/update-category.dto.ts @@ -1,18 +1,35 @@ +import { ApiPropertyOptional } from '@nestjs/swagger'; import { IsOptional, IsString, IsUUID, MaxLength, MinLength } from 'class-validator'; export class UpdateCategoryDto { + @ApiPropertyOptional({ + example: 'Technology', + description: 'Name of the category', + minLength: 1, + maxLength: 120, + }) @IsOptional() @IsString() @MinLength(1) @MaxLength(120) name?: string; + @ApiPropertyOptional({ + example: 'technology', + description: 'URL-friendly slug for the category', + maxLength: 140, + }) @IsOptional() @IsString() @MaxLength(140) slug?: string; + @ApiPropertyOptional({ + example: '550e8400-e29b-41d4-a716-446655440000', + description: 'Parent category UUID (if this is a sub-category)', + nullable: true, + }) @IsOptional() @IsUUID() parentId?: string | null; -} +} \ No newline at end of file