{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/car-gene-com/json-schema/car-gene-com-get-sales-figures-response-schema.json",
  "title": "GetSalesFiguresResponse",
  "description": "台数の全件と、枡・地域ごとの合計・空欄の状態・別系統の通算\n\n**行と枡を両方返す。** 行だけだと画面が足し方を決め直すことになり、\n枡だけだと出典の1行が読めなくなる。\n\n**cells / region_totals / coverage / lifetime はシリーズの単位で作る。**\n割り付け (枡 → 世代) は、その年その地域に世代がいくつ並ぶかで決まるので、\nシリーズの世代が全部そろっていないと決まらない。**`model_id` で絞った\nときも、この4つはその世代が属するシリーズの分**が入る (絞られるのは\nfigures だけ)——世代1つ分の行だけで枡を作ると、同じ枡にある別の出典が\n見えず、出典数と食い違いを取り違える。\n\n**figures は絞り込みの範囲で全件。** シリーズ通算の行も落とさない——\n出典で確認できた真の値であること、E2E がその台数を使って「画面に出て\nいない」を検査すること、の2つのため",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/car-gene-com-openapi.yml#/components/schemas/GetSalesFiguresResponse",
  "properties": {
    "figures": {
      "items": {
        "$ref": "#/$defs/SalesFigureResponse"
      },
      "type": "array",
      "title": "Figures"
    },
    "cells": {
      "items": {
        "$ref": "#/$defs/SalesCellResponse"
      },
      "type": "array",
      "title": "Cells"
    },
    "region_totals": {
      "items": {
        "$ref": "#/$defs/SalesRegionTotalResponse"
      },
      "type": "array",
      "title": "Region Totals"
    },
    "coverage": {
      "items": {
        "$ref": "#/$defs/SalesCoverageResponse"
      },
      "type": "array",
      "title": "Coverage"
    },
    "lifetime": {
      "items": {
        "$ref": "#/$defs/SalesLifetimeResponse"
      },
      "type": "array",
      "title": "Lifetime"
    }
  },
  "type": "object",
  "required": [
    "figures",
    "cells",
    "region_totals",
    "coverage",
    "lifetime"
  ],
  "$defs": {
    "SalesCellResponse": {
      "properties": {
        "series_id": {
          "type": "string",
          "title": "Series Id"
        },
        "region_code": {
          "type": "string",
          "title": "Region Code"
        },
        "year": {
          "type": "integer",
          "title": "Year"
        },
        "metric": {
          "type": "string",
          "title": "Metric"
        },
        "metric_label": {
          "type": "string",
          "title": "Metric Label"
        },
        "units": {
          "type": "integer",
          "title": "Units"
        },
        "sources": {
          "type": "integer",
          "title": "Sources"
        },
        "conflict": {
          "type": "boolean",
          "title": "Conflict"
        },
        "model_id": {
          "type": "string",
          "title": "Model Id"
        },
        "model_name": {
          "type": "string",
          "title": "Model Name"
        },
        "attribution": {
          "type": "string",
          "title": "Attribution"
        },
        "deferred_model_ids": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Deferred Model Ids",
          "default": []
        },
        "source_terms": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Source Terms"
        },
        "scope_notes": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Scope Notes"
        },
        "figure_ids": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Figure Ids"
        }
      },
      "type": "object",
      "required": [
        "series_id",
        "year",
        "metric",
        "metric_label",
        "sources",
        "conflict",
        "attribution",
        "source_terms",
        "scope_notes",
        "figure_ids"
      ],
      "title": "SalesCellResponse",
      "description": "枡ひとつ (シリーズ × 地域 × 暦年 × metric)\n\n決めごとは docs/sales-grid.md。**同じ枡に出典を何本でも入れられる**\n(#1189) ので、**枡ごとに1つの値を選ぶのはここ**。全部同じ値なら units に\n入り、食い違えば units は null で conflict が立つ——どちらを載せるかは\n人が決めるので、機械は選ばずに「食い違っている」とだけ言う。\n\n**暦年の行だけが枡になる。** 年度・半期は別の数で、世代の通算と累計は\n別系統 (lifetime)。どちらも枡には入らない。"
    },
    "SalesCoverageResponse": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "series_id": {
          "type": "string",
          "title": "Series Id"
        },
        "region_code": {
          "type": "string",
          "title": "Region Code"
        },
        "year_from": {
          "type": "integer",
          "title": "Year From"
        },
        "year_to": {
          "type": "integer",
          "title": "Year To"
        },
        "result": {
          "type": "string",
          "title": "Result"
        },
        "result_label": {
          "type": "string",
          "title": "Result Label"
        },
        "checked_source_url": {
          "type": "string",
          "title": "Checked Source Url"
        },
        "checked_at": {
          "type": "string",
          "format": "date",
          "title": "Checked At"
        }
      },
      "type": "object",
      "required": [
        "id",
        "series_id",
        "region_code",
        "year_from",
        "year_to",
        "result",
        "result_label",
        "checked_source_url"
      ],
      "title": "SalesCoverageResponse",
      "description": "調べたが、その出典には無かった枡\n\n**行が無い = 未調査、行がある = 調べた結果の空欄。** 画面はこの行から\n「公表なし」「圏外」「集計対象外」の語を選ぶ\n(docs/sales-grid.md「空欄には状態がある」)。\n\n**`note` は返さない。** 調べた側の申し送りで、読者には出さない (#948)"
    },
    "SalesFigureResponse": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "series_id": {
          "type": "string",
          "title": "Series Id"
        },
        "model_id": {
          "type": "string",
          "title": "Model Id"
        },
        "model_name": {
          "type": "string",
          "title": "Model Name"
        },
        "region_code": {
          "type": "string",
          "title": "Region Code"
        },
        "metric": {
          "type": "string",
          "title": "Metric"
        },
        "source_term": {
          "type": "string",
          "title": "Source Term"
        },
        "units": {
          "type": "integer",
          "title": "Units"
        },
        "period": {
          "$ref": "#/$defs/SalesPeriodResponse"
        },
        "scope_note": {
          "type": "string",
          "title": "Scope Note"
        },
        "source_url": {
          "type": "string",
          "title": "Source Url"
        },
        "source_excerpt": {
          "type": "string",
          "title": "Source Excerpt"
        }
      },
      "type": "object",
      "required": [
        "id",
        "series_id",
        "metric",
        "source_term",
        "units",
        "period",
        "source_url",
        "source_excerpt"
      ],
      "title": "SalesFigureResponse",
      "description": "出典に書いてある台数、1行\n\n`source_term` は出典が使っている語そのまま、`metric` は集計キー。**画面に出る\n語は枡の `metric_label` で、`source_term` は出さない**（docs/sales-grid.md\n「見せ方」）——1つの円・1つの列が複数の出典を束ねるので、出典の語を並べると\n「販売台数・sales」のように読めない語になる。`source_term` は DB と検算で使う。"
    },
    "SalesLifetimeResponse": {
      "properties": {
        "figure_id": {
          "type": "string",
          "title": "Figure Id"
        },
        "series_id": {
          "type": "string",
          "title": "Series Id"
        },
        "model_id": {
          "type": "string",
          "title": "Model Id"
        },
        "model_name": {
          "type": "string",
          "title": "Model Name"
        },
        "region_code": {
          "type": "string",
          "title": "Region Code"
        },
        "metric": {
          "type": "string",
          "title": "Metric"
        },
        "metric_label": {
          "type": "string",
          "title": "Metric Label"
        },
        "source_term": {
          "type": "string",
          "title": "Source Term"
        },
        "units": {
          "type": "integer",
          "title": "Units"
        },
        "period": {
          "$ref": "#/$defs/SalesPeriodResponse"
        },
        "scope_note": {
          "type": "string",
          "title": "Scope Note"
        },
        "source_url": {
          "type": "string",
          "title": "Source Url"
        }
      },
      "type": "object",
      "required": [
        "figure_id",
        "series_id",
        "metric",
        "metric_label",
        "source_term",
        "units",
        "period",
        "source_url"
      ],
      "title": "SalesLifetimeResponse",
      "description": "世代の通算 (model_lifetime) と、時点までの累計 (cumulative)\n\n**枡と別系統で、足し合わせない** (docs/sales-grid.md)。出典の語のまま文として\n出すためだけに、行をそのまま渡す。"
    },
    "SalesPeriodResponse": {
      "properties": {
        "kind": {
          "type": "string",
          "title": "Kind"
        },
        "year": {
          "type": "integer",
          "title": "Year"
        },
        "end_month": {
          "type": "integer",
          "title": "End Month"
        },
        "half": {
          "type": "integer",
          "title": "Half"
        }
      },
      "type": "object",
      "required": [
        "kind",
        "year"
      ],
      "title": "SalesPeriodResponse",
      "description": "出典が書いている期間\n\n**年だけでは足せるかどうかが決まらない。** N-BOX には「2015年6月までの累計\n73万5,942台」と「2015年 18万4,920台」が両方あり、どちらも 2015 年。\nkind が違う行は足さない。"
    },
    "SalesRegionTotalResponse": {
      "properties": {
        "series_id": {
          "type": "string",
          "title": "Series Id"
        },
        "model_id": {
          "type": "string",
          "title": "Model Id"
        },
        "model_name": {
          "type": "string",
          "title": "Model Name"
        },
        "region_code": {
          "type": "string",
          "title": "Region Code"
        },
        "metric": {
          "type": "string",
          "title": "Metric"
        },
        "metric_label": {
          "type": "string",
          "title": "Metric Label"
        },
        "units": {
          "type": "integer",
          "title": "Units"
        },
        "years": {
          "items": {
            "type": "integer"
          },
          "type": "array",
          "title": "Years"
        },
        "expected_years": {
          "items": {
            "type": "integer"
          },
          "type": "array",
          "title": "Expected Years"
        },
        "complete": {
          "type": "boolean",
          "title": "Complete"
        },
        "conflicts": {
          "type": "integer",
          "title": "Conflicts"
        },
        "source_terms": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Source Terms"
        },
        "scope_notes": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Scope Notes"
        }
      },
      "type": "object",
      "required": [
        "series_id",
        "metric",
        "metric_label",
        "units",
        "years",
        "expected_years",
        "complete",
        "conflicts",
        "source_terms",
        "scope_notes"
      ],
      "title": "SalesRegionTotalResponse",
      "description": "1つの地域の枡を、年で足した数\n\n**足すのは年だけ** (docs/sales-grid.md「足さないもの」)。地域を跨いだ合計は\nどこにも作らない——親と子 (`US` ⊂ `NA`) が並ぶことがあり、足すとどの出典も\n言っていない数になる。\n\n**complete が「通算」と「掲載 N 年分」を分ける。** 対象期間 (シリーズなら\n売られていた全年、世代ならその世代がその地域で売られていた年) が全部\n埋まっていれば通算、欠けていれば掲載 N 年分。"
    }
  }
}