설명
클라이언트는 Accept로 원하는 응답 형식을 알립니다. OpenAPI 3.0은 Accept를 일반 헤더 파라미터로 정의하면 그 정의를 무시합니다.
잠재적 영향
도구가 해당 파라미터를 생략하면 호출자가 지원되는 응답 형식을 알기 어렵습니다.
해결 방법
지원하는 미디어 타입을 OpenAPI 3.0에서는 응답의 content, Swagger 2.0에서는 produces에 나열하세요. 서버가 ID를 요구하면 별도의 파라미터로 정의하세요.
예시
다음 OpenAPI 3.0 발췌에서는 /users/{id}의 경로 파라미터를 생략했습니다.
변경 전
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": "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"
}
]
}
]
}
}
}
}
}
}
}
},
"parameters": [
{
"name": "Accept",
"in": "header",
"description": "ID of the API the version",
"required": true,
"schema": {
"type": "integer"
}
}
]
},
"/users/{id}": {
"get": {
"parameters": [
{
"in": "header",
"name": "Accept",
"required": true,
"description": "The user ID",
"schema": {
"type": "integer",
"minimum": 1
}
}
],
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}
변경 후
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": "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"
}
]
}
]
}
}
}
}
}
}
}
},
"parameters": [
{
"name": "id",
"in": "query",
"description": "ID of the API the version",
"required": true,
"schema": {
"type": "integer"
}
}
]
},
"/users/{id}": {
"get": {
"responses": {
"200": {
"description": "200 response"
}
},
"parameters": [
{
"in": "header",
"name": "id",
"required": true,
"description": "The user ID",
"schema": {
"type": "integer",
"minimum": 1
}
}
]
}
}
}
}
변경 후 /는 쿼리에서, /users/{id}는 헤더에서 id를 받습니다. 서버가 실제로 그 위치에서 값을 읽을 때 사용하세요.