リンクオブジェクトの参照先が不正(OpenAPI 3.0)

後続のAPI操作を示すリンクの参照が不正な状態

説明

レスポンスのリンク参照は、有効なリンクオブジェクトを指す必要があります。パスや参照先が誤っていると、次に呼び出す操作と引き渡す値の対応関係を読み込めません。

想定される影響

文書から後続の呼び出し情報が欠落したり、参照の解決に失敗したりする可能性があります。

対処方法

共通リンクは #/components/links/... の実在する定義を参照してください。有効な外部のリンクオブジェクトも使えます。リンクが指定する操作とパラメーターも確認してください。

例

次の抜粋では、address リンクの参照パスを修正しています。外部モデル、エラーモデル、後続操作の定義は省略しています。

変更前

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "description": "the user being returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Pet": {
        "$ref": "../models/pet.yaml"
      },
      "User": {
        "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
      }
    },
    "responses": {
      "NotFound": {
        "description": "The specified resource was not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "links": {
          "l": {
            "$ref": "#components/linfks/address"
          }
        }
      }
    },
    "links": {
      "address": {
        "operationId": "getUssssserAddress",
        "parameters": {
          "userId": "$request.path.id"
        }
      }
    }
  }
}

変更後

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "description": "the user being returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Pet": {
        "$ref": "../models/pet.yaml"
      },
      "User": {
        "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User"
      }
    },
    "responses": {
      "NotFound": {
        "description": "The specified resource was not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "links": {
          "l": {
            "$ref": "#/components/links/address"
          }
        }
      }
    },
    "links": {
      "address": {
        "operationId": "getUssssserAddress",
        "parameters": {
          "userId": "$request.path.id"
        }
      }
    }
  }
}

参考資料