설명
최상위 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"
}
}
}