OpenAPI 2.0 オブジェクトの不明なプロパティ

標準プロパティの誤記を修正し、対応する拡張形式を使用してください。

説明

Swagger 2.0 の標準フィールドは、対象のオブジェクトで定義された名前と大文字・小文字に合わせます。properties 内のキーは API が使うデータフィールド名です。

想定される影響

標準フィールドを誤記すると、検証に失敗したり、生成された文書や SDK から説明や項目が抜けたりします。

対処方法

文書を検証し、生成されたパラメーターの説明とモデルのフィールドを確認してください。独自のメタデータには、拡張に対応するオブジェクトで x- 接頭辞を使います。

例

最初の例では、パスパラメーターの description を descripption と誤記しています。

変更前

json
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/{id}": {
      "get": {
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "operationId": "listVersionsv2"
      },
      "parameters": [
        {
          "descripption": "ID of pet to use",
          "required": true,
          "type": "array",
          "items": {
            "type": "string"
          },
          "collectionFormat": "csv",
          "name": "id",
          "in": "path"
        }
      ]
    }
  },
  "definitions": {
    "ErrorModel": {
      "type": "object",
      "required": [
        "message",
        "code"
      ],
      "propppperties": {
        "message": {
          "type": "string"
        },
        "code": {
          "type": "integer",
          "minimum": 100,
          "maximum": 600
        }
      }
    }
  }
}

変更後

json
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/{id}": {
      "get": {
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "operationId": "listVersionsv2"
      },
      "parameters": [
        {
          "description": "ID of pet to use",
          "required": true,
          "type": "array",
          "items": {
            "type": "string"
          },
          "collectionFormat": "csv",
          "name": "id",
          "in": "path"
        }
      ]
    }
  },
  "definitions": {
    "ErrorModel": {
      "type": "object",
      "required": [
        "message",
        "code"
      ],
      "properties": {
        "message": {
          "type": "string"
        },
        "code": {
          "type": "integer",
          "minimum": 100,
          "maximum": 600
        }
      }
    }
  }
}

ErrorModel の propppperties も properties に修正します。データフィールド message と code の名前はそのままです。

参考資料