サーバーURLで使われていない変数

サーバー変数の定義を実際のURLテンプレートに合わせてください。

説明

サーバー変数で URL が変わるのは、テンプレートに同じ名前の {name} がある場合です。

想定される影響

使われていない変数の値を変えても、接続先の環境は変わりません。

対処方法

variables から未使用の項目を削除します。ホストやパスの切り替えに必要な変数は url にプレースホルダーを追加し、デフォルト値で得られるアドレスを確認します。

例

テンプレートが使うのは server と base なので、例では another を削除します。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}",
                  "variables": {
                    "base": {
                      "default": "v2"
                    },
                    "server": {
                      "default": "gigant-server"
                    },
                    "another": {
                      "default": "another"
                    }
                  }
                }
              }
            }
          }
        },
        "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"
      }
    }
  }
}

参考資料