API を変えて取り込み直す
API の設計は途中で何度も変わります。YAML を直して取り込み直すと、設計書がどう追従するかを確かめます。次の 3 つの変更を入れます。
| 変更 | 対象 | 設計書で起きること |
|---|---|---|
| パラメータを足す | listTasks に priority |
パラメータの表の行が 1 行増える |
| API を足す | addComment(コメント追加) |
シートが 1 枚増える |
| API を消す | getHealth(死活監視) |
シートは残り、目次で「廃止」になる |
前の節を終えていない人は、ここから始められます。
YAML を直す
Section titled “YAML を直す”前の節で使った openapi.yaml をエディタ(メモ帳でも可)で開き、次の 3 か所を直します。手で直すのが面倒なら、変更済みの YAML を下からダウンロードして差し替えても構いません。
openapi.yaml を変更する
Section titled “openapi.yaml を変更する”178178 type: array179179 items:180180 $ref: '#/components/schemas/TaskStatus'181- name: priority182 in: query183 description: 優先度で絞り込む184 schema:185 $ref: '#/components/schemas/Priority'181186- name: assigneeId182187 in: query183188 description: 担当者で絞り込む460465 '404':461466 $ref: '#/components/responses/NotFound'462467
468/tasks/{taskId}/comments:469 parameters:470 - $ref: '#/components/parameters/TaskId'471 post:472 operationId: addComment473 tags: [tasks]474 summary: コメント追加475 x-purpose: タスクにコメントを書き込む。書き込んだコメントは履歴に残る。476 x-permissions:477 - role: member478 condition: 自分が所属するプロジェクトのタスクのみ479 - role: admin480 requestBody:481 required: true482 content:483 application/json:484 schema:485 type: object486 required:487 - body488 properties:489 body:490 type: string491 minLength: 1492 maxLength: 1000493 description: コメント本文494 responses:495 '201':496 description: 追加成功497 content:498 application/json:499 schema:500 $ref: '#/components/schemas/CommentActivity'501 '401':502 $ref: '#/components/responses/Unauthorized'503 '404':504 $ref: '#/components/responses/NotFound'505 '422':506 $ref: '#/components/responses/ValidationFailed'507
463508/tasks/{taskId}/attachments:464509 parameters:465510 - $ref: '#/components/parameters/TaskId'619664 '401':620665 description: 署名が正しくない621666
622 /health:623 get:624 operationId: getHealth625 tags: [system]626 summary: 死活監視627 security: []628 responses:629 '200':630 description: 稼働中631 content:632 application/json:633 schema:634 type: object635 properties:636 status:637 type: string638 enum: [ok]639
640667components:641668 securitySchemes:642669 bearerAuth:listTasksのparametersの中、assigneeIdの前にpriorityを足します- コメント追加の API(
addComment)は、/tasks/{taskId}/attachments:の行の 前 に、パスを 1 つ足します。インデント(行頭の空白)は/tasks/{taskId}/attachments:とそろえます - 死活監視の API は、
/health:から、その下のgetHealthの定義の終わり(components:の直前)までを消します
取り込み直す
Section titled “取り込み直す”詳細設計書.xlsmを開き、「使い方」シートのボタンを押して、直したopenapi.yamlを選びます- 「目次」を開きます
確かめるところは 4 つです。
- 増えた API:目次に
addCommentが増え、シートができている - 変わった API:
listTasksのパラメータの表にpriorityの行が増えている。下の表がその分ずれても崩れていない - 消えた API:
getHealthのシートは消えずに残り、シート見出しが灰色、目次の状態が「廃止」になっている - 処理の内容:前の節で
createTaskに書いた処理の内容が残っている
消えた API のシートを残す理由
Section titled “消えた API のシートを残す理由”YAML から API を消しても、シートは自動では消しません。そのシートの「処理の内容」に、人が書いた内容があるかもしれないからです。内容を確かめ、要らなければシートを手で削除してください。削除したシートは、次の取り込みからは目次にも出ません。
行数が変わっても崩れないしくみ
Section titled “行数が変わっても崩れないしくみ”パラメータやレスポンスの数は API ごとに違い、YAML を直すたびに変わります。そのため設計書は、毎回ひな形のシートから作り直しています。ひな形には「この行を項目の数だけ繰り返す」という目印の行が非表示で入っていて、取り込むときに必要な数だけ行を複製します。目印の詳しい話は「テンプレートの見た目を変える」で扱います。
この節を終えたときのディレクトリ
Section titled “この節を終えたときのディレクトリ”04-change
# Sample API definition.# The goal is to cover many OpenAPI patterns so that both the Excel importer# and the TypeScript generator can be checked against them.openapi: 3.0.3info: title: タスク管理 API version: 1.0.0 description: | 詳細設計書の生成サンプル用の API 定義。 認証は JWT(Bearer トークン)で行う。
- アクセストークンの有効期限は 15 分 - リフレッシュトークンの有効期限は 30 日servers: - url: https://api.example.com/v1 description: 本番 - url: http://localhost:3000/v1 description: ローカルtags: - name: auth description: 認証 - name: tasks description: タスク - name: attachments description: 添付ファイル - name: categories description: カテゴリ - name: system description: システム
# All operations require a JWT unless they override with `security: []`.security: - bearerAuth: []
paths: /auth/login: post: operationId: login tags: [auth] summary: ログイン x-purpose: メールアドレスとパスワードで本人確認し、JWT を発行する。 security: [] x-permissions: - role: 未ログイン condition: 誰でも呼び出せる x-processing: - step: 入力チェック detail: email の形式、password の長さを確認する - step: 認証 detail: パスワードのハッシュを照合する。失敗したら 401 を返す note: 5 回連続で失敗したら 15 分間ロックする - step: トークン発行 detail: アクセストークンとリフレッシュトークンを発行する requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LoginRequest' example: email: taro@example.com password: P@ssw0rd! responses: '200': description: ログイン成功 content: application/json: schema: $ref: '#/components/schemas/TokenPair' '400': $ref: '#/components/responses/BadRequest' '401': description: メールアドレスまたはパスワードが違う content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '423': description: アカウントがロックされている headers: Retry-After: description: ロックが解除されるまでの秒数 schema: type: integer content: application/problem+json: schema: $ref: '#/components/schemas/Problem'
/auth/refresh: post: operationId: refreshToken tags: [auth] summary: トークン再発行 x-purpose: 期限切れのアクセストークンを、リフレッシュトークンで再発行する。 security: [] x-permissions: - role: 未ログイン condition: 有効なリフレッシュトークンを持っていること requestBody: required: true content: application/json: schema: type: object required: - refreshToken properties: refreshToken: type: string description: ログイン時に受け取ったリフレッシュトークン responses: '200': description: 再発行成功 content: application/json: schema: $ref: '#/components/schemas/TokenPair' '401': $ref: '#/components/responses/Unauthorized'
/auth/logout: post: operationId: logout tags: [auth] summary: ログアウト x-purpose: リフレッシュトークンを無効にする。 x-permissions: - role: member - role: admin responses: '204': description: ログアウト成功 '401': $ref: '#/components/responses/Unauthorized'
/me: get: operationId: getMe tags: [auth] summary: ログイン中のユーザー取得 x-purpose: JWT の sub クレームが示すユーザーの情報を返す。 x-permissions: - role: member - role: admin responses: '200': description: 成功 content: application/json: schema: $ref: '#/components/schemas/User' '401': $ref: '#/components/responses/Unauthorized'
/tasks: get: operationId: listTasks tags: [tasks] summary: タスク一覧取得 description: > 条件に合うタスクを、更新日時の新しい順に返す。 件数が多い場合はページングする。 x-permissions: - role: member condition: 自分が所属するプロジェクトのタスクのみ - role: admin condition: すべてのタスク parameters: - $ref: '#/components/parameters/Page' - $ref: '#/components/parameters/PerPage' - name: status in: query description: 状態で絞り込む。複数指定できる style: form explode: true schema: type: array items: $ref: '#/components/schemas/TaskStatus' - name: priority in: query description: 優先度で絞り込む schema: $ref: '#/components/schemas/Priority' - name: assigneeId in: query description: 担当者で絞り込む schema: type: string format: uuid - name: q in: query description: タイトルと本文の部分一致検索 schema: type: string minLength: 2 maxLength: 50 - name: dueBefore in: query description: この日付以前が期限のものに絞り込む schema: type: string format: date example: '2026-12-31' - name: sort in: query schema: type: string enum: [updatedAt, -updatedAt, dueDate, -dueDate, priority] default: -updatedAt description: 並び順。先頭に - を付けると降順 responses: '200': description: 成功 headers: X-Total-Count: description: 条件に合う全件数 schema: type: integer content: application/json: schema: $ref: '#/components/schemas/TaskPage' '401': $ref: '#/components/responses/Unauthorized'
post: operationId: createTask tags: [tasks] summary: タスク作成 x-purpose: 新しいタスクを登録する。 x-permissions: - role: member condition: 自分が所属するプロジェクトにのみ作成できる - role: admin requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TaskInput' responses: '201': description: 作成成功 headers: Location: description: 作成したタスクの URL schema: type: string format: uri content: application/json: schema: $ref: '#/components/schemas/Task' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '422': $ref: '#/components/responses/ValidationFailed' default: $ref: '#/components/responses/UnexpectedError'
/tasks/export: get: operationId: exportTasks tags: [tasks] summary: タスクのエクスポート x-purpose: タスク一覧を JSON または CSV でダウンロードする。 x-permissions: - role: admin parameters: - name: Accept in: header description: 欲しい形式 schema: type: string enum: [application/json, text/csv] default: application/json - name: locale in: cookie description: CSV の見出しの言語 schema: type: string enum: [ja, en] default: ja responses: '200': description: 成功 content: application/json: schema: type: array items: $ref: '#/components/schemas/Task' text/csv: schema: type: string example: | id,title,status 1b4e28ba-2fa1-11d2-883f-0016d3cca427,資料作成,todo '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden'
/tasks/{taskId}: parameters: - $ref: '#/components/parameters/TaskId' get: operationId: getTask tags: [tasks] summary: タスク取得 x-purpose: タスク 1 件の詳細を返す。 x-permissions: - role: member condition: 自分が所属するプロジェクトのタスクのみ - role: admin parameters: - name: If-None-Match in: header description: 前回取得時の ETag。変わっていなければ 304 を返す schema: type: string responses: '200': description: 成功 headers: ETag: description: タスクの版 schema: type: string content: application/json: schema: $ref: '#/components/schemas/Task' '304': description: 変更なし '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound'
patch: operationId: updateTask tags: [tasks] summary: タスク更新 x-purpose: 担当者がタスクの状態や期限を変更する。送った項目だけを更新する。 x-permissions: - role: member condition: 自分が担当のタスクのみ - role: admin condition: すべてのタスク x-processing: - step: 入力チェック detail: title は 1〜100 文字。dueDate に null を送ると期限を消す - step: 権限チェック detail: member の場合、assigneeId が JWT の sub と一致するか確認する - step: 更新 detail: 送られた項目だけを更新し、updatedAt を現在時刻にする - step: 履歴登録 detail: 状態が変わった場合は Activity(status_changed)を登録する requestBody: required: true content: application/merge-patch+json: schema: $ref: '#/components/schemas/TaskPatch' responses: '200': description: 更新成功 content: application/json: schema: $ref: '#/components/schemas/Task' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': description: 他の人が先に更新した(If-Match の ETag が古い) content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '422': $ref: '#/components/responses/ValidationFailed'
delete: operationId: deleteTask tags: [tasks] summary: タスク削除 x-purpose: タスクを削除する。添付ファイルと履歴もまとめて消える。 x-permissions: - role: admin responses: '204': description: 削除成功 '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound'
/tasks/{taskId}/labels: parameters: - $ref: '#/components/parameters/TaskId' put: operationId: updateTaskLabels tags: [tasks] summary: ラベル更新 x-purpose: タスクに付けるラベル(キーと値の組)を丸ごと置き換える。 x-permissions: - role: member condition: 自分が担当のタスクのみ - role: admin requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/Labels' example: customer: ACME sprint: '2026-11' responses: '200': description: 更新成功 content: application/json: schema: $ref: '#/components/schemas/Labels' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound'
/tasks/{taskId}/activities: parameters: - $ref: '#/components/parameters/TaskId' get: operationId: listActivities tags: [tasks] summary: 履歴一覧取得 x-purpose: タスクに対するコメント・状態変更・担当変更の履歴を時系列で返す。 x-permissions: - role: member condition: 自分が所属するプロジェクトのタスクのみ - role: admin responses: '200': description: 成功 content: application/json: schema: type: array items: $ref: '#/components/schemas/Activity' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound'
/tasks/{taskId}/comments: parameters: - $ref: '#/components/parameters/TaskId' post: operationId: addComment tags: [tasks] summary: コメント追加 x-purpose: タスクにコメントを書き込む。書き込んだコメントは履歴に残る。 x-permissions: - role: member condition: 自分が所属するプロジェクトのタスクのみ - role: admin requestBody: required: true content: application/json: schema: type: object required: - body properties: body: type: string minLength: 1 maxLength: 1000 description: コメント本文 responses: '201': description: 追加成功 content: application/json: schema: $ref: '#/components/schemas/CommentActivity' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/ValidationFailed'
/tasks/{taskId}/attachments: parameters: - $ref: '#/components/parameters/TaskId' post: operationId: uploadAttachment tags: [attachments] summary: 添付ファイル登録 x-purpose: タスクにファイルを添付する。 x-permissions: - role: member condition: 自分が所属するプロジェクトのタスクのみ - role: admin requestBody: required: true content: multipart/form-data: schema: type: object required: - file properties: file: type: string format: binary description: 添付するファイル(10MB まで) comment: type: string maxLength: 200 description: ファイルの説明 responses: '201': description: 登録成功 content: application/json: schema: $ref: '#/components/schemas/Attachment' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' '413': description: ファイルが大きすぎる content: application/problem+json: schema: $ref: '#/components/schemas/Problem'
/tasks/{taskId}/attachments/{attachmentId}: parameters: - $ref: '#/components/parameters/TaskId' - name: attachmentId in: path required: true description: 添付ファイルの ID schema: type: string format: uuid get: operationId: downloadAttachment tags: [attachments] summary: 添付ファイル取得 x-purpose: 添付ファイルの中身をダウンロードする。 x-permissions: - role: member condition: 自分が所属するプロジェクトのタスクのみ - role: admin responses: '200': description: 成功 headers: Content-Disposition: description: 'ファイル名。例: attachment; filename="report.pdf"' schema: type: string content: application/octet-stream: schema: type: string format: binary '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound'
/categories: get: operationId: getCategoryTree tags: [categories] summary: カテゴリツリー取得 x-purpose: カテゴリを親子の木構造で返す。 x-permissions: - role: member - role: admin parameters: - name: depth in: query description: 返す階層の深さ schema: type: integer minimum: 1 maximum: 5 default: 3 responses: '200': description: 成功 content: application/json: schema: type: array items: $ref: '#/components/schemas/Category' '401': $ref: '#/components/responses/Unauthorized'
/webhooks/task-events: post: operationId: receiveWebhook tags: [system] summary: 外部サービスからのイベント受信 deprecated: true description: | 旧連携用。新しい連携では使わない。 送信元は X-Signature ヘッダーに本文の HMAC-SHA256 署名を付ける。 x-purpose: 外部のチケット管理サービスから、タスクの変更を受け取る。 security: [] x-permissions: - role: 外部サービス condition: 'X-Signature の署名が正しいこと(JWT は使わない)' parameters: - name: X-Signature in: header required: true description: '本文の HMAC-SHA256 署名(形式: sha256=<16 進数>)' schema: type: string pattern: '^sha256=[0-9a-f]{64}$' requestBody: required: true content: application/json: schema: type: object required: - event - payload properties: event: type: string enum: [task.created, task.updated] payload: type: object additionalProperties: true description: イベントごとに中身が変わる responses: '202': description: 受け付けた '401': description: 署名が正しくない
components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT description: | ログインで受け取ったアクセストークンを Authorization ヘッダーに付ける。 例: Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...
JWT のクレーム: - sub: ユーザー ID - role: member または admin - exp: 有効期限
parameters: TaskId: name: taskId in: path required: true description: タスクの ID schema: type: string format: uuid Page: name: page in: query description: ページ番号(1 始まり) schema: type: integer minimum: 1 default: 1 PerPage: name: perPage in: query description: 1 ページの件数 schema: type: integer minimum: 1 maximum: 100 default: 20
responses: BadRequest: description: リクエストの形式が正しくない content: application/problem+json: schema: $ref: '#/components/schemas/Problem' Unauthorized: description: JWT が無い、期限切れ、または署名が正しくない headers: WWW-Authenticate: description: 'Bearer error="invalid_token" など' schema: type: string content: application/problem+json: schema: $ref: '#/components/schemas/Problem' Forbidden: description: JWT の role では実行できない content: application/problem+json: schema: $ref: '#/components/schemas/Problem' NotFound: description: 対象が存在しない content: application/problem+json: schema: $ref: '#/components/schemas/Problem' ValidationFailed: description: 入力値の検証エラー content: application/problem+json: schema: $ref: '#/components/schemas/ValidationProblem' UnexpectedError: description: 想定外のエラー content: application/problem+json: schema: $ref: '#/components/schemas/Problem'
schemas: LoginRequest: type: object required: - email - password properties: email: type: string format: email description: メールアドレス password: type: string format: password minLength: 8 maxLength: 64 writeOnly: true description: パスワード
TokenPair: type: object required: - accessToken - refreshToken - tokenType - expiresIn properties: accessToken: type: string description: アクセストークン(JWT) example: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMifQ.signature refreshToken: type: string description: リフレッシュトークン tokenType: type: string enum: [Bearer] expiresIn: type: integer description: アクセストークンの有効秒数 example: 900
User: type: object required: - id - name - email - role properties: id: type: string format: uuid readOnly: true name: type: string description: 表示名 email: type: string format: email role: $ref: '#/components/schemas/Role'
Role: type: string description: 'member: 一般ユーザー / admin: 管理者' enum: [member, admin]
TaskStatus: type: string description: タスクの状態 enum: [todo, doing, done]
Priority: type: integer description: '優先度(1: 低 〜 3: 高)' enum: [1, 2, 3]
UserSummary: type: object required: - id - name properties: id: type: string format: uuid name: type: string
TaskInput: type: object required: - title - projectId properties: title: type: string minLength: 1 maxLength: 100 description: タイトル example: 週次レポートを作る description: type: string maxLength: 2000 description: 本文(Markdown) projectId: type: string format: uuid description: 所属するプロジェクト status: $ref: '#/components/schemas/TaskStatus' priority: $ref: '#/components/schemas/Priority' dueDate: type: string format: date description: 期限 assigneeId: type: string format: uuid description: 担当者 checklist: type: array maxItems: 20 description: チェックリスト items: type: object required: - text properties: text: type: string maxLength: 100 done: type: boolean default: false tags: type: array description: タグ items: type: string pattern: '^[a-z0-9-]+$'
Task: allOf: - $ref: '#/components/schemas/TaskInput' - type: object required: - id - status - createdAt - updatedAt properties: id: type: string format: uuid readOnly: true assignee: $ref: '#/components/schemas/UserSummary' createdAt: type: string format: date-time readOnly: true updatedAt: type: string format: date-time readOnly: true
TaskPatch: type: object description: 送った項目だけを更新する(JSON Merge Patch) properties: title: type: string minLength: 1 maxLength: 100 status: $ref: '#/components/schemas/TaskStatus' priority: $ref: '#/components/schemas/Priority' dueDate: type: string format: date nullable: true description: null を送ると期限を消す assigneeId: type: string format: uuid nullable: true description: null を送ると担当を外す
TaskPage: allOf: - $ref: '#/components/schemas/PageMeta' - type: object required: - items properties: items: type: array items: $ref: '#/components/schemas/Task'
PageMeta: type: object required: - page - perPage - totalPages properties: page: type: integer perPage: type: integer totalPages: type: integer
Labels: type: object description: キーと値の組。キーは英小文字とハイフン maxProperties: 10 additionalProperties: type: string maxLength: 50
Activity: oneOf: - $ref: '#/components/schemas/CommentActivity' - $ref: '#/components/schemas/StatusChangedActivity' - $ref: '#/components/schemas/AssigneeChangedActivity' discriminator: propertyName: type mapping: comment: '#/components/schemas/CommentActivity' status_changed: '#/components/schemas/StatusChangedActivity' assignee_changed: '#/components/schemas/AssigneeChangedActivity'
ActivityBase: type: object required: - id - type - actor - occurredAt properties: id: type: string format: uuid type: type: string description: 履歴の種類 actor: $ref: '#/components/schemas/UserSummary' occurredAt: type: string format: date-time
CommentActivity: allOf: - $ref: '#/components/schemas/ActivityBase' - type: object required: - body properties: type: type: string enum: [comment] body: type: string description: コメント本文
StatusChangedActivity: allOf: - $ref: '#/components/schemas/ActivityBase' - type: object required: - from - to properties: type: type: string enum: [status_changed] from: $ref: '#/components/schemas/TaskStatus' to: $ref: '#/components/schemas/TaskStatus'
AssigneeChangedActivity: allOf: - $ref: '#/components/schemas/ActivityBase' - type: object properties: type: type: string enum: [assignee_changed] from: type: object allOf: - $ref: '#/components/schemas/UserSummary' nullable: true description: 変更前の担当者(未割り当てなら null) to: type: object allOf: - $ref: '#/components/schemas/UserSummary' nullable: true description: 変更後の担当者(未割り当てなら null)
Category: type: object required: - id - name properties: id: type: integer name: type: string children: type: array description: 子カテゴリ(同じ形が入れ子になる) items: $ref: '#/components/schemas/Category'
Attachment: type: object required: - id - fileName - size properties: id: type: string format: uuid fileName: type: string size: type: integer format: int64 description: バイト数 maximum: 10485760 comment: type: string uploadedAt: type: string format: date-time
Problem: type: object description: エラーの共通形式(RFC 9457) required: - type - title - status properties: type: type: string format: uri default: about:blank title: type: string status: type: integer detail: type: string instance: type: string format: uri
ValidationProblem: allOf: - $ref: '#/components/schemas/Problem' - type: object required: - errors properties: errors: type: array description: 項目ごとのエラー items: type: object required: - field - message properties: field: type: string description: 'エラーの項目(例: checklist[0].text)' message: type: stringこの節で削除したファイル: 詳細設計書テンプレート.xlsm
よくある質問
Section titled “よくある質問”YAML を直したのにエラーになる
インデントのずれが一番多い原因です。エラーに出た行番号の前後で、行頭の空白の数が周りとそろっているか確かめてください。VS Code で開くと、ずれている場所に印が付きます。
間違えて取り込んでしまった
ブックと同じフォルダの backup に、取り込む直前のブックが日時付きで保存されています。今のブックを閉じ、backup のファイルをコピーして使ってください。