Skip to content

Commit

Permalink
Add api README
Browse files Browse the repository at this point in the history
  • Loading branch information
shunsei committed Sep 30, 2024
1 parent 9b8d753 commit c6e3fec
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
24 changes: 24 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## ディレクトリ構造
```
api
├── bundle.yml ... APIに仕様を1つにまとめたYAMLファイル
├── components ... 使い回すために部品化された仕様
│   ├── examples
│   ├── responses
│   └── schemas
├── openapi.yml ... エントリーポイント
├── paths ... 利用可能なエンドポイントとメソッド
└── redocly.yml ... redocly-cliの設定ファイル
```

## CLI

バリデーション
```
$ npm run lint
```

APIの仕様を1つのYAMLファイルにまとめる
```
$ npm run bundle
```
101 changes: 101 additions & 0 deletions api/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,81 @@ paths:
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/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'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
put:
tags:
- loan
operationId: updateLoans
summary: 貸出履歴を更新する
description: 指定された貸出履歴の情報を更新する
security:
- BasicAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/loan'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/response-2'
example:
code: 200
message: OK
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
/login:
post:
tags:
Expand Down Expand Up @@ -547,6 +622,23 @@ components:
- name
- email
- password
loan:
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
responses:
InternalServerError:
description: サーバ内部でエラーが発生した
Expand Down Expand Up @@ -575,6 +667,15 @@ components:
example:
code: 404
message: Not Found
BadRequest:
description: リクエストの構文が誤っている
content:
application/json:
schema:
$ref: '#/components/schemas/response-2'
example:
code: 400
message: Bad Request
examples:
request:
value:
Expand Down

0 comments on commit c6e3fec

Please sign in to comment.