Skip to content

Commit

Permalink
Docs : 장소 컨트롤러 swagger 응답 정정
Browse files Browse the repository at this point in the history
  • Loading branch information
YubinShin committed Dec 7, 2023
1 parent 200d424 commit 0240ebf
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 63 deletions.
61 changes: 28 additions & 33 deletions src/places/places.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ApiCreatedResponse,
ApiResponse,
ApiOperation,
ApiQuery,
} from "@nestjs/swagger";
import {
SearchResponse,
Expand Down Expand Up @@ -43,40 +44,31 @@ export class PlacesController {
type: landmarksResponse,
})
async getLandmarks() {
try {
const result = await this.placesService.getLandmarks();
// 클라이언트에게 결과를 응답으로 보내기
return result;
// return res.status(HttpStatus.OK).json(result);
} catch (error) {
// return res
// .status(HttpStatus.NOT_FOUND)
// .json({ message: "Error occurred during search." });
}
}
/** -------------------- */

/** 간단하게 장소검색하기 */
@Get("/simple_search")
@ApiOperation({
summary: "간단하게 장소검색하기/ query 필요",
})
@ApiResponse({
status: 200,
description: "",
type: SearchResponse, // 반환 모델을 지정
})
@ApiResponse({ status: 404, description: "해당 장소 검색 실패" })
async jhPlaceSearch(
@Query("query") query: string,
): Promise<void> {
try {
const searchResult = await this.placesService.findSimplePlacesInfo(query);
return searchResult;
// res.status(HttpStatus.OK).json(searchResult);
} catch (error) {
}
}
/** 개발용 : 간단하게 장소검색하기 */
// @Get("/simple_search")
// @ApiOperation({
// summary: "간단하게 장소검색하기/ query 필요",
// })
// @ApiResponse({
// status: 200,
// description: "",
// type: SearchResponse, // 반환 모델을 지정
// })
// @ApiResponse({ status: 404, description: "해당 장소 검색 실패" })
// async jhPlaceSearch(
// @Query("query") query: string,
// ): Promise<void> {
// try {
// const searchResult = await this.placesService.findSimplePlacesInfo(query);
// return searchResult;
// } catch (error) {
// }
// }
/** -------------------- */

/** 장소 검색하기
Expand All @@ -91,6 +83,9 @@ export class PlacesController {
type: SearchResponse,
})
@ApiResponse({ status: 404, description: "해당 장소 검색 실패" })
@ApiQuery({ name: 'query', required: true, example: '코엑스' })
@ApiQuery({ name: 'x', required: true, example: 127.0588278439012 })
@ApiQuery({ name: 'y', required: true, example: 37.51266138067201 })
@Get("/search")
async getPlaceSearch(
@Query("query") query: string,
Expand All @@ -107,9 +102,7 @@ export class PlacesController {
yCoordinate,
query
);

return searchResult;
// res.status(HttpStatus.OK).json(searchResult);
} catch (error) {
}
}
Expand Down Expand Up @@ -162,7 +155,7 @@ export class PlacesController {
@ApiResponse({
status: 200,
description: "",
type: PlaceWithPostsResponse,
type: [PlaceWithPostsResponse],
})
async getPlacePosts(@Param("id", ParseIntPipe) placeId: number) {
try {
Expand All @@ -187,9 +180,11 @@ export class PlacesController {
})
@ApiResponse({
status: 200,
type: SearchResponse,
type: [SearchResponse],
})
@ApiResponse({ status: 404, description: "해당 장소 검색 실패" })
@ApiQuery({ name: 'x', required: true, example: 127.0588278439012 })
@ApiQuery({ name: 'y', required: true, example: 37.51266138067201 })
@Get("/current-xy")
async findPlacesWithXY(
@Query("x") xCoordinate: number,
Expand Down
58 changes: 28 additions & 30 deletions src/places/responses/place.landmarks.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,34 @@

import { ApiProperty } from '@nestjs/swagger';

export class Post {
@ApiProperty()
post_id: number;

class Post {
@ApiProperty()
post_id: number;

@ApiProperty()
post_created_at: string;

@ApiProperty()
post_updated_at: string;

@ApiProperty()
post_description: string;

@ApiProperty()
post_image_url: string;

@ApiProperty()
post_author_id: number;

@ApiProperty()
post_star_rating: number;

@ApiProperty()
post_place_id: number;

@ApiProperty()
post_is_deleted: boolean;
}
@ApiProperty()
post_created_at: string;

@ApiProperty()
post_updated_at: string;

@ApiProperty()
post_description: string;

@ApiProperty()
post_image_url: string;

@ApiProperty()
post_author_id: number;

@ApiProperty({ type: Number })
post_star_rating: number;

@ApiProperty({ type: Number })
post_place_id: number;

@ApiProperty()
post_is_deleted: boolean;
}

export class landmarksResponse {
@ApiProperty()
Expand Down Expand Up @@ -64,6 +63,5 @@ export class landmarksResponse {
place_longitude: number;

@ApiProperty()
place_posts: Post;

place_posts: Post[];
}

0 comments on commit 0240ebf

Please sign in to comment.