{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/arpi-ai/json-schema/arpi-ai-diag-products-response-schema.json",
  "title": "DiagProductsResponse",
  "description": "Product projection response. HTTP status reflects job state: 200 = COMPLETED, 202 = PENDING, 500 = FAILED. Products are resolved only when the job is COMPLETED.",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/arpi-ai-openapi.json#/components/schemas/DiagProductsResponse",
  "type": "object",
  "properties": {
    "jobId": {
      "type": "string",
      "description": "Job ID"
    },
    "status": {
      "type": "string",
      "description": "Current job status",
      "enum": [
        "PENDING",
        "COMPLETED",
        "FAILED"
      ]
    },
    "products": {
      "type": "array",
      "description": "Requested products. Empty unless COMPLETED.",
      "items": {
        "$ref": "#/$defs/ProductResult"
      }
    },
    "thresholds": {
      "type": "object",
      "description": "Fixed EB biomarker grade cutoffs (diagKey → thresholds). Static catalog — identical for every job and present in every status. Use it to interpret raw biomarker scores.",
      "additionalProperties": {
        "$ref": "#/$defs/BiomarkerThresholdResponse"
      }
    }
  },
  "required": [
    "jobId",
    "products",
    "status",
    "thresholds"
  ],
  "$defs": {
    "BiomarkerThresholdResponse": {
      "type": "object",
      "description": "Fixed grade cutoffs for an EB biomarker field. Each value is the inclusive entry threshold (%) for the next grade band: `score < intermediate` = LOW, `< high` = INTERMEDIATE, `< veryHigh` = HIGH, otherwise VERY_HIGH.",
      "properties": {
        "intermediate": {
          "type": "number",
          "format": "double",
          "description": "INTERMEDIATE band entry threshold (%)"
        },
        "high": {
          "type": "number",
          "format": "double",
          "description": "HIGH band entry threshold (%)"
        },
        "veryHigh": {
          "type": "number",
          "format": "double",
          "description": "VERY_HIGH band entry threshold (%)"
        }
      },
      "required": [
        "intermediate",
        "high",
        "veryHigh"
      ]
    },
    "ProductResult": {
      "type": "object",
      "description": "One product projection derived from the analysis output. The `fields` keys depend on the job's analysis engine (the `?engine` chosen at submit time; see the endpoint description for the v1/v2 layout).",
      "properties": {
        "type": {
          "type": "string",
          "description": "Product type",
          "enum": [
            "EB",
            "EBR",
            "EBC",
            "HEART_AGE_MORT",
            "GLS",
            "DIAST_DYSF",
            "VHD"
          ]
        },
        "variant": {
          "type": "string",
          "description": "Applied output variant (BASIC, or EU where configured)"
        },
        "fields": {
          "type": "object",
          "description": "Projected field map (name → value). Keys absent in the source are omitted. Read field names from the response rather than hard-coding them.",
          "additionalProperties": {
            "type": "string"
          }
        },
        "imageUrl": {
          "type": "string",
          "description": "Presigned image URL for this product, or null if it has no image."
        }
      },
      "required": [
        "type",
        "variant",
        "fields"
      ]
    }
  }
}