{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/gunspec-io/json-schema/gunspec-io-popular-firearm-schema.json",
  "title": "PopularFirearm",
  "description": "One firearm and the view activity recorded against it over the trailing window. **snake_case, and the identity columns are `entity_*`**: this reads the view-activity rollup, which counts any entity kind, not the catalog row.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/gunspec-io-firearm-discovery-api-openapi.yml#/components/schemas/PopularFirearm",
  "type": "object",
  "properties": {
    "entity_id": {
      "type": "string",
      "description": "Slug of the firearm. Named `entity_id` because the rollup counts views of any entity kind; it is `id` on the catalog endpoints."
    },
    "entity_name": {
      "type": "string",
      "description": "Display name of the firearm."
    },
    "manufacturer_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Slug of the manufacturer. `manufacturerId` on the camelCase endpoints."
    },
    "category_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Slug of the category. `categoryId` on the camelCase endpoints."
    },
    "country_of_origin": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO 3166-1 alpha-2 code of the country of origin."
    },
    "year_introduced": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Year the model was introduced."
    },
    "status": {
      "anyOf": [
        {
          "$ref": "#/$defs/FirearmStatus"
        },
        {
          "type": "null"
        }
      ],
      "description": "Production status, one of `in_production`, `discontinued`, `out_of_production`, `in_service`, `limited_production`, `prototype`. Discontinued records are kept deliberately: a rifle built in 2004 wears parts nobody sells today."
    },
    "svg_line_art_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Line-art silhouette, or null where none has been drawn."
    },
    "total_views": {
      "type": "integer",
      "description": "Views recorded inside the trailing window given by `days`."
    },
    "total_unique_users": {
      "type": "integer",
      "description": "Distinct visitors behind those views. Forty views from one reader is a different fact from forty readers."
    }
  },
  "required": [
    "entity_id",
    "entity_name"
  ],
  "$defs": {
    "FirearmStatus": {
      "type": "string",
      "enum": [
        "in_production",
        "discontinued",
        "out_of_production",
        "in_service",
        "limited_production",
        "prototype"
      ],
      "description": "Production status of a firearm. Closed: these are every value the catalog holds."
    }
  }
}