설명
요청이나 응답에서 예시를 로컬 참조로 연결할 때는 components.examples에 정의한 이름을 사용하세요.
잠재적 영향
정의가 없으면 문서에 예시 값이 표시되지 않거나 검증과 문서 생성이 실패할 수 있습니다.
해결 방법
오타나 이름 변경으로 끊어진 $ref를 고치고, 필요한 정의가 삭제됐다면 복원하세요. 외부 참조는 URI와 대상을 확인하세요. 예시가 실제 데이터, 스키마, 미디어 유형에 맞는지도 확인하세요.
예시
변경 전
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"
},
"examples": {
"objectExample": {
"$ref": "#/components/examples/wrongExample"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"examples": {
"objectExample": {
"value": {
"id": "1",
"name": "new object"
},
"summary": "A sample object"
}
}
}
}
변경 후
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"
},
"examples": {
"objectExample": {
"$ref": "#/components/examples/objectExample"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"examples": {
"objectExample": {
"value": {
"id": "1",
"name": "new object"
},
"summary": "A sample object"
}
}
}
}
GET /의 200 응답에서 wrongExample을 objectExample로 고치면 id와 name이 있는 JSON 예시를 문서에 표시할 수 있습니다.