From 0adb9f1266b14b3e68681dbce3ad286996d55dd8 Mon Sep 17 00:00:00 2001 From: shunsei Date: Sat, 9 Nov 2024 14:41:21 +0900 Subject: [PATCH 1/3] Add id to GET /books/search response specification (#124) --- api/bundle.yml | 6 +++++- api/paths/book.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/bundle.yml b/api/bundle.yml index d2ca2426..acb157c0 100644 --- a/api/bundle.yml +++ b/api/bundle.yml @@ -411,6 +411,8 @@ paths: items: type: object properties: + id: + type: string title: type: string authors: @@ -428,6 +430,7 @@ paths: isbn: type: string required: + - id - title - authors required: @@ -436,7 +439,8 @@ paths: example: totalBook: 30 books: - - title: 計算機プログラムの構造と解釈 + - id: 5-OgzgEACAAJ + title: 計算機プログラムの構造と解釈 authors: - Harold Abelson - Gerald Jay Sussman diff --git a/api/paths/book.yml b/api/paths/book.yml index 1a03c71f..20a7df59 100644 --- a/api/paths/book.yml +++ b/api/paths/book.yml @@ -398,6 +398,8 @@ search: items: type: object properties: + id: + type: string title: type: string authors: @@ -415,6 +417,7 @@ search: isbn: type: string required: + - id - title - authors required: @@ -423,7 +426,8 @@ search: example: totalBook: 30 books: - - title: '計算機プログラムの構造と解釈' + - id: 5-OgzgEACAAJ + title: '計算機プログラムの構造と解釈' authors: - 'Harold Abelson' - 'Gerald Jay Sussman' From 971dedf4074460b1567c24bb5d0a45f18c328674 Mon Sep 17 00:00:00 2001 From: shunsei Date: Sat, 9 Nov 2024 14:41:39 +0900 Subject: [PATCH 2/3] Regenerate orval (#124) --- backend/src/schema.ts | 1 + frontend/client/client.schemas.ts | 1 + frontend/test/mocks/mock.ts | 2 +- frontend/test/mocks/model/searchBooks200BooksItem.ts | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/schema.ts b/backend/src/schema.ts index 004e109b..160d4e86 100644 --- a/backend/src/schema.ts +++ b/backend/src/schema.ts @@ -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(), diff --git a/frontend/client/client.schemas.ts b/frontend/client/client.schemas.ts index 209d50fd..3c22ed03 100644 --- a/frontend/client/client.schemas.ts +++ b/frontend/client/client.schemas.ts @@ -137,6 +137,7 @@ email?: string; export type SearchBooks200BooksItem = { authors: string[]; description?: string; + id: string; isbn?: string; publishedDate?: string; publisher?: string; diff --git a/frontend/test/mocks/mock.ts b/frontend/test/mocks/mock.ts index 8f69f373..e66468da 100644 --- a/frontend/test/mocks/mock.ts +++ b/frontend/test/mocks/mock.ts @@ -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}) diff --git a/frontend/test/mocks/model/searchBooks200BooksItem.ts b/frontend/test/mocks/model/searchBooks200BooksItem.ts index 5b297ac3..4f0ec976 100644 --- a/frontend/test/mocks/model/searchBooks200BooksItem.ts +++ b/frontend/test/mocks/model/searchBooks200BooksItem.ts @@ -8,6 +8,7 @@ export type SearchBooks200BooksItem = { authors: string[]; description?: string; + id: string; isbn?: string; publishedDate?: string; publisher?: string; From 555c3b46e62e340e17893522987a256b3e0b5210 Mon Sep 17 00:00:00 2001 From: shunsei Date: Sat, 9 Nov 2024 14:42:04 +0900 Subject: [PATCH 3/3] Add id to GET /books/search response implementation (#124) --- backend/src/api/book.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/api/book.ts b/backend/src/api/book.ts index b3e4cfb6..07675912 100644 --- a/backend/src/api/book.ts +++ b/backend/src/api/book.ts @@ -27,6 +27,7 @@ interface GoogleBookVolume { totalItems: number; items?: [ { + id: string; volumeInfo: { title: string; authors?: string[]; @@ -59,6 +60,7 @@ interface GoogleApiError { // GET /search のレスポンス interface GoogleBook { + id: string; title: string; authors: string[]; publisher: string; @@ -140,6 +142,7 @@ app.get( // 書籍を配列に追加する hitBooks.push({ + id: item.id, title: book.title, authors: book.authors ?? [], publisher: book.publisher ?? '',