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:
@@ -6,29 +6,37 @@ import {
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { PaymentProvider, PaymentType } from '@prisma/client';
|
||||
|
||||
export class CreatePaymentDto {
|
||||
@ApiProperty({ enum: PaymentProvider, description: 'Payment provider' })
|
||||
@IsEnum(PaymentProvider)
|
||||
provider!: PaymentProvider;
|
||||
|
||||
@ApiProperty({ enum: PaymentType, description: 'Payment type' })
|
||||
@IsEnum(PaymentType)
|
||||
type!: PaymentType;
|
||||
|
||||
@ApiProperty({ type: Number, description: 'Amount in VND', example: 500000 })
|
||||
@Transform(({ value }) => BigInt(value))
|
||||
amountVND!: bigint;
|
||||
|
||||
@ApiProperty({ description: 'Payment description', example: 'Listing fee' })
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
description!: string;
|
||||
|
||||
@ApiProperty({ description: 'URL to redirect after payment', example: 'https://example.com/return' })
|
||||
@IsUrl()
|
||||
returnUrl!: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'External transaction ID' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
transactionId?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Idempotency key to prevent duplicate payments' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
idempotencyKey?: string;
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import { IsEnum, IsInt, IsOptional, Max, Min } from 'class-validator';
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { PaymentStatus } from '@prisma/client';
|
||||
|
||||
export class ListTransactionsDto {
|
||||
@ApiPropertyOptional({ enum: PaymentStatus, description: 'Filter by payment status' })
|
||||
@IsOptional()
|
||||
@IsEnum(PaymentStatus)
|
||||
status?: PaymentStatus;
|
||||
|
||||
@ApiPropertyOptional({ type: Number, description: 'Maximum number of results', minimum: 1, maximum: 100, default: 20 })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
limit?: number;
|
||||
|
||||
@ApiPropertyOptional({ type: Number, description: 'Number of results to skip', minimum: 0, default: 0 })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { IsString, MinLength } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class RefundPaymentDto {
|
||||
@ApiProperty({ description: 'Reason for the refund', example: 'Customer requested cancellation' })
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
reason!: string;
|
||||
|
||||
Reference in New Issue
Block a user