説明
サーバー URL のすべての {placeholder} を、そのサーバーの variables に定義します。各変数には文字列の default が必要です。
想定される影響
クライアントはこれらの値を使ってサーバーのアドレスを組み立てます。
対処方法
変数名をプレースホルダーと正確に合わせます。選択肢を絞る場合は enum を使い、デフォルト値や許可した値で正しい URL になることを確認します。
例
例の server と base のデフォルト値を使うと https://development.gigant-server.com/v2 になります。Link の対象を示す operationId または operationRef も指定します。
変更前
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"address": {
"server": {
"url": "https://development.{server}.com/{base}"
}
}
}
}
},
"operationId": "listVersionsv2"
}
}
}
}
変更後
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "the user being returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid"
}
}
}
}
},
"links": {
"address": {
"server": {
"url": "https://development.{server}.com/{base}",
"variables": {
"base": {
"default": "v2"
},
"server": {
"default": "gigant-server"
}
}
}
}
}
}
},
"operationId": "listVersionsv2"
}
}
}
}