설명
components.schemas의 모델은 OpenAPI 3.0 작업에서 직접 또는 다른 참조를 통해 사용할 때 그 작업의 데이터 구조를 정합니다.
잠재적 영향
미사용 모델이 문서나 생성 코드에 남으면 API가 어떤 필드를 받거나 반환하는지 구분하기 어렵습니다.
해결 방법
요청, 응답, 매개변수, 다른 모델과 외부 문서에서 이어지는 참조를 확인하세요. 사용하는 곳이 없는 스키마만 삭제하세요.
예시
응답 본문은 MyObject를 사용합니다. 예시에서는 참조되지 않는 MyObject2를 삭제합니다.
변경 전
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MyObject"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"MyObject2": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MyObject"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
}
}
}