add category swagger schema

This commit is contained in:
2026-04-18 09:44:09 +01:00
parent 068dff4c19
commit 5248430579
2 changed files with 36 additions and 2 deletions
@@ -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;
}
}
@@ -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;
}
}