{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peppolstatus-com/json-schema/peppolstatus-com-id-quality-malformed-page-schema.json",
  "title": "IdQualityMalformedPage",
  "description": "A keyset page of malformed identifiers with first-page facets.",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peppolstatus-com-id-quality-api-openapi.yml#/components/schemas/IdQualityMalformedPage",
  "type": "object",
  "required": [
    "items",
    "next_cursor",
    "meta"
  ],
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/IdQualityViolation"
      }
    },
    "next_cursor": {
      "type": [
        "string",
        "null"
      ],
      "description": "Opaque cursor for the next page, or null on the last page."
    },
    "meta": {
      "type": "object",
      "required": [
        "facets"
      ],
      "properties": {
        "facets": {
          "type": "object",
          "required": [
            "scheme",
            "reason",
            "smp"
          ],
          "description": "Value→count maps honouring the other active filters.",
          "properties": {
            "scheme": {
              "type": "object",
              "additionalProperties": {
                "type": "integer"
              }
            },
            "reason": {
              "type": "object",
              "additionalProperties": {
                "type": "integer"
              }
            },
            "smp": {
              "type": "object",
              "additionalProperties": {
                "type": "integer"
              },
              "description": "Top-50 serving SMP hostnames → malformed-id count."
            }
          }
        }
      }
    }
  },
  "$defs": {
    "IdQualityViolation": {
      "type": "object",
      "description": "One participant identifier that failed its scheme's structural rule.",
      "required": [
        "scheme",
        "value",
        "participant_id",
        "rule",
        "reason",
        "detail",
        "first_detected_at",
        "last_checked_at",
        "smp",
        "ap_seat_id",
        "ap_provider"
      ],
      "properties": {
        "scheme": {
          "type": "string"
        },
        "value": {
          "type": "string"
        },
        "participant_id": {
          "type": "string",
          "description": "Full canonical participant id, e.g. `iso6523-actorid-upis::0208:1039563252`."
        },
        "rule": {
          "type": "string"
        },
        "reason": {
          "type": "string",
          "enum": [
            "length",
            "charset",
            "check-digit"
          ]
        },
        "detail": {
          "type": [
            "string",
            "null"
          ]
        },
        "first_detected_at": {
          "type": "string",
          "format": "date-time"
        },
        "last_checked_at": {
          "type": "string",
          "format": "date-time"
        },
        "smp": {
          "type": [
            "string",
            "null"
          ],
          "description": "Serving SMP hostname, or null."
        },
        "ap_seat_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Serving AP seat id, or null."
        },
        "ap_provider": {
          "type": [
            "string",
            "null"
          ],
          "description": "Display name of the serving AP seat's provider, or null."
        }
      }
    }
  }
}