feat: complete auth and submission's swagger docs
This commit is contained in:
@@ -15,6 +15,11 @@ import { ActiveUser } from '@/common/decorators/active-user.decorator';
|
||||
import { SubmissionsService } from './providers/submissions.service';
|
||||
import { StartSubmissionDTO } from './dtos/start-submission.dto';
|
||||
import { AnswerSubmissionDTO } from './dtos/answer-submission.dto';
|
||||
import { ApiAppResponse } from '@/common/decorators/api-app-response.decorator';
|
||||
import { StartAuthenticatedDTO } from './dtos/responses/start-authenticated.dto';
|
||||
import { StartGuestDTO } from './dtos/responses/start-guest.dto';
|
||||
import { GetAnswerSubmissionDTO } from './dtos/responses/get-answer-submission.dto';
|
||||
import { GetSubmissionHistoryDTO } from './dtos/responses/get-submission-history.dto';
|
||||
|
||||
@Controller('submissions')
|
||||
export class SubmissionsController {
|
||||
@@ -29,6 +34,63 @@ export class SubmissionsController {
|
||||
@Post('start')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(OptionalJwtGuard)
|
||||
@ApiAppResponse([
|
||||
{
|
||||
status: HttpStatus.OK,
|
||||
variants: [
|
||||
{
|
||||
model: StartAuthenticatedDTO,
|
||||
example: {
|
||||
data: {
|
||||
submissionId: 1,
|
||||
question: {
|
||||
id: 1,
|
||||
type: 'numeric',
|
||||
content: 'string',
|
||||
required: true,
|
||||
choices: [],
|
||||
metadata: {
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
model: StartGuestDTO,
|
||||
example: {
|
||||
data: {
|
||||
guestSubmissionId: 'sahfdih123ieg1231fds23ljhakshf',
|
||||
question: {
|
||||
id: 2,
|
||||
type: 'single-choice',
|
||||
content: 'string',
|
||||
required: true,
|
||||
choices: [
|
||||
{
|
||||
id: 1,
|
||||
order: 1,
|
||||
text: 'string',
|
||||
},
|
||||
],
|
||||
metadata: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
status: HttpStatus.NOT_FOUND,
|
||||
variants: [{ messageExample: 'تست مورد نظر یافت نشد.' }],
|
||||
},
|
||||
{
|
||||
status: HttpStatus.FORBIDDEN,
|
||||
variants: [{ messageExample: 'تست مورد نظر فعال نیست.' }],
|
||||
},
|
||||
])
|
||||
public async startTest(
|
||||
@Body() startSubmissionDto: StartSubmissionDTO,
|
||||
@ActiveUser() user?: User,
|
||||
@@ -43,6 +105,16 @@ export class SubmissionsController {
|
||||
@Post(':id/answer')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@UseGuards(OptionalJwtGuard)
|
||||
@ApiAppResponse([
|
||||
{
|
||||
status: HttpStatus.OK,
|
||||
variants: [
|
||||
{
|
||||
model: GetAnswerSubmissionDTO,
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
public async answerSubmission(
|
||||
@Param('id') id: string,
|
||||
@Body() answerSubmissionDto: AnswerSubmissionDTO,
|
||||
@@ -58,6 +130,16 @@ export class SubmissionsController {
|
||||
@Public()
|
||||
@Get(':id/history')
|
||||
@UseGuards(OptionalJwtGuard)
|
||||
@ApiAppResponse([
|
||||
{
|
||||
status: HttpStatus.OK,
|
||||
variants: [
|
||||
{
|
||||
model: GetSubmissionHistoryDTO,
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
public async getHistory(@Param('id') id: string, @ActiveUser() user?: User) {
|
||||
return await this.submissionsService.getSubmissionHistory(id, user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user