説明
OpenAPI 3.0 のレスポンスヘッダーには値の形式を定義します。説明だけでは型が分かりません。
想定される影響
SDK が数値のヘッダーを文字列として扱ったり、値を誤って解釈したりすることがあります。
対処方法
schema にヘッダーの型と制約を指定するか、一つのメディアタイプで表す場合は content を使います。共通ヘッダーでは $ref の参照先を確認します。
例
例は、現在の期間に許可されるリクエスト数を表す X-Rate-Limit-Limit のスキーマに type: integer を指定しています。
変更前
json
{
"openapi": "3.0.0",
"components": {
"responses": {
"ResponseExample": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The number of allowed requests in the current period"
}
}
}
}
}
}
変更後
json
{
"openapi": "3.0.0",
"components": {
"responses": {
"ResponseExample": {
"headers": {
"X-Rate-Limit-Limit": {
"description": "The number of allowed requests in the current period",
"schema": {
"type": "integer"
}
}
}
}
}
}
}