설명
요청이나 응답의 schema에서 참조하는 대상은 데이터의 필드와 타입을 정의한 스키마 객체여야 합니다.
잠재적 영향
참조가 잘못되면 검증이나 모델 생성이 실패하거나 문서에서 데이터 구조가 빠질 수 있습니다.
해결 방법
#/components/schemas/... 또는 외부 파일의 스키마를 참조하세요. 경로의 철자와 대상 객체의 종류를 확인하세요.
예시
NewItem의 멀티파트 본문에서 schemads를 schemas로 고치면 GeneralError를 참조할 수 있습니다. tshirt 예시 정의와 NewItem을 사용하는 작업은 생략했습니다.
변경 전
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "https://www.google.com/",
"email": "user@gmail.c"
}
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"petType"
]
}
},
"requestBodies": {
"NewItem": {
"description": "Multipart item data",
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemads/GeneralError"
},
"examples": {
"tshirt": {
"$ref": "#/components/examples/tshirt"
}
}
}
}
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "https://www.google.com/",
"email": "user@gmail.c"
}
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"petType"
]
}
},
"requestBodies": {
"NewItem": {
"description": "Multipart item data",
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/GeneralError"
},
"examples": {
"tshirt": {
"$ref": "#/components/examples/tshirt"
}
}
}
}
}
}
}
}