{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openfreytprotocol.example/schemas/v0/vehicle-spec",
  "title": "VehicleSpec",
  "description": "Specification of a vehicle or trailer type offered or required in a capacity transaction. Body type is drawn from a normative enum; the 'extension:' prefix allows proprietary types without schema changes.",
  "type": "object",
  "properties": {
    "vehicleBodyType": {
      "description": "Normative vehicle/trailer body type. Use the 'extension:<value>' pattern for types not in the standard enum.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "tautliner",
            "curtainsider",
            "box",
            "refrigerated",
            "flatbed",
            "tanker",
            "bulk",
            "heavy-lift",
            "low-loader",
            "swap-body"
          ]
        },
        {
          "type": "string",
          "pattern": "^extension:.+$",
          "description": "Proprietary extension type. Format: 'extension:<namespace>/<type>' is recommended."
        }
      ]
    },
    "capacity": {
      "$ref": "#/$defs/Capacity"
    }
  },
  "required": ["vehicleBodyType"],
  "$defs": {
    "Capacity": {
      "title": "Capacity",
      "description": "Dimensional and weight capacity of the vehicle. All sub-dimensions are optional individually, but at least one should be present in practice.",
      "type": "object",
      "properties": {
        "weight": {
          "$ref": "#/$defs/Measure",
          "description": "Maximum payload weight. Recommended unit code: 'KGM' (kilogram) per UN/CEFACT."
        },
        "volume": {
          "$ref": "#/$defs/Measure",
          "description": "Internal loading volume. Recommended unit code: 'MTQ' (cubic metre) per UN/CEFACT."
        },
        "loadingMetres": {
          "$ref": "#/$defs/Measure",
          "description": "Loading metre capacity (effective floor length usable for loading). Recommended unit code: 'MTR' (metre) per UN/CEFACT."
        }
      }
    },
    "Measure": {
      "title": "Measure",
      "description": "A numeric quantity with a UN/CEFACT unit code.",
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "minimum": 0,
          "description": "Non-negative numeric quantity."
        },
        "unitCode": {
          "type": "string",
          "description": "UN/CEFACT Recommendation 20 unit code, e.g. 'KGM', 'MTQ', 'MTR'."
        }
      },
      "required": ["value", "unitCode"]
    }
  }
}
