설명
requestBody의 $ref는 본문을 어떤 미디어 유형으로 보낼지 정의하는 요청 본문 객체를 가리켜야 합니다.
잠재적 영향
스키마를 직접 참조하면 생성된 문서에서 형식이 빠져 클라이언트가 본문을 잘못 보낼 수 있습니다.
해결 방법
#/components/requestBodies/... 또는 외부 파일의 요청 본문 객체를 참조하세요. 스키마는 이 객체의 content 안에서 해당 미디어 유형에 지정하세요.
예시
POST /는 #/components/requestBodies/List를 참조합니다. List는 text/plain 본문에 정수 배열 스키마를 지정합니다.
변경 전
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"components": {
"requestBodies": {
"List": {
"description": "id of api version",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
}
},
"paths": {
"/": {
"post": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"requestBody": {
"$ref": "#/components/schemas/List"
},
"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"
}
]
}
]
}
}
}
}
}
}
}
}
}
}
}
변경 후
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"components": {
"requestBodies": {
"List": {
"description": "id of api version",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
}
},
"paths": {
"/": {
"post": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"requestBody": {
"$ref": "#/components/requestBodies/List"
},
"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"
}
]
}
]
}
}
}
}
}
}
}
}
}
}
}