Skip to content

Commit

Permalink
docs: 현재 구현 기준으로 quizzes로 오는 API 설명 작성
Browse files Browse the repository at this point in the history
- 추가로 POST command 실행 시 nest가 자동으로 201 created를 반환하길래 200 OK임을 명시했습니다.

[#59]
  • Loading branch information
flydog98 authored and LuizyHub committed Nov 22, 2023
1 parent 418aef8 commit 25bf40f
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion packages/backend/src/quizzes/quizzes.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import {
Res,
Req,
} from '@nestjs/common';
import {
ApiTags,
ApiOperation,
ApiResponse,
ApiParam,
ApiBody,
} from '@nestjs/swagger';
import { QuizDto } from './dto/quiz.dto';
import { QuizzesService } from './quizzes.service';
import { QuizzesDto } from './dto/quizzes.dto';
Expand All @@ -18,6 +25,7 @@ import { SessionService } from '../session/session.service';
import { Request, Response } from 'express';
import { ContainersService } from '../containers/containers.service';

@ApiTags('quizzes')
@Controller('api/v1/quizzes')
export class QuizzesController {
constructor(
Expand All @@ -27,18 +35,41 @@ export class QuizzesController {
) {}

@Get(':id')
@ApiOperation({ summary: 'ID를 통해 문제 정보를 가져올 수 있습니다.' })
@ApiResponse({
status: 200,
description: 'Returns the quiz details',
type: QuizDto,
})
@ApiParam({ name: 'id', description: '문제 ID' })
async getProblemById(@Param('id') id: number): Promise<QuizDto> {
const quizDto = await this.quizService.getQuizById(id);

return quizDto;
}

@Get('/')
@ApiOperation({
summary: '카테고리 별로 모든 문제의 제목과 id를 가져올 수 있습니다.',
})
@ApiResponse({
status: 200,
description: '카테고리 별로 문제의 제목과 id가 리턴됩니다.',
type: QuizzesDto,
})
async getProblemsGroupedByCategory(): Promise<QuizzesDto> {
return this.quizService.findAllProblemsGroupedByCategory();
}

@Post(':id/command')
@ApiOperation({ summary: 'Git 명령을 실행합니다.' })
@ApiResponse({
status: 200,
description: 'Git 명령의 실행 결과(stdout/stderr)를 리턴합니다.',
type: CommandResponseDto,
})
@ApiParam({ name: 'id', description: '문제 ID' })
@ApiBody({ description: 'Command to be executed', type: CommandRequestDto })
async runGitCommand(
@Param('id') id: number,
@Body() execCommandDto: CommandRequestDto,
Expand Down Expand Up @@ -82,7 +113,7 @@ export class QuizzesController {
execCommandDto.command,
);

response.send({
response.status(HttpStatus.OK).send({
message,
result,
// graph: 필요한 경우 여기에 추가
Expand Down

0 comments on commit 25bf40f

Please sign in to comment.