Skip to content

Commit aa2e98d

Browse files
committed
feat: swagger에서 1줄 요약 표시
1 parent c95d0de commit aa2e98d

File tree

6 files changed

+87
-16
lines changed

6 files changed

+87
-16
lines changed

contracts/src/books/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const bookMetasContracts = c.router(
2222
method: 'GET',
2323
path: '/info/:id',
2424
pathParams: searchBookInfoByIdPathSchema,
25-
description: '도서 정보를 조회합니다.',
25+
summary: '도서 정보를 조회합니다.',
2626
responses: {
2727
200: searchBookInfoByIdResponseSchema,
2828
404: bookInfoNotFoundSchema,
@@ -37,7 +37,7 @@ export const booksContract = c.router(
3737
getById: {
3838
method: 'GET',
3939
path: '/:id',
40-
description: 'book테이블의 ID기준으로 책 한 종류의 정보를 가져온다.',
40+
summary: 'book테이블의 ID기준으로 책 한 종류의 정보를 가져온다.',
4141
pathParams: searchBookByIdParamSchema,
4242
responses: {
4343
200: searchBookByIdResponseSchema,
@@ -47,7 +47,7 @@ export const booksContract = c.router(
4747
get: {
4848
method: 'GET',
4949
path: '/',
50-
description: '개별 책 정보(book)를 검색하여 가져온다. 책이 대출할 수 있는지 확인 할 수 있음',
50+
summary: '개별 책 정보(book)를 검색하여 가져온다. 책이 대출할 수 있는지 확인 할 수 있음',
5151
query: searchAllBooksQuerySchema,
5252
responses: {
5353
200: searchAllBooksResponseSchema,
@@ -57,7 +57,7 @@ export const booksContract = c.router(
5757
patch: {
5858
method: 'PATCH',
5959
path: '/update',
60-
description: '책 정보 하나를 수정합니다.',
60+
summary: '책 정보 하나를 수정합니다.',
6161
body: updateBookBodySchema,
6262
responses: {
6363
204: updateBookResponseSchema,

contracts/src/books/mod.ts

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { initContract } from '@ts-rest/core';
2+
import {
3+
searchAllBooksQuerySchema,
4+
searchAllBooksResponseSchema,
5+
searchBookByIdResponseSchema,
6+
pubdateFormatErrorSchema,
7+
updateBookBodySchema,
8+
updateBookResponseSchema,
9+
unknownPatchErrorSchema,
10+
nonDataErrorSchema,
11+
searchBookInfoByIdResponseSchema,
12+
searchBookInfoByIdPathSchema,
13+
searchBookByIdParamSchema,
14+
} from './schema';
15+
import { badRequestSchema, bookInfoNotFoundSchema, bookNotFoundSchema } from '../shared';
16+
17+
const c = initContract();
18+
19+
export const bookMetasContracts = c.router(
20+
{
21+
getById: {
22+
method: 'GET',
23+
path: '/info/:id',
24+
pathParams: searchBookInfoByIdPathSchema,
25+
summary: '도서 정보를 조회합니다.',
26+
responses: {
27+
200: searchBookInfoByIdResponseSchema,
28+
404: bookInfoNotFoundSchema,
29+
},
30+
},
31+
},
32+
{ pathPrefix: '/bookmetas' },
33+
);
34+
35+
export const booksContract = c.router(
36+
{
37+
getById: {
38+
method: 'GET',
39+
path: '/:id',
40+
summary: 'book테이블의 ID기준으로 책 한 종류의 정보를 가져온다.',
41+
pathParams: searchBookByIdParamSchema,
42+
responses: {
43+
200: searchBookByIdResponseSchema,
44+
404: bookNotFoundSchema,
45+
},
46+
},
47+
get: {
48+
method: 'GET',
49+
path: '/',
50+
summary: '개별 책 정보(book)를 검색하여 가져온다. 책이 대출할 수 있는지 확인 할 수 있음',
51+
query: searchAllBooksQuerySchema,
52+
responses: {
53+
200: searchAllBooksResponseSchema,
54+
400: badRequestSchema,
55+
},
56+
},
57+
patch: {
58+
method: 'PATCH',
59+
path: '/update',
60+
summary: '책 정보 하나를 수정합니다.',
61+
body: updateBookBodySchema,
62+
responses: {
63+
204: updateBookResponseSchema,
64+
312: unknownPatchErrorSchema,
65+
313: nonDataErrorSchema,
66+
311: pubdateFormatErrorSchema,
67+
},
68+
},
69+
},
70+
{ pathPrefix: '/books' },
71+
);

contracts/src/lendings/mod.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const lendingsContract = c.router({
1515
getMine: {
1616
method: 'GET',
1717
path: '/mypage/lendings',
18-
description: '내 대출 기록을 가져옵니다.',
18+
summary: '내 대출 기록을 가져옵니다.',
1919
query: historiesGetMyQuerySchema,
2020
responses: {
2121
200: historiesGetResponseSchema,
@@ -25,7 +25,7 @@ export const lendingsContract = c.router({
2525
get: {
2626
method: 'GET',
2727
path: '/lendings',
28-
description: '사서가 전체 대출 기록을 가져옵니다.',
28+
summary: '사서가 전체 대출 기록을 가져옵니다.',
2929
query: historiesGetQuerySchema,
3030
responses: {
3131
200: historiesGetResponseSchema,

contracts/src/likes/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const likesContract = c.router(
1010
post: {
1111
method: 'POST',
1212
path: '/:bookInfoId/like',
13-
description: '책에 좋아요를 누릅니다.',
13+
summary: '책에 좋아요를 누릅니다.',
1414
pathParams: z.object({ bookInfoId: bookInfoIdSchema }),
1515
body: null,
1616
responses: {
@@ -24,7 +24,7 @@ export const likesContract = c.router(
2424
method: 'GET',
2525
path: '/:bookInfoId/like',
2626
summary: 'Like 정보를 가져온다.',
27-
description: '사용자가 좋아요 버튼을 누르면 좋아요 개수를 가져온다.',
27+
summary: '사용자가 좋아요 버튼을 누르면 좋아요 개수를 가져온다.',
2828
pathParams: z.object({ bookInfoId: bookInfoIdSchema }),
2929
responses: {
3030
200: likeResponseSchema,
@@ -34,7 +34,7 @@ export const likesContract = c.router(
3434
delete: {
3535
method: 'DELETE',
3636
path: '/:bookInfoId/like',
37-
description: 'delete a like',
37+
summary: 'delete a like',
3838
pathParams: z.object({ bookInfoId: bookInfoIdSchema }),
3939
body: null,
4040
responses: {

contracts/src/reviews/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ export const reviewsContract = c.router(
3030
search: z.string().optional().describe('도서 제목 또는 리뷰 작성자 닉네임'),
3131
visibility,
3232
}),
33-
description: '전체 도서 리뷰 목록을 조회합니다.',
33+
summary: '전체 도서 리뷰 목록을 조회합니다.',
3434
responses: {
3535
200: metaPaginatedSchema(reviewSchema),
3636
},
3737
},
3838
post: {
3939
method: 'POST',
4040
path: '/',
41-
query: z.object({ bookInfoId: bookInfoIdSchema.openapi({ description: '도서 ID' }) }),
42-
description: '책 리뷰를 작성합니다.',
41+
query: z.object({ bookInfoId: bookInfoIdSchema.openapi({ summary: '도서 ID' }) }),
42+
summary: '책 리뷰를 작성합니다.',
4343
body: contentSchema,
4444
responses: {
4545
201: z.literal('리뷰가 작성되었습니다.'),
@@ -50,7 +50,7 @@ export const reviewsContract = c.router(
5050
method: 'PATCH',
5151
path: '/:reviewsId',
5252
pathParams: reviewIdPathSchema,
53-
description: '책 리뷰의 비활성화 여부를 토글 방식으로 변환합니다.',
53+
summary: '책 리뷰의 비활성화 여부를 토글 방식으로 변환합니다.',
5454
body: null,
5555
responses: {
5656
200: z.literal('리뷰 공개 여부가 업데이트되었습니다.'),

contracts/src/users/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const usersContract = c.router(
1818
get: {
1919
method: 'GET',
2020
path: '/',
21-
description: '유저 정보를 검색해 온다. query가 null이면 모든 유저를 검색한다.',
21+
summary: '유저 정보를 검색해 온다. query가 null이면 모든 유저를 검색한다.',
2222
query: searchUserSchema,
2323
responses: {
2424
200: searchUserResponseSchema,
@@ -28,7 +28,7 @@ export const usersContract = c.router(
2828
post: {
2929
method: 'POST',
3030
path: '/',
31-
description: '유저를 생성한다.',
31+
summary: '유저를 생성한다.',
3232
body: createUserSchema,
3333
responses: {
3434
201: createUserResponseSchema,
@@ -38,7 +38,7 @@ export const usersContract = c.router(
3838
patch: {
3939
method: 'PATCH',
4040
path: '/:id',
41-
description: '유저 정보를 변경한다.',
41+
summary: '유저 정보를 변경한다.',
4242
pathParams: userIdSchema,
4343
body: updateUserSchema,
4444
responses: {

0 commit comments

Comments
 (0)