{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/propraven-com/json-schema/propraven-com-contractor-schema.json",
  "title": "Contractor",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/propraven-com-deals-api-openapi.yml#/components/schemas/Contractor",
  "type": "object",
  "required": [
    "contractor_name_normalized",
    "contractor_license",
    "permit_count",
    "jurisdiction_count",
    "state_count",
    "county_count",
    "total_permit_value",
    "avg_permit_value",
    "first_permit_date",
    "last_permit_date",
    "active_years",
    "top_permit_types",
    "states_list",
    "contractor_rank"
  ],
  "properties": {
    "contractor_name_normalized": {
      "type": [
        "string",
        "null"
      ]
    },
    "contractor_license": {
      "type": [
        "string",
        "null"
      ]
    },
    "permit_count": {
      "type": [
        "integer",
        "null"
      ]
    },
    "jurisdiction_count": {
      "type": [
        "integer",
        "null"
      ]
    },
    "state_count": {
      "type": [
        "integer",
        "null"
      ]
    },
    "county_count": {
      "type": [
        "integer",
        "null"
      ]
    },
    "total_permit_value": {
      "type": [
        "integer",
        "null"
      ]
    },
    "avg_permit_value": {
      "type": [
        "number",
        "null"
      ],
      "description": "total_permit_value / permit_count (#558); see avg_valued_permit_value for the mean over permits with a recorded cost."
    },
    "first_permit_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "last_permit_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "active_years": {
      "type": [
        "integer",
        "null"
      ]
    },
    "top_permit_types": {
      "type": [
        "string",
        "null"
      ]
    },
    "states_list": {
      "type": [
        "string",
        "null"
      ],
      "description": "Comma-delimited 2-letter state codes."
    },
    "contractor_rank": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Contiguous position in this filtered, rank-ordered list (offset + position); contractor_rank_stored is the producer's national rank."
    },
    "contractor_name_raw": {
      "type": "string",
      "description": "The stored name when stray leading/trailing punctuation was trimmed."
    },
    "contractor_rank_stored": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The producer's rank over its own universe (includes names this list filters out)."
    },
    "avg_valued_permit_value": {
      "type": [
        "number",
        "null"
      ],
      "description": "The producer's mean over permits with a recorded positive cost."
    },
    "valued_permit_count_implied": {
      "type": [
        "integer",
        "null"
      ],
      "description": "total_permit_value / avg_valued_permit_value."
    },
    "avg_permit_value_basis": {
      "type": "string",
      "enum": [
        "total_over_permit_count",
        "no_recorded_cost",
        "no_permit_count"
      ]
    },
    "county_count_raw": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The stored 0 when county_count is served null (no source permit carried a county)."
    },
    "county_count_basis": {
      "type": "string",
      "enum": [
        "stored",
        "county_fips_missing_on_permits",
        "unavailable"
      ]
    },
    "state_count_basis": {
      "type": "string",
      "enum": [
        "geography_unavailable"
      ]
    }
  },
  "additionalProperties": false
}