{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:bgi:schema:material-profile:1",
  "title": "bgi material profile v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "id",
    "profile_version",
    "name",
    "family",
    "status",
    "nominal_thickness_mm",
    "parameters"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "id": {
      "$ref": "#/$defs/id"
    },
    "profile_version": {
      "type": "integer",
      "minimum": 1
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "family": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "type": "string",
      "minLength": 1
    },
    "reference_product": {
      "type": "string",
      "minLength": 1
    },
    "nominal_thickness_mm": {
      "$ref": "#/$defs/nullableLength"
    },
    "parameters": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "thickness_mm",
        "kerf_mm",
        "fit_clearance_mm",
        "min_web_mm",
        "min_tab_mm",
        "joint_edge_margin_mm",
        "compensation"
      ],
      "properties": {
        "thickness_mm": {
          "$ref": "#/$defs/nullableLength"
        },
        "kerf_mm": {
          "$ref": "#/$defs/nullableLength"
        },
        "fit_clearance_mm": {
          "$ref": "#/$defs/nullableLength"
        },
        "min_web_mm": {
          "$ref": "#/$defs/nullableLength"
        },
        "min_tab_mm": {
          "$ref": "#/$defs/nullableLength"
        },
        "joint_edge_margin_mm": {
          "$ref": "#/$defs/nullableLength"
        },
        "compensation": {
          "enum": [
            "bgi",
            "external",
            null
          ]
        }
      }
    },
    "parameter_basis": {
      "type": "string",
      "minLength": 1
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$",
      "maxLength": 80
    },
    "nullableLength": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0,
      "maximum": 2000,
      "multipleOf": 0.001
    }
  }
}
