From 9b8d753f4048b5d026ce3baade89ffd492672a32 Mon Sep 17 00:00:00 2001 From: shunsei Date: Tue, 1 Oct 2024 03:28:56 +0900 Subject: [PATCH] Define loan API (#4) --- api/components/schemas/loan.yml | 16 +++++++ api/openapi.yml | 6 +-- api/paths/loan.yml | 76 +++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 api/components/schemas/loan.yml create mode 100644 api/paths/loan.yml diff --git a/api/components/schemas/loan.yml b/api/components/schemas/loan.yml new file mode 100644 index 00000000..48ae623e --- /dev/null +++ b/api/components/schemas/loan.yml @@ -0,0 +1,16 @@ +type: object +properties: + id: + type: integer + userId: + type: integer + bookId: + type: integer + volume: + type: integer + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time diff --git a/api/openapi.yml b/api/openapi.yml index 5014c18b..e88d8002 100644 --- a/api/openapi.yml +++ b/api/openapi.yml @@ -34,9 +34,9 @@ paths: /users/{userId}: $ref: "paths/user.yml#/user" - # /loans: - # /loans/{loanId}: - + /loans: + $ref: "./paths/loan.yml#/loans" + /login: $ref: "./paths/auth.yml#/login" /logout: diff --git a/api/paths/loan.yml b/api/paths/loan.yml new file mode 100644 index 00000000..d9b43bf5 --- /dev/null +++ b/api/paths/loan.yml @@ -0,0 +1,76 @@ +loans: + get: + tags: + - loan + operationId: getLoans + summary: 貸出履歴を取得する + description: 指定された条件に合致する貸出履歴を返す + security: + - BasicAuth: [] + parameters: + - name: userId + in: query + description: 貸出履歴を取得するユーザーのID + required: false + schema: + type: integer + - name: bookId + in: query + description: 貸出履歴を取得する書籍のID + required: false + schema: + type: integer + - name: page + in: query + description: ページ番号 + required: false + schema: + type: integer + minimum: 1 + default: 1 + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: "../components/schemas/loan.yml" + '401': + $ref: "../components/responses/4xx.yml#/Unauthorized" + '500': + $ref: "../components/responses/5xx.yml#/InternalServerError" + + put: + tags: + - loan + operationId: updateLoans + summary: 貸出履歴を更新する + description: 指定された貸出履歴の情報を更新する + security: + - BasicAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + $ref: "../components/schemas/loan.yml" + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: "../components/schemas/response.yml" + example: + code: 200 + message: "OK" + '400': + $ref: "../components/responses/4xx.yml#/BadRequest" + '401': + $ref: "../components/responses/4xx.yml#/Unauthorized" + '500': + $ref: "../components/responses/5xx.yml#/InternalServerError"