Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWL-212] Workouts API 테스트 코드 작성 및 리팩토링 #248

Merged
merged 13 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: response dto에서 Schema Swagger 삭제 및 수정
wonholim committed Dec 6, 2023
commit 669f1d5ac6bf1fdd08bdbb65c5b6fd3e80881e27
32 changes: 3 additions & 29 deletions BackEnd/src/workouts/dto/workout-response.dto.ts
Original file line number Diff line number Diff line change
@@ -3,32 +3,6 @@ import { SuccessResDto } from '../../common/dto/SuccessRes.dto';
import { Workout } from '../entities/workout.entity';

export class WorkoutResDto extends SuccessResDto {
@ApiProperty({ type: () => PickType(Workout, ['id', 'name']) })
data: Pick<Workout, 'id' | 'name'>;
}

export const WorkoutResDtoSwagger = () => {
return {
example: {
code: null,
errorMessage: null,
data: [
{
id: 1,
name: '달리기',
icon: 'figure.outdoor.a',
},
{
id: 2,
name: '수영',
icon: 'figure.outdoor.b',
},
{
id: 3,
name: '사이클',
icon: 'figure.outdoor.c',
},
],
},
};
};
@ApiProperty({ type: () => [Workout] })
data: Workout[];
}
8 changes: 2 additions & 6 deletions BackEnd/src/workouts/workouts.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, UseGuards } from '@nestjs/common';
import { WorkoutsService } from './workouts.service';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { WorkoutResDtoSwagger } from './dto/workout-response.dto';
import {WorkoutResDto} from './dto/workout-response.dto';
import { AccessTokenGuard } from '../auth/guard/bearerToken.guard';
import { Workout } from './entities/workout.entity';

@@ -12,11 +12,7 @@ export class WorkoutsController {
constructor(private readonly workoutsService: WorkoutsService) {}
@Get()
@ApiOperation({ summary: '모든 운동 종류 조회' })
@ApiResponse({
status: 200,
description: '성공',
schema: WorkoutResDtoSwagger(),
})
@ApiResponse({ type: WorkoutResDto })
getAllWorkout(): Promise<Workout[]> {
return this.workoutsService.findAllWorkouts();
}