feat: complete auth and submission's swagger docs
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { AccessType } from '../../enums/access-types.enum';
|
||||
|
||||
export class GetTestByIdDTO {
|
||||
@ApiProperty({
|
||||
type: 'number',
|
||||
example: 1,
|
||||
})
|
||||
id!: number;
|
||||
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
example: 'Test Title',
|
||||
})
|
||||
title!: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
example: 'Test description',
|
||||
})
|
||||
description!: string;
|
||||
|
||||
@ApiProperty({
|
||||
enum: AccessType,
|
||||
enumName: 'accessType',
|
||||
example: 'login',
|
||||
})
|
||||
accessType!: AccessType;
|
||||
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
example: '1000000',
|
||||
})
|
||||
price!: string;
|
||||
}
|
||||
@@ -1,6 +1,14 @@
|
||||
import { Controller, Get, Param, ParseIntPipe } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
HttpStatus,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
} from '@nestjs/common';
|
||||
import { TestsService } from './providers/tests.service';
|
||||
import { Public } from '../auth/decorators/public.decorator';
|
||||
import { ApiAppResponse } from '@/common/decorators/api-app-response.decorator';
|
||||
import { GetTestByIdDTO } from './dtos/responses/get-test-by-id.dto';
|
||||
|
||||
@Controller('tests')
|
||||
export class TestsController {
|
||||
@@ -13,12 +21,41 @@ export class TestsController {
|
||||
|
||||
@Public()
|
||||
@Get()
|
||||
@ApiAppResponse([
|
||||
{
|
||||
status: HttpStatus.OK,
|
||||
variants: [
|
||||
{
|
||||
isArray: true,
|
||||
model: GetTestByIdDTO,
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
public async getAllTests() {
|
||||
return await this.testsService.userGetAll();
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get(':id')
|
||||
@ApiAppResponse([
|
||||
{
|
||||
status: HttpStatus.OK,
|
||||
variants: [
|
||||
{
|
||||
model: GetTestByIdDTO,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
status: HttpStatus.NOT_FOUND,
|
||||
variants: [
|
||||
{
|
||||
messageExample: 'تست مورد نظر یافت نشد.',
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
public async getTestById(@Param('id', ParseIntPipe) id: number) {
|
||||
return await this.testsService.userGetOne(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user