{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/amigo/main/json-schema/amigo-metric-list-response-schema.json",
  "title": "MetricListResponse",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amigo-metrics-api-openapi.yml#/components/schemas/MetricListResponse",
  "properties": {
    "metrics": {
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/NumericalMetricValueResponse"
          },
          {
            "$ref": "#/$defs/CategoricalMetricValueResponse"
          },
          {
            "$ref": "#/$defs/BooleanMetricValueResponse"
          }
        ]
      },
      "type": "array",
      "title": "Metrics"
    }
  },
  "type": "object",
  "required": [
    "metrics"
  ],
  "$defs": {
    "BooleanMetricValueResponse": {
      "properties": {
        "metric_key": {
          "type": "string",
          "title": "Metric Key"
        },
        "source": {
          "type": "string",
          "title": "Source",
          "default": "production"
        },
        "entity_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Entity Type"
        },
        "entity_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Entity Id"
        },
        "service_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Service Id"
        },
        "run_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Run Id"
        },
        "session_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Session Id"
        },
        "period_start": {
          "type": "string",
          "format": "date-time",
          "title": "Period Start"
        },
        "period_end": {
          "type": "string",
          "format": "date-time",
          "title": "Period End"
        },
        "event_count": {
          "type": "integer",
          "title": "Event Count"
        },
        "avg_confidence": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Avg Confidence"
        },
        "unit": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 32
            },
            {
              "type": "null"
            }
          ],
          "title": "Unit"
        },
        "computed_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Computed At"
        },
        "metric_type": {
          "type": "string",
          "const": "boolean",
          "title": "Metric Type"
        },
        "value": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value"
        }
      },
      "type": "object",
      "required": [
        "metric_key",
        "period_start",
        "period_end",
        "event_count",
        "metric_type",
        "value"
      ],
      "title": "BooleanMetricValueResponse"
    },
    "CategoricalMetricValueResponse": {
      "properties": {
        "metric_key": {
          "type": "string",
          "title": "Metric Key"
        },
        "source": {
          "type": "string",
          "title": "Source",
          "default": "production"
        },
        "entity_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Entity Type"
        },
        "entity_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Entity Id"
        },
        "service_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Service Id"
        },
        "run_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Run Id"
        },
        "session_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Session Id"
        },
        "period_start": {
          "type": "string",
          "format": "date-time",
          "title": "Period Start"
        },
        "period_end": {
          "type": "string",
          "format": "date-time",
          "title": "Period End"
        },
        "event_count": {
          "type": "integer",
          "title": "Event Count"
        },
        "avg_confidence": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Avg Confidence"
        },
        "unit": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 32
            },
            {
              "type": "null"
            }
          ],
          "title": "Unit"
        },
        "computed_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Computed At"
        },
        "metric_type": {
          "type": "string",
          "const": "categorical",
          "title": "Metric Type"
        },
        "value": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value"
        }
      },
      "type": "object",
      "required": [
        "metric_key",
        "period_start",
        "period_end",
        "event_count",
        "metric_type",
        "value"
      ],
      "title": "CategoricalMetricValueResponse"
    },
    "NumericalMetricValueResponse": {
      "properties": {
        "metric_key": {
          "type": "string",
          "title": "Metric Key"
        },
        "source": {
          "type": "string",
          "title": "Source",
          "default": "production"
        },
        "entity_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Entity Type"
        },
        "entity_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Entity Id"
        },
        "service_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Service Id"
        },
        "run_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Run Id"
        },
        "session_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Session Id"
        },
        "period_start": {
          "type": "string",
          "format": "date-time",
          "title": "Period Start"
        },
        "period_end": {
          "type": "string",
          "format": "date-time",
          "title": "Period End"
        },
        "event_count": {
          "type": "integer",
          "title": "Event Count"
        },
        "avg_confidence": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Avg Confidence"
        },
        "unit": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 32
            },
            {
              "type": "null"
            }
          ],
          "title": "Unit"
        },
        "computed_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Computed At"
        },
        "metric_type": {
          "type": "string",
          "const": "numerical",
          "title": "Metric Type"
        },
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value"
        }
      },
      "type": "object",
      "required": [
        "metric_key",
        "period_start",
        "period_end",
        "event_count",
        "metric_type",
        "value"
      ],
      "title": "NumericalMetricValueResponse"
    }
  }
}