説明
パラメーターの位置にある $ref は、名前や場所などを定義するパラメーターオブジェクトを参照する必要があります。スキーマなど別の種類のオブジェクトや誤ったパスでは、必要なリクエストパラメーターを定義できません。
想定される影響
検証やクライアント生成に失敗したり、必須パラメーターの情報が欠落したりする可能性があります。
対処方法
共通パラメーターは #/components/parameters/... の実在する定義を参照してください。外部ファイルの有効なパラメーターオブジェクトも使用できます。
例
次の例では、誤ったパスを idParam の実際の参照パスに変更しています。パスパラメーター id はURLパスの {id} と一致します。
変更前
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"components": {
"parameters": {
"idParam": {
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true,
"schema": {
"type": "integer"
}
}
}
},
"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": [
{
"$ref": "#path/parameters/idParam"
},
{
"$ref": "#components/schemas/idParam"
}
]
},
"/user/{id}": {
"get": {
"parameters": [
{
"$ref": "#path/parameters/idParam"
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
}
}
}
変更後
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API overview",
"version": "1.0.0"
},
"components": {
"parameters": {
"idParam": {
"name": "id",
"in": "path",
"description": "ID of the API version",
"required": true,
"schema": {
"type": "integer"
}
}
}
},
"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": [
{
"$ref": "#/components/parameters/idParam"
}
]
}
}
}