{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.anguskit.com/schema/angusmeter/plugins/angus-dubbo.json",
  "type": "object",
  "properties": {
    "host": {
      "type": "string",
      "default": "localhost"
    },
    "port": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535,
      "description": "Service port; default varies by protocol: rest=8080, dubbo/tri=20880"
    },
    "protocol": {
      "type": "string",
      "enum": [
        "dubbo",
        "rest",
        "tri"
      ],
      "default": "rest",
      "description": "dubbo=telnet, rest=HTTP/1.1 REST gateway, tri=Triple HTTP/2 JSON gateway"
    },
    "interfaceName": {
      "type": "string",
      "description": "Fully-qualified service interface name, e.g. com.example.GreetingService"
    },
    "methodName": {
      "type": "string",
      "description": "Method name to invoke"
    },
    "path": {
      "type": "string",
      "description": "Explicit REST/Triple HTTP path override (default: /{SimpleClassName}/{methodName}); supports ${var} interpolation"
    },
    "version": {
      "type": "string",
      "description": "Service version (multi-version routing), e.g. 1.0.0"
    },
    "group": {
      "type": "string",
      "description": "Service group for isolation"
    },
    "parameterTypes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Fully-qualified parameter types for overloaded method disambiguation"
    },
    "arguments": {
      "type": "array",
      "items": {
        "description": "Method argument value (string, number, boolean, object, or array)"
      },
      "description": "Method arguments; supports ${var} interpolation in string values"
    },
    "timeout": {
      "type": "integer",
      "default": 5000,
      "minimum": 1,
      "maximum": 300000,
      "description": "Timeout in milliseconds (1–300000)"
    },
    "tls": {
      "type": "object",
      "description": "TLS configuration for REST/Triple HTTPS endpoints. Field names align with cloud.xcan.angus.spec.model.TlsConfig.",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": false,
          "description": "If true, use HTTPS as the scheme"
        },
        "trustAll": {
          "type": "boolean",
          "default": false,
          "description": "Trust all certificates (testing only). Required for verifyHostname=false to take effect in JDK HttpClient."
        },
        "verifyHostname": {
          "type": "boolean",
          "default": true,
          "description": "Whether to verify server hostname against certificate CN/SANs (only effective when trustAll=true)"
        },
        "keystorePath": {
          "type": "string",
          "description": "Path to client keystore (JKS/PKCS12) for mTLS"
        },
        "keystorePassword": {
          "type": "string",
          "writeOnly": true
        },
        "truststorePath": {
          "type": "string",
          "description": "Path to custom trust store (JKS/PKCS12)"
        },
        "truststorePassword": {
          "type": "string",
          "writeOnly": true
        },
        "protocols": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Allowed TLS protocols, e.g. [\"TLSv1.3\"]"
        },
        "ciphers": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Allowed cipher suites"
        }
      }
    },
    "attachments": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Dubbo attachment headers (traceId, spanId, etc.) sent as HTTP headers in REST/Triple mode"
    },
    "headers": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Extra HTTP headers (REST/Triple mode); supports ${var} interpolation"
    },
    "assertions": {
      "type": "array",
      "description": "Optional step-level assertions evaluated against the Dubbo sample result (see DubboConfigValidator; Assertion.AssertionType).",
      "items": {
        "$ref": "#/definitions/dubboAssertion"
      }
    },
    "extractors": {
      "type": "array",
      "description": "Optional extractors from the Dubbo response (see DubboConfigValidator; Extractor.ExtractorType).",
      "items": {
        "$ref": "#/definitions/dubboExtractor"
      }
    }
  },
  "required": [
    "interfaceName",
    "methodName"
  ],
  "definitions": {
    "dubboAssertion": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "STATUS_CODE",
            "RESPONSE_TIME",
            "BODY_CONTAINS",
            "BODY_JSON_PATH",
            "BODY_REGEX",
            "HEADER_EXISTS",
            "HEADER_VALUE",
            "BODY_SIZE",
            "NOT_NULL",
            "CUSTOM",
            "BODY_EQUALS",
            "BODY_XPATH",
            "METRIC_SCORE",
            "TOKEN_COUNT",
            "API_COST",
            "LLM_LATENCY",
            "JSON_SCHEMA",
            "NO_PII",
            "RESPONSE_BODY",
            "URL",
            "TITLE",
            "ELEMENT_TEXT",
            "ELEMENT_VALUE",
            "ELEMENT_VISIBLE",
            "ORIENTATION"
          ]
        },
        "operator": {
          "type": "string"
        },
        "expected": {
          "description": "Expected value for the assertion"
        },
        "expression": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        }
      },
      "required": [
        "type"
      ]
    },
    "dubboExtractor": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "JSON_PATH",
            "XPATH",
            "REGEX",
            "HEADER",
            "COOKIE",
            "RESPONSE_CODE",
            "RESPONSE_TIME"
          ]
        },
        "expression": {
          "type": "string"
        },
        "variable": {
          "type": "string"
        },
        "defaultValue": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "variable"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "JSON_PATH",
                  "XPATH",
                  "REGEX",
                  "HEADER",
                  "COOKIE"
                ]
              }
            }
          },
          "then": {
            "required": [
              "expression"
            ]
          }
        }
      ]
    }
  }
}
