feat: complete auth and submission's swagger docs

This commit is contained in:
2026-09-02 16:37:47 +03:30
parent 8fced148b7
commit 0961b8f11d
22 changed files with 453 additions and 13 deletions
+35 -8
View File
@@ -26,16 +26,13 @@ export class AuthController {
@ApiAppResponse([
{
status: HttpStatus.OK,
description: 'Successfull responses',
variants: [
{
model: TokensResponseDTO,
example: {
data: {
access:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjMiLCJyb2xlIjoidXNlciIsImlhdCI6MTcyNDAwMDAwMCwiZXhwIjoxNzI0MDAzNjAwfQ.dGVzdC1zaWduYXR1cmU',
refresh:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjMiLCJyb2xlIjoidXNlciIsImlhdCI6MTcyNDAwMDAwMCwiZXhwIjoxNzI0MDAzNjAwfQ.dGVzdC1zaWduYXR1cmU',
access: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
refresh: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
},
},
},
@@ -61,8 +58,7 @@ export class AuthController {
],
},
{
status: HttpStatus.BAD_REQUEST,
description: 'BadRequest responses',
status: HttpStatus.UNAUTHORIZED,
variants: [
{
messageExample: 'شماره موبایل یا رمز عبور اشتباه است.',
@@ -71,7 +67,6 @@ export class AuthController {
},
{
status: HttpStatus.TOO_MANY_REQUESTS,
description: 'TooManyRequests responses',
variants: [
{
messageExample:
@@ -88,6 +83,24 @@ export class AuthController {
@Post('verify-otp')
@HttpCode(HttpStatus.OK)
@Throttle({ otp: {} })
@ApiAppResponse([
{
status: HttpStatus.OK,
variants: [
{
model: TokensResponseDTO,
},
],
},
{
status: HttpStatus.UNAUTHORIZED,
variants: [
{
messageExample: 'کد تایید اشتباه است یا منقضی شده.',
},
],
},
])
public async verifyOTP(@Body() verifyOtpDto: VerifyOtpDTO) {
return await this.authService.verifyOTP(verifyOtpDto);
}
@@ -96,6 +109,20 @@ export class AuthController {
@Post('refresh')
@HttpCode(HttpStatus.OK)
@Throttle({ login: {} })
@ApiAppResponse([
{
status: HttpStatus.OK,
variants: [
{
model: TokensResponseDTO,
},
],
},
{
status: HttpStatus.UNAUTHORIZED,
variants: [{ messageExample: 'توکن قبلا استفاده شده.' }],
},
])
public async refreshToken(@Body() refreshTokenDto: RefreshTokenDTO) {
return await this.authService.refreshToken(refreshTokenDto);
}
@@ -3,11 +3,13 @@ import { ApiProperty } from '@nestjs/swagger';
export class TokensResponseDTO {
@ApiProperty({
type: 'string',
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
})
access!: string;
@ApiProperty({
type: 'string',
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
})
refresh!: string;
}