feat(api): add OpenAPI/Swagger documentation for all API endpoints

Install @nestjs/swagger, configure Swagger UI at /api/docs with JWT bearer
auth, and add ApiTags/ApiOperation/ApiResponse/ApiProperty decorators to
all 8 controllers (50+ endpoints) and 31 DTOs across auth, listings,
search, payments, subscriptions, admin, notifications, and analytics modules.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-08 04:08:11 +07:00
parent 325cd4c421
commit 8e7672694b
42 changed files with 531 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import {
Max,
} from 'class-validator';
import { Transform, Type } from 'class-transformer';
import { ApiPropertyOptional } from '@nestjs/swagger';
export enum SortByOption {
PRICE_ASC = 'price_asc',
@@ -17,60 +18,72 @@ export enum SortByOption {
}
export class SearchPropertiesDto {
@ApiPropertyOptional({ description: 'Free-text search query', example: 'chung cu quan 7' })
@IsOptional()
@IsString()
q?: string;
@ApiPropertyOptional({ description: 'Property type filter', example: 'apartment' })
@IsOptional()
@IsString()
propertyType?: string;
@ApiPropertyOptional({ description: 'Transaction type filter (sale or rent)', example: 'sale' })
@IsOptional()
@IsString()
transactionType?: string;
@ApiPropertyOptional({ description: 'Minimum price in VND', example: 1000000000, minimum: 0 })
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(0)
priceMin?: number;
@ApiPropertyOptional({ description: 'Maximum price in VND', example: 5000000000, minimum: 0 })
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(0)
priceMax?: number;
@ApiPropertyOptional({ description: 'Minimum area in m²', example: 50, minimum: 0 })
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(0)
areaMin?: number;
@ApiPropertyOptional({ description: 'Maximum area in m²', example: 200, minimum: 0 })
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(0)
areaMax?: number;
@ApiPropertyOptional({ description: 'Number of bedrooms', example: 2, minimum: 0 })
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(0)
bedrooms?: number;
@ApiPropertyOptional({ description: 'District name', example: 'Quan 7' })
@IsOptional()
@IsString()
district?: string;
@ApiPropertyOptional({ description: 'City name', example: 'Ho Chi Minh' })
@IsOptional()
@IsString()
city?: string;
@ApiPropertyOptional({ description: 'Sort order', enum: SortByOption, example: SortByOption.PRICE_ASC })
@IsOptional()
@IsEnum(SortByOption)
sortBy?: SortByOption;
@ApiPropertyOptional({ description: 'Page number (1-based)', example: 1, default: 1, minimum: 1 })
@IsOptional()
@Type(() => Number)
@IsInt()
@@ -78,6 +91,7 @@ export class SearchPropertiesDto {
@Transform(({ value }) => value ?? 1)
page?: number;
@ApiPropertyOptional({ description: 'Results per page', example: 20, default: 20, minimum: 1, maximum: 100 })
@IsOptional()
@Type(() => Number)
@IsInt()