OpenAPI 新旧比較で破壊的変更を一覧化
OpenAPI diff for breaking changes
2 つの OpenAPI 仕様を比べ、削除されたパスやメソッド、新しく必須になったパラメータ、レスポンスから消えた項目、型の変更など、既存クライアントを壊す変更を一覧にします。
できること
API の新旧仕様(OpenAPI 3.0 / 3.1 / Swagger 2.0)を比べ、変更を「破壊的」「要確認」「影響なし」に分類して報告します。
- 削除されたパス・メソッド(
{petId}から{id}のような名前変更は削除扱いしません) - 新しい必須パラメータ、任意から必須への変更、リクエストボディの必須化、受け付けなくなったメディアタイプ
- レスポンスから消えた項目、必須でなくなった項目、null になり得るようになった項目、削除された成功レスポンス
- 型の変更(送る側・受け取る側の向きを区別。integer から number への拡大など)、enum の値の削除・追加、最大長などの制約の厳格化
$ref、allOfの統合、循環参照、readOnly/writeOnlyに対応- 認証が新たに必要になった変更、サーバー URL の変更
使い方
python scripts/openapi_diff.py old.yaml new.yaml --markdown api-diff.md
エージェントは結果を見て、名前変更の見落としや実際のクライアントへの影響を確認し、バージョンの上げ方や非推奨化の手順、変更履歴の書き方を提案します。破壊的変更があると終了コード 1 になるので CI にも使えます。
必要な環境
- Python 3(標準ライブラリのみ)
- YAML は PyYAML があればそれを使い、なければ内蔵の簡易リーダーで読みます。アンカー・エイリアス・タグを使った YAML は PyYAML を入れるか JSON に変換してください。
注意点
- 仕様書どうしの比較です。仕様に現れない挙動の変更(既定値やエラー形式など)は検出できません。
- 外部ファイルへの
$refはたどりません。分割された仕様は先に 1 ファイルにまとめてください。
English description
Compare two OpenAPI specs and list changes that break existing clients: removed paths and methods, new required parameters, removed response fields and type changes.
What it does
Compares an old and a new API spec (OpenAPI 3.0, 3.1 or Swagger 2.0) and classifies each change as breaking, needs review or non-breaking.
- Removed paths and methods (renaming
{petId}to{id}is not treated as a removal) - New required parameters, optional to required, request body becoming required, media types no longer accepted
- Response fields removed, no longer required or now nullable, removed success responses
- Type changes with direction awareness (request vs response, integer to number widening), enum values removed or added, tightened constraints such as maxLength
- Handles
$ref,allOfmerging, recursive schemas,readOnlyandwriteOnly - Authentication newly required, server URL changes
How to use
python scripts/openapi_diff.py old.yaml new.yaml --markdown api-diff.md
The agent reviews the result for renames and real client impact, then recommends the version bump, a deprecation path and changelog entries. Exit code is 1 when breaking changes exist, so it also works in CI.
Requirements
- Python 3 (standard library only)
- YAML is read with PyYAML when installed, otherwise with a built-in reader for the common subset. For YAML with anchors, aliases or tags, install PyYAML or convert the spec to JSON.
Caveats
- It compares specs only; behaviour changes not visible in the spec (defaults, error formats) are not detected.
- External
$reffiles are not followed; bundle split specs into one file first.
インストール方法
- ダウンロードしたZIPを展開します(中に
openapi-diff-breaking-changes/フォルダとSKILL.mdがあります)。 - フォルダごと、使うエージェントのスキル置き場にコピーします。
- Claude:
~/.claude/skills/(プロジェクト単位なら.claude/skills/) - Hermes Agent:
~/.hermes/skills/ - Codex:
~/.agents/skills//Cursor:~/.cursor/skills/ - Claude アプリ(claude.ai):「カスタマイズ → スキル」からZIPをアップロード
- Claude:
- エージェントを再起動し、スキル一覧に表示されることを確認します。
出品者
出品スキル 44 件