Skip to content

Commit

Permalink
Merge pull request #125 from kitcc-org/124-add-id-search-res
Browse files Browse the repository at this point in the history
GET /boos/searchのレスポンスにidを追加した
  • Loading branch information
kimurash authored Nov 9, 2024
2 parents 45c6247 + 555c3b4 commit c659244
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion api/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ paths:
items:
type: object
properties:
id:
type: string
title:
type: string
authors:
Expand All @@ -428,6 +430,7 @@ paths:
isbn:
type: string
required:
- id
- title
- authors
required:
Expand All @@ -436,7 +439,8 @@ paths:
example:
totalBook: 30
books:
- title: 計算機プログラムの構造と解釈
- id: 5-OgzgEACAAJ
title: 計算機プログラムの構造と解釈
authors:
- Harold Abelson
- Gerald Jay Sussman
Expand Down
6 changes: 5 additions & 1 deletion api/paths/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ search:
items:
type: object
properties:
id:
type: string
title:
type: string
authors:
Expand All @@ -415,6 +417,7 @@ search:
isbn:
type: string
required:
- id
- title
- authors
required:
Expand All @@ -423,7 +426,8 @@ search:
example:
totalBook: 30
books:
- title: '計算機プログラムの構造と解釈'
- id: 5-OgzgEACAAJ
title: '計算機プログラムの構造と解釈'
authors:
- 'Harold Abelson'
- 'Gerald Jay Sussman'
Expand Down
3 changes: 3 additions & 0 deletions backend/src/api/book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface GoogleBookVolume {
totalItems: number;
items?: [
{
id: string;
volumeInfo: {
title: string;
authors?: string[];
Expand Down Expand Up @@ -59,6 +60,7 @@ interface GoogleApiError {

// GET /search のレスポンス
interface GoogleBook {
id: string;
title: string;
authors: string[];
publisher: string;
Expand Down Expand Up @@ -140,6 +142,7 @@ app.get(

// 書籍を配列に追加する
hitBooks.push({
id: item.id,
title: book.title,
authors: book.authors ?? [],
publisher: book.publisher ?? '',
Expand Down
1 change: 1 addition & 0 deletions backend/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export const searchBooksQueryParams = zod.object({
export const searchBooksResponse = zod.object({
"totalBook": zod.number(),
"books": zod.array(zod.object({
"id": zod.string(),
"title": zod.string(),
"authors": zod.array(zod.string()),
"publisher": zod.string().optional(),
Expand Down
1 change: 1 addition & 0 deletions frontend/client/client.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ email?: string;
export type SearchBooks200BooksItem = {
authors: string[];
description?: string;
id: string;
isbn?: string;
publishedDate?: string;
publisher?: string;
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/mocks/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ export const getGetBookResponseMock = (): Book => ({"id":1,"title":"計算機プ

export const getUpdateBookResponseMock = (): Book => ({"id":1,"title":"計算機プログラムの構造と解釈","authors":["Harold Abelson","Gerald Jay Sussman","Julie Sussman"],"publisher":"翔泳社","publishedDate":"2012-07-06","description":"言わずと知れた計算機科学の古典的名著","thumbnail":"http://books.google.com/books/content?id=LlH-oAEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api","isbn":"9784798135984","stock":1})

export const getSearchBooksResponseMock = (): SearchBooks200 => ({"totalBook":30,"books":[{"title":"計算機プログラムの構造と解釈","authors":["Harold Abelson","Gerald Jay Sussman","Julie Sussman"],"publisher":"翔泳社","publishedDate":"2018-07-01","description":"言わずと知れた計算機科学の古典的名著","thumbnail":"http://books.google.com/books/content?id=LlH-oAEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api","isbn":"9784798135984"}]})
export const getSearchBooksResponseMock = (): SearchBooks200 => ({"totalBook":30,"books":[{"id":"5-OgzgEACAAJ","title":"計算機プログラムの構造と解釈","authors":["Harold Abelson","Gerald Jay Sussman","Julie Sussman"],"publisher":"翔泳社","publishedDate":"2018-07-01","description":"言わずと知れた計算機科学の古典的名著","thumbnail":"http://books.google.com/books/content?id=LlH-oAEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api","isbn":"9784798135984"}]})

export const getGetUsersResponseMock = (overrideResponse: Partial< GetUsers200 > = {}): GetUsers200 => ({totalUser: faker.number.int({min: undefined, max: undefined}), users: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({email: faker.internet.email(), id: faker.number.int({min: undefined, max: undefined}), name: faker.word.sample(), sessionToken: faker.helpers.arrayElement([faker.helpers.arrayElement([faker.word.sample(), null]), undefined])})), ...overrideResponse})

Expand Down
1 change: 1 addition & 0 deletions frontend/test/mocks/model/searchBooks200BooksItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export type SearchBooks200BooksItem = {
authors: string[];
description?: string;
id: string;
isbn?: string;
publishedDate?: string;
publisher?: string;
Expand Down

0 comments on commit c659244

Please sign in to comment.