{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openssom.org/schema/quantity-kind-unit-registry.json",
  "title": "SSOM Quantity Kind And Unit Registry",
  "description": "Machine-readable index of governed quantity kinds and the unit codes accepted for each, with a reference into a recognised unit vocabulary.",
  "type": "object",
  "required": [
    "registry_id",
    "registry_version",
    "unit_reference_vocabulary",
    "quantity_kinds",
    "units"
  ],
  "properties": {
    "registry_id": {
      "type": "string"
    },
    "registry_version": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "unit_reference_vocabulary": {
      "type": "object",
      "required": [
        "vocabulary_id",
        "name"
      ],
      "properties": {
        "vocabulary_id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "quantity_kinds": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "code",
          "introduced_in",
          "description"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "introduced_in": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "references": {
            "type": "object",
            "required": [
              "match"
            ],
            "properties": {
              "match": {
                "type": "string",
                "enum": [
                  "exact",
                  "close",
                  "broader",
                  "narrower",
                  "none"
                ],
                "description": "How the SSOM quantity kind relates to the QUDT quantity kind named. `broader` means the QUDT kind is the broader one."
              },
              "qudt_quantity_kind": {
                "type": "string",
                "pattern": "^http://qudt\\.org/vocab/quantitykind/[A-Za-z0-9_-]+$"
              }
            },
            "additionalProperties": false
          },
          "dimension_vectors": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^A-?\\d+E-?\\d+L-?\\d+I-?\\d+M-?\\d+H-?\\d+T-?\\d+D-?\\d+$"
            },
            "description": "QUDT dimension vectors a unit of this kind may have."
          },
          "reference_note": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deprecated"
            ]
          },
          "deprecated_in": {
            "type": "string"
          },
          "replaced_by": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "units": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "unit_code",
          "reference_code",
          "quantity_kinds"
        ],
        "properties": {
          "unit_code": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]*$"
          },
          "reference_code": {
            "type": "string",
            "minLength": 1
          },
          "quantity_kinds": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string"
            }
          },
          "references": {
            "type": "object",
            "required": [
              "ucum"
            ],
            "properties": {
              "ucum": {
                "type": "string",
                "minLength": 1
              },
              "qudt_unit": {
                "type": "string",
                "pattern": "^http://qudt\\.org/vocab/unit/[A-Za-z0-9_-]+$"
              },
              "unece_rec20": {
                "type": "string",
                "pattern": "^[A-Z0-9]{2,3}$"
              }
            },
            "additionalProperties": false
          },
          "dimension_vector": {
            "type": "string",
            "pattern": "^A-?\\d+E-?\\d+L-?\\d+I-?\\d+M-?\\d+H-?\\d+T-?\\d+D-?\\d+$"
          },
          "reference_note": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deprecated"
            ]
          },
          "deprecated_in": {
            "type": "string"
          },
          "replaced_by": {
            "type": "string"
          },
          "introduced_in": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "reference_vocabularies": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "vocabulary_id",
          "role",
          "name",
          "version",
          "source"
        ],
        "properties": {
          "vocabulary_id": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "unit_code",
              "unit_and_quantity_kind_identifier",
              "cross_reference_only"
            ]
          },
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        },
        "additionalProperties": false
      }
    },
    "previous_registry_version": {
      "type": "string"
    }
  },
  "additionalProperties": false
}
