{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arcnm-io/json-schema/arcnm-io-material-grade-public-schema.json",
  "title": "MaterialGradePublic",
  "description": "API projection. ``primary_code`` is the standards-compliant cased\ndisplay form (e.g. ``X5CrNi18-10``, ``PA6-GF30``, ``EN AW-6061``) —\nsafe to render directly. The lowercase lookup form is internal and\nnot exposed.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/arcnm-io-materials-api-openapi.yml#/components/schemas/MaterialGradePublic",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id",
      "description": "Unique identifier of the material grade."
    },
    "org_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Org Id",
      "description": "Null → platform-catalogue grade shared by every organization; set → this organization's private grade."
    },
    "urn": {
      "type": "string",
      "title": "Urn",
      "description": "Canonical URN that uniquely and stably identifies this grade across systems."
    },
    "category": {
      "$ref": "#/$defs/MaterialCategory",
      "description": "Broad material family the grade belongs to (e.g. steel, aluminium, polymer)."
    },
    "primary_standard_id": {
      "type": "string",
      "format": "uuid",
      "title": "Primary Standard Id",
      "description": "Identifier of the standard that defines this grade's primary code."
    },
    "primary_standard_code": {
      "anyOf": [
        {
          "$ref": "#/$defs/MaterialStandardCode"
        },
        {
          "type": "null"
        }
      ],
      "description": "URN-safe code of the primary standard (``en10027-2``, ``iso1043-1``, …). Hydrated by the routes layer so frontends can render a badge without a second round-trip."
    },
    "primary_code": {
      "type": "string",
      "title": "Primary Code",
      "description": "Standards-compliant cased display code; the same value as `display_code`."
    },
    "name": {
      "type": "string",
      "title": "Name",
      "description": "Human-readable name of the material grade."
    },
    "iso_machining_group": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoMachiningGroup"
        },
        {
          "type": "null"
        }
      ],
      "description": "ISO 513 machining group (P/M/K/N/S/H) used to gauge machinability."
    },
    "density_kg_per_m3": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Density Kg Per M3",
      "description": "Material density in kilograms per cubic metre."
    },
    "is_active": {
      "type": "boolean",
      "title": "Is Active",
      "description": "Whether the grade is currently active and selectable; false when retired."
    },
    "successor_grade_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Successor Grade Id",
      "description": "Identifier of the grade that supersedes this one; null when still current."
    },
    "workpiece_group_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Workpiece Group Id",
      "description": "Identifier of the workpiece material group (ISO 513 letter → composition subgroup → hardness band) whose cutting data prices this grade; null when the grade falls back to its category's default cutting data."
    },
    "workpiece_group_code": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Workpiece Group Code",
      "description": "The group's short code (e.g. ``P1.2``, ``M1.1``, ``K2.2``), hydrated by the routes layer so a UI can render it without a second round-trip."
    },
    "attributes": {
      "additionalProperties": true,
      "type": "object",
      "title": "Attributes",
      "description": "The grade's material statement — mechanical and physical figures plus the categorical route gates. A closed vocabulary; see `GET /materials/attribute-vocabulary` for every key and what it drives."
    },
    "aliases": {
      "items": {
        "$ref": "#/$defs/MaterialGradeAliasPublic"
      },
      "type": "array",
      "title": "Aliases",
      "description": "Cross-references mapping this grade's code across other standards and trade names. Filled on single-grade reads (`GET /materials/grades/{id}`, `/grades/by-urn/{urn}`, `/grades/{id}/master`); list, lookup and batch results always carry an empty list to keep them small — read the grade (e.g. get_grade_master) for its aliases."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Timestamp when the grade record was created."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Timestamp when the grade record was last updated."
    }
  },
  "type": "object",
  "required": [
    "id",
    "urn",
    "category",
    "primary_standard_id",
    "primary_code",
    "name",
    "is_active",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "IsoMachiningGroup": {
      "type": "string",
      "enum": [
        "P",
        "M",
        "K",
        "N",
        "S",
        "H"
      ],
      "title": "IsoMachiningGroup",
      "description": "ISO 513 workpiece groups — drives cutting-data lookup and tariffs.\n\n* ``P`` — non-alloyed & low-alloyed steels\n* ``M`` — stainless steels (austenitic, duplex, …)\n* ``K`` — cast iron (grey, nodular, malleable)\n* ``N`` — non-ferrous (aluminium, copper, plastics)\n* ``S`` — heat-resistant super-alloys + titanium\n* ``H`` — hardened steels (45–65 HRC)"
    },
    "MaterialCategory": {
      "type": "string",
      "enum": [
        "carbon_steel",
        "alloy_steel",
        "stainless_steel",
        "tool_steel",
        "cast_iron",
        "aluminium",
        "copper_alloy",
        "nickel_alloy",
        "titanium_alloy",
        "magnesium_alloy",
        "zinc_alloy",
        "thermoplastic",
        "thermoset",
        "elastomer",
        "composite",
        "other"
      ],
      "title": "MaterialCategory",
      "description": "Top-level material family. Drives ISO machining group defaults and\nUI filtering. Values are stable identifiers — adding a new category is\nadditive; renaming is a breaking change."
    },
    "MaterialGradeAliasPublic": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "Unique identifier of the alias."
        },
        "material_grade_id": {
          "type": "string",
          "format": "uuid",
          "title": "Material Grade Id",
          "description": "Identifier of the canonical grade this alias points to."
        },
        "standard_id": {
          "anyOf": [
            {
              "type": "string",
              "format": "uuid"
            },
            {
              "type": "null"
            }
          ],
          "title": "Standard Id",
          "description": "Identifier of the standard the alias belongs to; null for a free-form trade name."
        },
        "standard_code": {
          "anyOf": [
            {
              "$ref": "#/$defs/MaterialStandardCode"
            },
            {
              "type": "null"
            }
          ],
          "description": "URN-safe code of the alias standard; null for a free-form trade name."
        },
        "code": {
          "type": "string",
          "title": "Code",
          "description": "Standards-compliant cased form; the same value as `display_code`."
        },
        "is_canonical": {
          "type": "boolean",
          "title": "Is Canonical",
          "description": "Whether this alias is itself a canonical name under its standard.",
          "default": false
        },
        "is_preferred_display": {
          "type": "boolean",
          "title": "Is Preferred Display",
          "description": "Whether this alias is preferred when rendering the grade."
        }
      },
      "type": "object",
      "required": [
        "id",
        "material_grade_id",
        "code",
        "is_preferred_display"
      ],
      "title": "MaterialGradeAliasPublic"
    },
    "MaterialStandardCode": {
      "type": "string",
      "enum": [
        "en10027-1",
        "en10027-2",
        "en10025",
        "en10083",
        "en10084",
        "en10088",
        "en10346",
        "en-iso-4957",
        "en573-1",
        "en573-2",
        "en1412",
        "din17007",
        "en1560",
        "en1561",
        "en1563",
        "iso1043-1",
        "iso1043-2",
        "iso18064",
        "uns",
        "aisi-sae",
        "jis",
        "astm",
        "en10130",
        "en10111",
        "en10149",
        "en10085",
        "en10087",
        "en10089",
        "en10028",
        "en10216",
        "en10305",
        "en10293",
        "en10302",
        "iso683-17",
        "en1562",
        "en1564",
        "en16079",
        "en573-3",
        "en1706",
        "en1982",
        "en1753",
        "en12844",
        "en60893",
        "iso1629",
        "din17100",
        "din17200",
        "din17210",
        "din17440",
        "din1691",
        "din1692",
        "din1693",
        "din1725",
        "din17660",
        "eclass",
        "unspsc",
        "org"
      ],
      "title": "MaterialStandardCode",
      "description": "Issuing standard codes used in URNs and the ``MaterialStandard`` table.\n\nValues are URN-safe (lowercase, hyphenated). The human-readable name\nand issuing body are stored in the ``MaterialStandard`` row.\n\nEach code is tagged with a *kind* (designation, numbering, product,\nclassification) in the database — that is what tells the UI whether\na code is a name for a material (``EN 10027-1``), a number for a\nmaterial (``EN 10027-2``), a list of which materials are deliverable\nunder what conditions (``EN 10025``), or a cross-industry taxonomy\n(``ECLASS``)."
    }
  }
}