From 19e42df49ff2b85200411d07b20be07cbb252b63 Mon Sep 17 00:00:00 2001 From: twoo1999 Date: Thu, 23 Nov 2023 23:59:13 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Swagger=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 실시간 위치 기록 api에 swagger추가 --- BE/musicspot/src/app.module.ts | 3 +++ BE/musicspot/src/journey/dto/journeyRecord.dto.ts | 11 +++++++++++ BE/musicspot/src/journey/journey.controller.ts | 8 ++++++++ BE/musicspot/src/main.ts | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/BE/musicspot/src/app.module.ts b/BE/musicspot/src/app.module.ts index 0368fd2..5f54785 100644 --- a/BE/musicspot/src/app.module.ts +++ b/BE/musicspot/src/app.module.ts @@ -5,6 +5,9 @@ import { MongooseModule } from '@nestjs/mongoose'; import { JourneyModule } from './journey/journey.module'; import { SpotModule } from './spot/spot.module'; import { UserModule } from './user/user.module'; +import * as dotenv from 'dotenv'; +dotenv.config(); + @Module({ imports: [ MongooseModule.forRoot( diff --git a/BE/musicspot/src/journey/dto/journeyRecord.dto.ts b/BE/musicspot/src/journey/dto/journeyRecord.dto.ts index b8f031d..d052908 100644 --- a/BE/musicspot/src/journey/dto/journeyRecord.dto.ts +++ b/BE/musicspot/src/journey/dto/journeyRecord.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger'; import { ArrayMaxSize, ArrayMinSize, @@ -7,9 +8,19 @@ import { } from 'class-validator'; export class RecordJourneyDTO { + @ApiProperty({ + example: '655efda2fdc81cae36d20650', + description: '여정 id', + required: true, + }) @IsString() readonly journeyId: string; + @ApiProperty({ + example: [37.555946, 126.972384], + description: '위치 좌표', + required: true, + }) @IsArray() @ArrayMaxSize(2, { message: 'coordinate has only 2' }) @ArrayMinSize(2, { message: 'coordinate has only 2' }) diff --git a/BE/musicspot/src/journey/journey.controller.ts b/BE/musicspot/src/journey/journey.controller.ts index d30705d..d075bf2 100644 --- a/BE/musicspot/src/journey/journey.controller.ts +++ b/BE/musicspot/src/journey/journey.controller.ts @@ -37,6 +37,14 @@ export class JourneyController { return await this.journeyService.end(endJourneyDTO); } + @ApiOperation({ + summary: '여정 좌표 기록API', + description: '여정의 좌표를 기록합니다.', + }) + @ApiCreatedResponse({ + description: '생성된 여정 데이터를 반환', + type: Journey, + }) @Post('record') async record(@Body() recordJourneyDTO: RecordJourneyDTO) { return await this.journeyService.pushCoordianteToJourney(recordJourneyDTO); diff --git a/BE/musicspot/src/main.ts b/BE/musicspot/src/main.ts index 801071b..4731111 100644 --- a/BE/musicspot/src/main.ts +++ b/BE/musicspot/src/main.ts @@ -5,7 +5,7 @@ import { ValidationPipe } from '@nestjs/common'; async function bootstrap() { const app = await NestFactory.create(AppModule); const config = new DocumentBuilder() - .setTitle('Cats example') // 문서의 제목 + .setTitle('Music Spot') // 문서의 제목 .setDescription('iOS01 Music Spot App API') // 문서의 간단한 설명 .setVersion('1.0') // API의 버전(업데이트 버전) .addTag('Music Spot')