-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
176 lines (175 loc) · 5.98 KB
/
openapi.yaml
File metadata and controls
176 lines (175 loc) · 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
openapi: 3.0.3
# APIの基本情報
info:
title: "My AR Project API" # APIのタイトル
version: "1.0.0" # APIのバージョン
servers:
- url: http://localhost:8080
description: ローカル開発用サーバ
- url: http://app:8080
description: Docker内部用サーバ
# APIのエンドポイント(パス)を列挙するセクション
paths:
/fireworks:
get:
summary: "花火の一覧を取得する" # APIの簡単な説明
operationId: "GetFireworks" # この操作の一意なID。コード生成時にメソッド名になる
responses: # レスポンスの定義
# '200' (成功) ステータスコードの時のレスポンス
'200':
description: "花火の一覧" # レスポンスの説明
content: # レスポンスボディの定義
application/json: # メディアタイプがJSONの場合
schema: # ボディのデータ構造(スキーマ)
type: array # データは配列
items: # 配列の各要素の型
$ref: "#/components/schemas/FireworkResponse" # 下で定義するFireworkスキーマを参照
post:
summary: "花火を作成する"
operationId: "CreateFirework"
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/FireworkCreateRequest" # FireworkCreateRequestスキーマを参照
responses:
'201': # 作成成功時のステータスコード
description: "花火が作成されました"
content:
application/json:
schema:
$ref: "#/components/schemas/FireworkResponse"
/fireworks/{id}:
get:
summary: "IDで指定した花火を取得"
operationId: "GetFireworkById"
parameters:
- name: id
in: path
required: true # このパラメータは必須
description: "花火のID"
schema:
type: integer
format: int64
responses:
'200':
description: "花火の詳細"
content:
application/json:
schema:
$ref: "#/components/schemas/FireworkResponse"
put:
summary: "IDで指定した花火の共有設定を更新"
operationId: "UpdateFirework"
parameters:
- name: id
in: path
required: true
description: "花火のID"
schema:
type: integer
format: int64
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/FireworkUpdateRequest" # FireworkUpdateRequestスキーマを参照
responses:
'200':
description: "花火が更新されました"
content:
application/json:
schema:
$ref: "#/components/schemas/FireworkResponse"
delete:
summary: "IDで指定した花火を削除"
operationId: "DeleteFirework"
parameters:
- name: id
in: path
required: true
description: "花火のID"
schema:
type: integer
format: int64
responses:
'204':
description: "花火が削除されました" # 削除成功時は204 No Contentを返す
content: {} # レスポンスボディはなし
# 再利用可能なコンポーネントを定義するセクション
components:
schemas:
FireworkCreateRequest:
type: object
description: "花火を作成するためのリクエストボディ"
required: # 必須フィールド
- isShareable
- image # pixelDataの元となる画像
properties:
isShareable:
type: boolean
description: "花火が共有可能かどうか"
example: false
image:
type: string
format: binary
description: "花火の元となる画像ファイル"
example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
FireworkUpdateRequest:
type: object
description: "花火を更新するためのリクエストボディ"
required:
- isShareable
properties:
isShareable:
type: boolean
description: "花火が共有可能かどうか"
example: true
# image:
# type: string
# format: binary
# description: "花火の元となる画像ファイル"
# example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
FireworkResponse:
type: object
description: "花火のレスポンスデータ"
required:
- id
- isShareable
- pixelData
properties:
id:
type: integer
format: int64
description: "花火のID"
example: 1
isShareable:
type: boolean
description: "花火が共有可能かどうか"
default: false
example: true
pixelData:
type: array
description: "花火のピクセルデータ"
example: [true, false, true, false, true]
items:
type: boolean
description: "各ピクセルの状態(点灯/消灯)"
# type: integer
# format: int32
# example: 0
createdAt:
type: string
format: date-time
description: "花火の作成日時"
example: "2023-10-01T12:00:00Z"
updatedAt:
type: string
format: date-time
description: "花火の更新日時"
example: "2023-10-01T12:00:00Z"
# tags:
# - name: "Fireworks" # タグの名前。APIの分類に使える
# description: "花火に関する操作" # タグの説明