Skip to content

Commit

Permalink
Define loan API (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
shunsei committed Sep 30, 2024
1 parent 3f4a7dd commit 9b8d753
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 3 deletions.
16 changes: 16 additions & 0 deletions api/components/schemas/loan.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
76 changes: 76 additions & 0 deletions api/paths/loan.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 9b8d753

Please sign in to comment.