-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday58_openapi.yaml
More file actions
511 lines (489 loc) · 13.3 KB
/
day58_openapi.yaml
File metadata and controls
511 lines (489 loc) · 13.3 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
openapi: 3.0.3
info:
title: Sonpo App API (Day58 Minimal)
version: "0.1.0"
description: >
Day58で作成した「最小API案(Policy/Accident)」のOpenAPI仕様。
失敗時レスポンスは共通で ApiError(code/message/traceId) を返す。
servers:
- url: http://localhost:8080
description: Local development server
tags:
- name: Policy
description: 契約(Policy)
- name: Accident
description: 事故(Accident)
paths:
/api/policies:
get:
tags: [Policy]
summary: Policy一覧取得
description: 契約の一覧を取得する(任意でstatus/qで絞り込み)
parameters:
- in: query
name: status
schema:
type: string
description: 例) ACTIVE
- in: query
name: q
schema:
type: string
description: 契約番号/契約者名の部分一致想定
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Policy"
examples:
sample:
value:
- id: 123
policyNumber: P-0001
customerName: 山田 太郎
startDate: "2026-01-01"
endDate: "2026-12-31"
status: ACTIVE
"400":
$ref: "#/components/responses/ValidationError"
"500":
$ref: "#/components/responses/SystemError"
post:
tags: [Policy]
summary: Policy新規作成
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PolicyCreateRequest"
examples:
sample:
value:
policyNumber: P-0002
customerName: 佐藤 花子
startDate: "2026-02-01"
endDate: "2027-01-31"
status: ACTIVE
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/Policy"
examples:
sample:
value:
id: 124
policyNumber: P-0002
customerName: 佐藤 花子
startDate: "2026-02-01"
endDate: "2027-01-31"
status: ACTIVE
"400":
$ref: "#/components/responses/ValidationError"
"409":
$ref: "#/components/responses/ConflictError"
"500":
$ref: "#/components/responses/SystemError"
/api/policies/{id}:
get:
tags: [Policy]
summary: Policy詳細取得
parameters:
- in: path
name: id
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Policy"
examples:
sample:
value:
id: 123
policyNumber: P-0001
customerName: 山田 太郎
startDate: "2026-01-01"
endDate: "2026-12-31"
status: ACTIVE
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/SystemError"
/api/policies/{id}/renew:
post:
tags: [Policy]
summary: Policy更新操作(renew)
description: 満期更新の例。newEndDateで満期日を更新する想定。
parameters:
- in: path
name: id
required: true
schema:
type: integer
format: int64
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PolicyRenewRequest"
examples:
sample:
value:
newEndDate: "2027-12-31"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/PolicyRenewResponse"
examples:
sample:
value:
id: 123
status: ACTIVE
endDate: "2027-12-31"
"400":
$ref: "#/components/responses/ValidationError"
"404":
$ref: "#/components/responses/NotFoundError"
"409":
$ref: "#/components/responses/ConflictError"
"500":
$ref: "#/components/responses/SystemError"
/api/accidents:
get:
tags: [Accident]
summary: Accident一覧取得
parameters:
- in: query
name: policyId
schema:
type: integer
format: int64
description: 契約IDで絞り込み
- in: query
name: status
schema:
type: string
description: 例) OPEN / IN_PROGRESS / RESOLVED
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Accident"
examples:
sample:
value:
- id: 501
policyId: 123
occurredAt: "2026-01-10T10:30:00"
status: OPEN
"400":
$ref: "#/components/responses/ValidationError"
"500":
$ref: "#/components/responses/SystemError"
post:
tags: [Accident]
summary: Accident新規作成
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/AccidentCreateRequest"
examples:
sample:
value:
policyId: 123
occurredAt: "2026-01-10T10:30:00"
place: 熊本市
description: 追突事故
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: "#/components/schemas/Accident"
examples:
sample:
value:
id: 502
policyId: 123
occurredAt: "2026-01-10T10:30:00"
place: 熊本市
description: 追突事故
status: OPEN
"400":
$ref: "#/components/responses/ValidationError"
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/SystemError"
/api/accidents/{id}:
get:
tags: [Accident]
summary: Accident詳細取得
parameters:
- in: path
name: id
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Accident"
examples:
sample:
value:
id: 501
policyId: 123
occurredAt: "2026-01-10T10:30:00"
place: 熊本市
description: 追突事故
status: OPEN
"404":
$ref: "#/components/responses/NotFoundError"
"500":
$ref: "#/components/responses/SystemError"
/api/accidents/{id}/start:
post:
tags: [Accident]
summary: 状態遷移(OPEN→IN_PROGRESS)
parameters:
- in: path
name: id
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/AccidentStatusResponse"
examples:
sample:
value:
id: 501
status: IN_PROGRESS
"404":
$ref: "#/components/responses/NotFoundError"
"409":
$ref: "#/components/responses/ConflictError"
"500":
$ref: "#/components/responses/SystemError"
/api/accidents/{id}/resolve:
post:
tags: [Accident]
summary: 状態遷移(IN_PROGRESS→RESOLVED)
parameters:
- in: path
name: id
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/AccidentStatusResponse"
examples:
sample:
value:
id: 501
status: RESOLVED
"404":
$ref: "#/components/responses/NotFoundError"
"409":
$ref: "#/components/responses/ConflictError"
"500":
$ref: "#/components/responses/SystemError"
components:
schemas:
Policy:
type: object
required: [id, policyNumber, customerName, startDate, endDate, status]
properties:
id:
type: integer
format: int64
policyNumber:
type: string
customerName:
type: string
startDate:
type: string
format: date
endDate:
type: string
format: date
status:
type: string
PolicyCreateRequest:
type: object
required: [policyNumber, customerName, startDate, endDate, status]
properties:
policyNumber:
type: string
customerName:
type: string
startDate:
type: string
format: date
endDate:
type: string
format: date
status:
type: string
PolicyRenewRequest:
type: object
required: [newEndDate]
properties:
newEndDate:
type: string
format: date
PolicyRenewResponse:
type: object
required: [id, status, endDate]
properties:
id:
type: integer
format: int64
status:
type: string
endDate:
type: string
format: date
Accident:
type: object
required: [id, policyId, occurredAt, status]
properties:
id:
type: integer
format: int64
policyId:
type: integer
format: int64
occurredAt:
type: string
format: date-time
place:
type: string
nullable: true
description:
type: string
nullable: true
status:
type: string
AccidentCreateRequest:
type: object
required: [policyId, occurredAt]
properties:
policyId:
type: integer
format: int64
occurredAt:
type: string
format: date-time
place:
type: string
description:
type: string
AccidentStatusResponse:
type: object
required: [id, status]
properties:
id:
type: integer
format: int64
status:
type: string
ApiError:
type: object
required: [code, message, traceId]
properties:
code:
type: string
message:
type: string
traceId:
type: string
responses:
ValidationError:
description: Bad Request(入力不正)
content:
application/json:
schema:
$ref: "#/components/schemas/ApiError"
examples:
sample:
value:
code: VALIDATION_ERROR
message: 入力値が不正です
traceId: a1b2c3d4
NotFoundError:
description: Not Found(対象なし)
content:
application/json:
schema:
$ref: "#/components/schemas/ApiError"
examples:
sample:
value:
code: NOT_FOUND
message: 対象が見つかりません
traceId: a1b2c3d4
ConflictError:
description: Conflict(状態不整合/競合)
content:
application/json:
schema:
$ref: "#/components/schemas/ApiError"
examples:
sample:
value:
code: CONFLICT
message: 状態が不正のため処理できません
traceId: a1b2c3d4
SystemError:
description: Internal Server Error(想定外)
content:
application/json:
schema:
$ref: "#/components/schemas/ApiError"
examples:
sample:
value:
code: SYSTEM_ERROR
message: 予期しないエラーが発生しました
traceId: a1b2c3d4