説明
responses の任意項目 default は、操作で別途定義していないステータスコードに適用されます。エラー以外の結果にも使えます。
想定される影響
エラー本文の形式が不明だと、生成したクライアントでそのデータを扱えないことがあります。
対処方法
既知の成功コードとエラーコードを先に記述します。残るレスポンスが共通の説明や本文形式を使う場合は default を追加します。本文がある場合は実際に返す形式も記述します。
例
PATCH の例では本文のない 204 を残し、説明が Error の default を追加します。
変更前
json
{
"openapi": "3.0.0",
"paths": {
"/item": {
"patch": {
"operationId": "updateItem",
"responses": {
"204": {
"description": "Item updated successfully"
}
}
}
}
}
}
変更後
json
{
"openapi": "3.0.0",
"paths": {
"/item": {
"patch": {
"operationId": "updateItem",
"responses": {
"204": {
"description": "Item updated successfully"
},
"default": {
"description": "Error"
}
}
}
}
}
}