설명
OpenAPI 2.0에서 한 작업에 지정할 수 있는 in: body 매개변수는 최대 하나입니다.
잠재적 영향
본문 매개변수가 여러 개면 검증이 실패하거나 클라이언트가 어떤 값을 보내야 할지 알기 어렵습니다.
해결 방법
서버가 본문 필드를 여러 개 받는다면 하나의 객체 스키마로 묶으세요. 서버가 지원할 때만 값을 쿼리 매개변수나 헤더로 옮기세요. formData는 body와 함께 쓸 수 없습니다.
예시
수정한 POST 작업은 limit을 본문으로 받고, pageCount는 정수형 쿼리 매개변수로 받습니다.
변경 전
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"post": {
"parameters": [
{
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "string"
}
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}
변경 후
json
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"post": {
"parameters": [
{
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "pageCount",
"in": "query",
"description": "records per page",
"required": true,
"type": "integer"
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}