説明
OpenAPI 3.0 のリクエスト・レスポンス本文では、content のキーに実際のメディアタイプか対応するメディア範囲を指定します。
想定される影響
誤記があると、生成したクライアントが想定した本文形式を選択できない場合があります。
対処方法
有効なベンダー固有のタイプやメディア範囲は維持します。実際の Content-Type と本文を定義と照合し、再利用するレスポンスはどの操作が参照するか確認してください。
例
例で変更するのは ResponseExample です。GET / の 200 レスポンスは個別に定義されています。
変更前
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 の指定は不要です。