説明
最上位の responses に定義したレスポンスは、操作のステータスコードから参照して使います。未使用の定義があっても仕様は有効です。
想定される影響
使われていない定義を見て、その操作が実際に返すレスポンスだと誤解する場合があります。
対処方法
必要なレスポンスは対応するステータスコードから参照してください。削除する前に、他の操作や文書での使用も確認します。
例
POST / の 200 レスポンスが参照する Success を残し、使っていない IllegalInput と GeneralError を削除しています。
変更前
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"post": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"$ref": "#/responses/Success"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
},
"responses": {
"Success": {
"description": "200 response"
},
"IllegalInput": {
"description": "Illegal input for operation."
},
"GeneralError": {
"description": "General Error"
}
}
}
変更後
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"post": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"$ref": "#/responses/Success"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
},
"responses": {
"Success": {
"description": "200 response"
}
}
}