説明
OpenAPI 3.0 は allowEmptyValue の使用を推奨していません。空の値を表現できるシリアライズ方式のクエリーパラメーターにだけ適用されます。
想定される影響
クライアントが送った空の値をサーバーが拒否することがあります。
対処方法
パス、ヘッダー、Cookie のパラメーターからこの設定を削除します。クエリーパラメーターでは、省略した場合と空の値を明示した場合をそれぞれ試し、サーバーの挙動を確認します。
例
この例の id はパスで必須の整数です。
変更前
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/{id}": {
"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": "path",
"description": "ID of the API version",
"required": true,
"allowEmptyValue": true,
"schema": {
"type": "integer"
}
}
]
}
}
}
変更後
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"paths": {
"/{id}": {
"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": [
{
"in": "path",
"style": "label",
"description": "ID of the API version",
"required": true,
"schema": {
"type": "integer"
},
"name": "id"
}
]
}
}
}
style: label が変更するのはパスの表記です。整数値は引き続き必要です。