本文以外のパラメーターにschemaを使用(OpenAPI 2.0)

query、path、header、formDataパラメーターにschemaがある状態

説明

OpenAPI 2.0の query、path、header、formData パラメーターでは、schema ではなく、パラメーター直下の type で型を定義します。配列には items も必要です。

想定される影響

文書の検証に失敗したり、ツールがパラメーターの型を正しく解釈できなかったりする可能性があります。

対処方法

schema を実際の type に置き換え、必要な format や items もパラメーターに直接定義してください。schema だけを削除して型情報を欠落させないでください。

例

次の例では、query パラメーターと再利用可能な path パラメーターで、schema を type: integer に置き換えています。limitParam の定義はこの操作では参照していません。

変更前

json
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "parameters": [
          {
            "name": "limit2",
            "in": "query",
            "description": "max records to return",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "operationId": "listVersionsV2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  },
  "parameters": {
    "limitParam": {
      "name": "limit",
      "in": "path",
      "description": "max records to return",
      "required": true,
      "schema": {
        "type": "integer"
      }
    }
  }
}

変更後

json
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "parameters": [
          {
            "name": "limit2",
            "in": "query",
            "description": "max records to return",
            "required": true,
            "type": "integer"
          }
        ],
        "operationId": "listVersionsV2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        }
      }
    }
  },
  "parameters": {
    "limitParam": {
      "name": "limit",
      "in": "path",
      "description": "max records to return",
      "required": true,
      "type": "integer"
    }
  }
}

参考資料