feat: add login swagger fields

This commit is contained in:
2026-09-01 17:38:29 +03:30
parent 195ace097c
commit d1324eb960
11 changed files with 222 additions and 8 deletions
+61
View File
@@ -5,6 +5,10 @@ import { VerifyOtpDTO } from './dtos/verify-otp.dto';
import { Public } from './decorators/public.decorator';
import { RefreshTokenDTO } from './dtos/refresh-token.dto';
import { Throttle } from '@nestjs/throttler';
import { ApiAppResponse } from '@/common/decorators/api-app-response.decorator';
import { NewUserLoginResponseDTO } from './dtos/responses/new-user-login.dto';
import { RequirePasswordDTO } from './dtos/responses/require-password.dto';
import { TokensResponseDTO } from './dtos/responses/tokens.dto';
@Controller('auth')
export class AuthController {
@@ -19,6 +23,63 @@ export class AuthController {
@Post('login')
@HttpCode(HttpStatus.OK)
@Throttle({ login: {} })
@ApiAppResponse([
{
status: HttpStatus.OK,
description: 'Successfull responses',
variants: [
{
model: TokensResponseDTO,
example: {
data: {
access:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjMiLCJyb2xlIjoidXNlciIsImlhdCI6MTcyNDAwMDAwMCwiZXhwIjoxNzI0MDAzNjAwfQ.dGVzdC1zaWduYXR1cmU',
refresh:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjMiLCJyb2xlIjoidXNlciIsImlhdCI6MTcyNDAwMDAwMCwiZXhwIjoxNzI0MDAzNjAwfQ.dGVzdC1zaWduYXR1cmU',
},
},
},
{
model: NewUserLoginResponseDTO,
example: {
data: {
newUser: true,
otpExpiresAt: '2026-09-01T09:24:34.894Z',
},
message: 'کد تایید به شماره 09121111111 فرستاده شد.',
},
},
{
model: RequirePasswordDTO,
example: {
data: {
newUser: false,
},
message: 'لطفا رمز عبور را ارسال کنید.',
},
},
],
},
{
status: HttpStatus.BAD_REQUEST,
description: 'BadRequest responses',
variants: [
{
messageExample: 'شماره موبایل یا رمز عبور اشتباه است.',
},
],
},
{
status: HttpStatus.TOO_MANY_REQUESTS,
description: 'TooManyRequests responses',
variants: [
{
messageExample:
'تعداد درخواست ها بیشتر از حد مجاز است! لطفا بعد از 1 دقیقه دوباره امتحان کنید.',
},
],
},
])
public async logIn(@Body() loginDto: LoginDTO) {
return await this.authService.logIn(loginDto);
}