mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 13:49:40 +00:00
feat: fix swagger examples
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import { Body, Controller, Post } from '@nestjs/common';
|
import { Body, Controller, Post } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
import { ApiDataResponse } from '~/core/decorators';
|
||||||
import { ResponseFactory } from '~/core/utils';
|
import { ResponseFactory } from '~/core/utils';
|
||||||
import { CreateUnverifiedUserV2RequestDto, VerifyUserV2RequestDto } from '../dtos/request';
|
import { CreateUnverifiedUserV2RequestDto, VerifyUserV2RequestDto } from '../dtos/request';
|
||||||
import { LoginResponseDto } from '../dtos/response/login.response.dto';
|
import { LoginResponseDto } from '../dtos/response/login.response.dto';
|
||||||
@ -11,12 +12,14 @@ import { AuthService } from '../services';
|
|||||||
export class AuthV2Controller {
|
export class AuthV2Controller {
|
||||||
constructor(private readonly authService: AuthService) {}
|
constructor(private readonly authService: AuthService) {}
|
||||||
@Post('register/otp')
|
@Post('register/otp')
|
||||||
|
@ApiDataResponse(SendRegisterOtpV2ResponseDto)
|
||||||
async register(@Body() createUnverifiedUserDto: CreateUnverifiedUserV2RequestDto) {
|
async register(@Body() createUnverifiedUserDto: CreateUnverifiedUserV2RequestDto) {
|
||||||
const phoneNumber = await this.authService.sendPhoneRegisterOtp(createUnverifiedUserDto);
|
const phoneNumber = await this.authService.sendPhoneRegisterOtp(createUnverifiedUserDto);
|
||||||
return ResponseFactory.data(new SendRegisterOtpV2ResponseDto(phoneNumber));
|
return ResponseFactory.data(new SendRegisterOtpV2ResponseDto(phoneNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('register/verify')
|
@Post('register/verify')
|
||||||
|
@ApiDataResponse(LoginResponseDto)
|
||||||
async verifyUser(@Body() verifyUserDto: VerifyUserV2RequestDto) {
|
async verifyUser(@Body() verifyUserDto: VerifyUserV2RequestDto) {
|
||||||
const [loginResponse, user] = await this.authService.verifyUserV2(verifyUserDto);
|
const [loginResponse, user] = await this.authService.verifyUserV2(verifyUserDto);
|
||||||
return ResponseFactory.data(new LoginResponseDto(loginResponse, user));
|
return ResponseFactory.data(new LoginResponseDto(loginResponse, user));
|
||||||
|
@ -17,7 +17,7 @@ export class LoginResponseDto {
|
|||||||
@ApiProperty({ example: UserResponseDto })
|
@ApiProperty({ example: UserResponseDto })
|
||||||
user!: UserResponseDto;
|
user!: UserResponseDto;
|
||||||
|
|
||||||
@ApiProperty({ example: CustomerResponseDto })
|
@ApiProperty({ type: CustomerResponseDto })
|
||||||
customer!: CustomerResponseDto | null;
|
customer!: CustomerResponseDto | null;
|
||||||
|
|
||||||
constructor(IVerifyUserResponse: ILoginResponse, user: User) {
|
constructor(IVerifyUserResponse: ILoginResponse, user: User) {
|
||||||
|
@ -1,79 +1,79 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import { Customer } from '~/customer/entities';
|
import { Customer } from '~/customer/entities';
|
||||||
import { CustomerStatus, KycStatus } from '~/customer/enums';
|
import { CustomerStatus, Gender, KycStatus } from '~/customer/enums';
|
||||||
import { DocumentMetaResponseDto } from '~/document/dtos/response';
|
import { DocumentMetaResponseDto } from '~/document/dtos/response';
|
||||||
|
|
||||||
export class CustomerResponseDto {
|
export class CustomerResponseDto {
|
||||||
@ApiProperty()
|
@ApiProperty({ example: '123e4567-e89b-12d3-a456-426614174000' })
|
||||||
id!: string;
|
id!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: CustomerStatus.PENDING })
|
||||||
customerStatus!: CustomerStatus;
|
customerStatus!: CustomerStatus;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: KycStatus.PENDING })
|
||||||
kycStatus!: KycStatus;
|
kycStatus!: KycStatus;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Rejection reason if any' })
|
||||||
rejectionReason!: string | null;
|
rejectionReason!: string | null;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'John' })
|
||||||
firstName!: string;
|
firstName!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Doe' })
|
||||||
lastName!: string;
|
lastName!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: '1990-01-01' })
|
||||||
dateOfBirth!: Date;
|
dateOfBirth!: Date;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: '123456789' })
|
||||||
nationalId!: string;
|
nationalId!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: '2025-01-01' })
|
||||||
nationalIdExpiry!: Date;
|
nationalIdExpiry!: Date;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'JO' })
|
||||||
countryOfResidence!: string;
|
countryOfResidence!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Employee' })
|
||||||
sourceOfIncome!: string;
|
sourceOfIncome!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Software Development' })
|
||||||
profession!: string;
|
profession!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Full-time' })
|
||||||
professionType!: string;
|
professionType!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: false })
|
||||||
isPep!: boolean;
|
isPep!: boolean;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: Gender.MALE })
|
||||||
gender!: string;
|
gender!: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: false })
|
||||||
isJunior!: boolean;
|
isJunior!: boolean;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: true })
|
||||||
isGuardian!: boolean;
|
isGuardian!: boolean;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 12345 })
|
||||||
waitingNumber!: number;
|
waitingNumber!: number;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'SA' })
|
||||||
country!: string | null;
|
country!: string | null;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Riyadh' })
|
||||||
region!: string | null;
|
region!: string | null;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Riyadh City' })
|
||||||
city!: string | null;
|
city!: string | null;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'Al-Masif' })
|
||||||
neighborhood!: string | null;
|
neighborhood!: string | null;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: 'King Fahd Road' })
|
||||||
street!: string | null;
|
street!: string | null;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty({ example: '123' })
|
||||||
building!: string | null;
|
building!: string | null;
|
||||||
|
|
||||||
@ApiPropertyOptional({ type: DocumentMetaResponseDto })
|
@ApiPropertyOptional({ type: DocumentMetaResponseDto })
|
||||||
|
Reference in New Issue
Block a user