설명
OpenAPI 3.0의 content 키는 미디어 타입이나 허용되는 미디어 범위를 나타냅니다. application/json을 잘못 적으면 도구와 API 사용자가 의도한 본문 형식을 이해하지 못할 수 있습니다.
잠재적 영향
잘못된 타입 이름은 요청 또는 응답 형식의 해석과 클라이언트 생성을 방해할 수 있습니다. 문서의 이름을 바꾸는 것만으로 실제 본문 형식이 변하지는 않습니다.
해결 방법
실제 본문 형식에 맞춰 타입과 하위 타입의 철자를 확인하세요. 올바른 벤더 타입이나 허용되는 미디어 범위를 임의로 일반 타입으로 바꾸지 말고, 실제 Content-Type과 문서가 일치하는지 확인하세요.
예시
재사용 응답의 JSON 미디어 타입 이름을 비교합니다. 이 응답을 사용할 작업의 연결은 별도로 구성해야 합니다.
변경 전
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": {
"responses": {
"ResponseExample": {
"description": "200 response",
"content": {
"applicasdsadtion/json": {
"schema": {
"properties": {
"code": {
"type": "string",
"format": "binary"
},
"message": {
"type": "string"
}
},
"type": "object"
}
}
}
}
}
}
}
변경 후
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": {
"responses": {
"ResponseExample": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"properties": {
"code": {
"type": "string",
"format": "binary"
},
"message": {
"type": "string"
}
},
"type": "object"
}
}
}
}
}
}
}
변경 후에는 잘못된 applicasdsadtion/json 대신 application/json을 사용합니다. JSON 응답에 적용되지 않는 encoding 설정은 포함하지 않습니다.