{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/gunspec-io/json-schema/gunspec-io-favorite-firearm-schema.json",
  "title": "FavoriteFirearm",
  "description": "One favorited firearm, enough to render a card without a second call. **The field names are snake_case here**, like the search results and unlike `/v1/firearms`. `firearm_id` and `id` carry the same slug.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/gunspec-io-account-api-openapi.yml#/components/schemas/FavoriteFirearm",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "URL-safe slug identifying the firearm. The same value as `firearm_id`."
    },
    "firearm_id": {
      "type": "string",
      "description": "Slug of the firearm, under the favorites table's own column name. The same value as `id`."
    },
    "favorited_at": {
      "type": "string",
      "description": "When this account favorited it, as the database stamps it (`YYYY-MM-DD HH:MM:SS`, UTC). The list is ordered by this, newest first."
    },
    "name": {
      "type": "string",
      "description": "Display name, as the maker writes it."
    },
    "manufacturer_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Slug of the manufacturer. `manufacturerId` on the camelCase endpoints."
    },
    "manufacturer_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "Display name of the manufacturer, joined in so a card renders without a second call."
    },
    "category_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Slug of the category. `categoryId` on the camelCase endpoints."
    },
    "category_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "Display name of the category."
    },
    "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."
    },
    "year_introduced": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Year the model was introduced."
    },
    "action_type": {
      "type": [
        "string",
        "null"
      ],
      "description": "Operating action as stored, underscored, e.g. `short_recoil`, `bolt_action`, `gas_operated`. The full vocabulary is `/v1/firearms/action-types`; a hyphenated value matches nothing."
    },
    "country_of_origin": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO 3166-1 alpha-2 code of the country of origin."
    },
    "weight_empty_g": {
      "type": [
        "number",
        "null"
      ],
      "description": "Unloaded weight in grams, one of the two figures a catalogue card draws beside the year. Null where the record has none."
    },
    "barrel_length_mm": {
      "type": [
        "number",
        "null"
      ],
      "description": "Barrel length in millimetres, the other of the two figures a card draws. Null where the record has none."
    },
    "svg_line_art_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Line-art silhouette, or null where none has been drawn."
    },
    "model_3d_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "GLB model, or null where none is on file."
    },
    "favorite_count": {
      "type": "integer",
      "description": "How many accounts have favorited this record."
    },
    "images": {
      "type": "array",
      "description": "Every image this firearm has, silhouette first. Empty when none are on file.",
      "items": {
        "$ref": "#/$defs/InlineMediaItem"
      }
    }
  },
  "required": [
    "id",
    "firearm_id",
    "favorited_at",
    "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."
    },
    "InlineMediaItem": {
      "type": "object",
      "description": "One image attached to a firearm, inlined on list-shaped responses so a client can render a gallery without a second request. `url` is absolute and directly fetchable. For the full envelope, including credits, licence, dimensions and data-URI encoding, use `/v1/firearms/{id}/media`.",
      "properties": {
        "id": {
          "type": "integer",
          "description": "Autoincrementing image id."
        },
        "url": {
          "type": "string",
          "description": "Absolute, directly fetchable URL."
        },
        "kind": {
          "$ref": "#/$defs/MediaKind"
        },
        "alt": {
          "type": [
            "string",
            "null"
          ],
          "description": "Alt text, where one has been written. Null otherwise, so do not render an empty string."
        },
        "width": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Pixel width, where it is known."
        },
        "height": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Pixel height, where it is known."
        }
      },
      "required": [
        "id",
        "url",
        "kind"
      ]
    },
    "MediaKind": {
      "type": "string",
      "enum": [
        "silhouette",
        "render",
        "photo",
        "schematic",
        "model"
      ],
      "description": "What kind of asset a media row is."
    }
  }
}